Commit e131179f authored by Joseph Noir's avatar Joseph Noir

the opencl test now cover all spawn_cl variants

parent b194482d
...@@ -23,7 +23,6 @@ constexpr const char* kernel_name = "matrix_square"; ...@@ -23,7 +23,6 @@ constexpr const char* kernel_name = "matrix_square";
constexpr const char* kernel_source = R"__( constexpr const char* kernel_source = R"__(
__kernel void matrix_square(__global int* matrix, __kernel void matrix_square(__global int* matrix,
__global int* output) { __global int* output) {
// we only use square matrices, hence: width == height
size_t size = get_global_size(0); // == get_global_size_(1); size_t size = get_global_size(0); // == get_global_size_(1);
size_t x = get_global_id(0); size_t x = get_global_id(0);
size_t y = get_global_id(1); size_t y = get_global_id(1);
...@@ -107,6 +106,7 @@ int main() { ...@@ -107,6 +106,7 @@ int main() {
,152,174,196,218 ,152,174,196,218
,248,286,324,362 ,248,286,324,362
,344,398,452,506}; ,344,398,452,506};
auto worker1 = spawn_cl<ivec(ivec&)>(program::create(kernel_source), auto worker1 = spawn_cl<ivec(ivec&)>(program::create(kernel_source),
kernel_name, kernel_name,
{matrix_size,matrix_size}); {matrix_size,matrix_size});
...@@ -119,25 +119,52 @@ int main() { ...@@ -119,25 +119,52 @@ int main() {
} }
); );
CPPA_CHECKPOINT(); auto worker2 = spawn_cl<ivec(ivec&)>(kernel_source,
kernel_name,
{matrix_size,matrix_size});
ivec m2(matrix_size * matrix_size);
iota(m2.begin(), m2.end(), 0);
send(worker2, move(m2));
receive (
on_arg_match >> [&] (const ivec& result) {
CPPA_CHECK(equal(begin(expected1), end(expected1), begin(result)));
}
);
const matrix_type expected2(move(expected1)); const matrix_type expected2(move(expected1));
matrix_type m2;
m2.iota_fill(); auto map_args = [] (any_tuple msg) -> option<cow_tuple<ivec>> {
auto worker2 = spawn_cl(kernel_source, kernel_name, auto opt = tuple_cast<matrix_type>(msg);
[] (any_tuple msg) -> option<cow_tuple<ivec>> { if (opt) {
auto opt = tuple_cast<matrix_type>(msg); return {move(get_ref<0>(*opt).data())};
if (opt) { }
return {move(get_ref<0>(*opt).data())}; return {};
} };
return {};
}, auto map_results = [] (ivec& result) -> any_tuple {
[] (ivec& result) -> any_tuple { return make_any_tuple(matrix_type{move(result)});
return make_any_tuple(matrix_type{move(result)}); };
},
{matrix_size, matrix_size} matrix_type m3;
m3.iota_fill();
auto worker3 = spawn_cl(program::create(kernel_source), kernel_name,
map_args, map_results,
{matrix_size, matrix_size});
send(worker3, move(m3));
receive (
on_arg_match >> [&] (const matrix_type& result) {
CPPA_CHECK(expected2 == result);
}
); );
send(worker2, move(m2));
matrix_type m4;
m4.iota_fill();
auto worker4 = spawn_cl(kernel_source, kernel_name,
map_args, map_results,
{matrix_size, matrix_size}
);
send(worker4, move(m4));
receive ( receive (
on_arg_match >> [&] (const matrix_type& result) { on_arg_match >> [&] (const matrix_type& result) {
CPPA_CHECK(expected2 == result); CPPA_CHECK(expected2 == result);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment