scan-fragmented.cc 723 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
#include <embb/algorithms/algorithms.h>
#include <embb/base/c/internal/unused.h>
#include <vector>

void CheckResults(const std::vector<int>& results) {
  assert(results.size() == 5);
  assert(results[0] == 1);
  assert(results[1] == 3);
  assert(results[2] == 6);
  assert(results[3] == 10);
  assert(results[4] == 15);
  EMBB_UNUSED_IN_RELEASE(results);
}

/**
 * Example using embb::algorithms::Scan.
 *
 *
 */
void RunScan() {
  #include "algorithms/scan/setup-snippet.h"

  #include "algorithms/scan/sequential_prefix_sum-snippet.h"
  CheckResults(output_range);

  for (size_t i = 0; i < output_range.size(); i++) output_range[i] = 0;
  #include "algorithms/scan/prefix_sum-snippet.h"
  CheckResults(output_range);
}