MCPcopy Create free account
hub / github.com/boostorg/compute / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

test/test_scan.cpp:41–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39namespace bc = boost::compute;
40
41BOOST_AUTO_TEST_CASE(inclusive_scan_int)
42{
43 using boost::compute::uint_;
44 using boost::compute::int_;
45
46 int_ data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
47 bc::vector<int_> vector(data, data + 12, queue);
48 BOOST_CHECK_EQUAL(vector.size(), size_t(12));
49
50 bc::vector<int_> result(12, context);
51 BOOST_CHECK_EQUAL(result.size(), size_t(12));
52
53 // inclusive scan
54 bc::inclusive_scan(vector.begin(), vector.end(), result.begin(), queue);
55 CHECK_RANGE_EQUAL(int_, 12, result, (0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66));
56
57 // in-place inclusive scan
58 CHECK_RANGE_EQUAL(int_, 12, vector, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
59 bc::inclusive_scan(vector.begin(), vector.end(), vector.begin(), queue);
60 CHECK_RANGE_EQUAL(int_, 12, vector, (0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66));
61
62 // scan_on_cpu
63
64 bc::copy(data, data + 12, vector.begin(), queue);
65
66 // make sure parallel scan_on_cpu is used, no serial_scan
67 std::string cache_key =
68 "__boost_scan_cpu_4";
69 boost::shared_ptr<bc::detail::parameter_cache> parameters =
70 bc::detail::parameter_cache::get_global_cache(device);
71
72 // save
73 uint_ map_copy_threshold =
74 parameters->get(cache_key, "serial_scan_threshold", 0);
75 // force parallel scan_on_cpu
76 parameters->set(cache_key, "serial_scan_threshold", 0);
77
78 // inclusive scan
79 bc::inclusive_scan(vector.begin(), vector.end(), result.begin(), queue);
80 CHECK_RANGE_EQUAL(int_, 12, result, (0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66));
81
82 // in-place inclusive scan
83 CHECK_RANGE_EQUAL(int_, 12, vector, (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
84 bc::inclusive_scan(vector.begin(), vector.end(), vector.begin(), queue);
85 CHECK_RANGE_EQUAL(int_, 12, vector, (0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66));
86
87 // restore
88 parameters->set(cache_key, "serial_scan_threshold", map_copy_threshold);
89}
90
91BOOST_AUTO_TEST_CASE(exclusive_scan_int)
92{

Callers

nothing calls this directly

Calls 13

inclusive_scanFunction · 0.85
copyFunction · 0.85
exclusive_scanFunction · 0.85
make_counting_iteratorFunction · 0.85
make_transform_iteratorFunction · 0.85
partial_sumFunction · 0.85
CHECK_RANGE_EQUALFunction · 0.70
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected