summaryrefslogtreecommitdiff
path: root/modules/remote-sycl/tests/calculator.cpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-06-21 19:44:34 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-06-21 19:44:34 +0200
commit86b06a3fee2cd7635a9ab486e2a35bdf1e81ce38 (patch)
tree5485b323cdce1c1347f1a20c7f33e8f772c73dbf /modules/remote-sycl/tests/calculator.cpp
parent601113a445658d8b15273dd91c66cf20daf50d30 (diff)
Moving forward with basic test for sycl
Diffstat (limited to 'modules/remote-sycl/tests/calculator.cpp')
-rw-r--r--modules/remote-sycl/tests/calculator.cpp69
1 files changed, 0 insertions, 69 deletions
diff --git a/modules/remote-sycl/tests/calculator.cpp b/modules/remote-sycl/tests/calculator.cpp
deleted file mode 100644
index 6d061ad..0000000
--- a/modules/remote-sycl/tests/calculator.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include <forstio/test/suite.hpp>
-
-#include "../c++/remote.hpp"
-
-namespace {
-namespace schema {
-using namespace saw::schema;
-using Calculator = Interface<
- Member<
- Function<Tuple<Int64, Int64>, Int64>, "add"
- >
-, Member<
- Function<Tuple<Int64, Int64>, Int64>, "multiply"
- >
->;
-}
-
-SAW_TEST("Sycl Interface Calculator"){
- using namespace saw;
-
- cl::sycl::queue cmd_queue;
-
- interface<schema::Calculator, encode::Native<storage::Default>, cl::sycl::queue*> cl_iface {
-[](data<schema::Tuple<schema::Int64, schema::Int64>>& in, cl::sycl::queue* cmd) -> data<schema::Int64> {
- std::array<int64_t,2> h_xy{in.get<0>().get(), in.get<1>().get()};
- int64_t res{};
- cl::sycl::buffer<int64_t,1> d_xy { h_xy.data(), h_xy.size() };
- cl::sycl::buffer<int64_t,1> d_z { &res, 1u };
- cmd->submit([&](cl::sycl::handler& h){
- auto a_xy = d_xy.get_access<cl::sycl::access::mode::read>(h);
- auto a_z = d_z.get_access<cl::sycl::access::mode::write>(h);
-
- h.parallel_for(cl::sycl::range<1>(1u), [=] (cl::sycl::id<1> it){
- a_z[0] = a_xy[0] + a_xy[1];
- });
- });
- cmd->wait();
- return data<schema::Int64>{res};
- },
- [](data<schema::Tuple<schema::Int64, schema::Int64>,encode::Native,rmt::Sycl>& in, cl::sycl::queue* cmd) -> data<schema::Int64> {
- return data<schema::Int64>{in.get<0>().get() * in.get<1>().get()};
- }
- };
-
- int64_t x = 1;
- int64_t y = -2;
-
- int64_t sum = x + y;
- int64_t mult = x * y;
-
-
- data<schema::Tuple<schema::Int64, schema::Int64>> input;
- input.template get<0>().set(x);
- input.template get<1>().set(y);
-
- {
- auto eov = cl_iface.template call<"add">(input, &cmd_queue);
- SAW_EXPECT(eov.is_value(), "Returned error on add");
-
- SAW_EXPECT(eov.get_value().get() == sum, "Addition was incorrect");
- }
- {
- auto eov = cl_iface.template call<"multiply">(input, &cmd_queue);
- SAW_EXPECT(eov.is_value(), "Returned error on add");
-
- SAW_EXPECT(eov.get_value().get() == mult, "Addition was incorrect");
- }
-}
-}