#include #include "../c++/remote.hpp" #include namespace { namespace schema { using namespace saw::schema; using TestMixedArray = Array< MixedPrecision >; using MixedFoo = Interface< Member, "foo"> >; using TestDoubleArray = Array< Float64 >; using DoubleFoo = Interface< Member, "foo"> >; using TestFloatArray = Array< Float32 >; using FloatFoo = Interface< Member, "foo"> >; } constexpr uint64_t test_size = 1024ul; SAW_TEST("SYCL Mixed Test"){ using namespace saw; std::random_device r; std::default_random_engine e1{r()}; std::uniform_real_distribution<> dis{-1.0,1.0}; data host_data; host_data = {test_size}; for(uint64_t i = 0; i < test_size; ++i){ host_data.at(i) = static_cast(dis(e1)); } saw::event_loop loop; saw::wait_scope wait{loop}; remote rmt; own> rmt_addr{}; rmt.resolve_address().then([&](auto addr){ rmt_addr = std::move(addr); }).detach(); wait.poll(); SAW_EXPECT(rmt_addr, "Remote address hasn't been filled"); data device_data{host_data}; cl::sycl::event ev; interface cl_iface { [&](data& in, cl::sycl::queue* cmd) -> error_or { ev = cmd->submit([&](cl::sycl::handler& h){ auto acc_buff = in.template access(h); h.parallel_for(cl::sycl::range<1>(test_size), [=] (cl::sycl::id<1> it){ acc_buff[0u].at(it[0u]) = acc_buff[0u].at(it[0u]) * data{2.0}; }); }); return saw::void_t{}; } }; auto& device = rmt_addr->get_device(); cl_iface.template call <"foo">(device_data, &(device.get_handle())); device.get_handle().wait(); { auto end = ev.get_profiling_info(); auto start = ev.get_profiling_info(); std::cout<<"Elapsed kernel time: "<< (end-start) / 1.0e9 << " seconds"< dis{-1.0,1.0}; data host_data; host_data = {test_size}; for(uint64_t i = 0; i < test_size; ++i){ host_data.at(i) = static_cast(dis(e1)); } saw::event_loop loop; saw::wait_scope wait{loop}; remote rmt; own> rmt_addr{}; rmt.resolve_address().then([&](auto addr){ rmt_addr = std::move(addr); }).detach(); wait.poll(); SAW_EXPECT(rmt_addr, "Remote address hasn't been filled"); data device_data{host_data}; cl::sycl::event ev; interface cl_iface { [&](data& in, cl::sycl::queue* cmd) -> error_or { ev = cmd->submit([&](cl::sycl::handler& h){ auto acc_buff = in.template access(h); h.parallel_for(cl::sycl::range<1>(test_size), [=] (cl::sycl::id<1> it){ acc_buff[0u].at(it[0u]) = acc_buff[0u].at(it[0u]) * data{2.0}; }); }); return saw::void_t{}; } }; auto& device = rmt_addr->get_device(); cl_iface.template call <"foo">(device_data, &(device.get_handle())); device.get_handle().wait(); { auto end = ev.get_profiling_info(); auto start = ev.get_profiling_info(); std::cout<<"Elapsed kernel time: "<< (end-start) / 1.0e9 << " seconds"< dis{-1.0,1.0}; data host_data; host_data = {test_size}; for(uint64_t i = 0; i < test_size; ++i){ host_data.at(i) = static_cast(dis(e1)); } saw::event_loop loop; saw::wait_scope wait{loop}; remote rmt; own> rmt_addr{}; rmt.resolve_address().then([&](auto addr){ rmt_addr = std::move(addr); }).detach(); wait.poll(); SAW_EXPECT(rmt_addr, "Remote address hasn't been filled"); data device_data{host_data}; cl::sycl::event ev; interface cl_iface { [&](data& in, cl::sycl::queue* cmd) -> error_or { ev = cmd->submit([&](cl::sycl::handler& h){ auto acc_buff = in.template access(h); h.parallel_for(cl::sycl::range<1>(test_size), [=] (cl::sycl::id<1> it){ acc_buff[0u].at(it[0u]) = acc_buff[0u].at(it[0u]) * data{2.0}; }); }); return saw::void_t{}; } }; auto& device = rmt_addr->get_device(); cl_iface.template call <"foo">(device_data, &(device.get_handle())); device.get_handle().wait(); { auto end = ev.get_profiling_info(); auto start = ev.get_profiling_info(); std::cout<<"Elapsed kernel time: "<< (end-start) / 1.0e9 << " seconds"<