MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / run_binary_transform_test

Function run_binary_transform_test

tests/pstl/transform.cpp:60–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60void run_binary_transform_test(std::size_t problem_size) {
61 std::vector<int> data1(problem_size);
62 for(int i = 0; i < data1.size(); ++i) {
63 data1[i] = i;
64 }
65
66 std::vector<int> data2(problem_size);
67 for(int i = 0; i < data2.size(); ++i) {
68 data2[i] = -i+10;
69 }
70
71
72 std::vector<int> device_out(problem_size);
73 std::vector<int> host_out(problem_size);
74
75 auto transformation = [](auto x, auto y) {
76 return x * y + y;
77 };
78
79 auto ret =
80 std::transform(std::execution::par_unseq, data1.begin(), data1.end(),
81 data2.begin(), device_out.begin(), transformation);
82 auto host_ret = std::transform(data1.begin(), data1.end(), data2.begin(),
83 host_out.begin(), transformation);
84
85 BOOST_CHECK(device_out == host_out);
86 BOOST_CHECK(ret == device_out.begin() + problem_size);
87}
88
89BOOST_AUTO_TEST_CASE(par_unseq_binary_zero_size) {
90 run_binary_transform_test(0);

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.85

Calls 4

transformFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected