From 36de95682200f3d1404951900b7d7089fefc62cc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 21 Nov 2025 20:47:10 +0100 Subject: Reworking sycl --- modules/remote-sycl/benchmarks/mixed_precision.cpp | 2 +- .../benchmarks/mixed_precision_alternative.cpp | 58 ++++++++++++++++------ modules/remote-sycl/tests/remote.cpp | 20 ++++++++ 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 modules/remote-sycl/tests/remote.cpp diff --git a/modules/remote-sycl/benchmarks/mixed_precision.cpp b/modules/remote-sycl/benchmarks/mixed_precision.cpp index aabe949..b4ba965 100644 --- a/modules/remote-sycl/benchmarks/mixed_precision.cpp +++ b/modules/remote-sycl/benchmarks/mixed_precision.cpp @@ -110,7 +110,7 @@ int main(int argc, char** argv){ std::cout<<"Warming up ..."< + namespace sch { using namespace saw::schema; } template void inner_work(){ - acpp::sycl::queue sycl_q; - - constexpr uint64_t dat_size = 10000u; - - data, encode::Sycl> dat{{{dat_size}},sycl_q}; - data>, encode::Sycl> dat_ref{dat}; - auto dat_ptr = dat_ref.get_internal_data(); + std::random_device r; + std::default_random_engine e1{r()}; + std::uniform_real_distribution<> dis{-3.0,-1.0}; - sycl_q.parallel_for(dat_size, [=](acpp::sycl::id<1> idx){ - size_t i = idx[0]; - - dat_ptr[i] = {i}; - }).wait(); - - for(uint64_t i = 0u; i < dat_size; ++i){ - SAW_EXPECT(dat_ptr[i].get() == i, std::string{"Unexpected value: "} + std::to_string(i)); + acpp::sycl::queue sycl_q; + acpp::sycl::event ev; + + auto time_eval = [](uint64_t & current_min_time, acpp::sycl::event& evt){ + auto end = evt.get_profiling_info(); + auto start = evt.get_profiling_info(); + + uint64_t curr_time = (end-start); + current_min_time = std::min(curr_time, current_min_time); + }; + + constexpr uint64_t arithmetic_intensity = 1024ul; + + /** + * Warmup + */ + std::cout<<"Warming up ..."<, encode::Sycl> dat{{{test_size}},sycl_q}; + data>, encode::Sycl> dat_ref{dat}; + auto dat_ptr = dat_ref.get_internal_data(); + + for(uint64_t i = 0; i < test_size; ++i){ + double gen_num = dis(e1); + dat.at({{i}}) = {static_cast(gen_num)}; + } + + sycl_q.parallel_for([=](acpp::sycl::id<1> idx){ + data foo = {dat_ptr[idx[0u]].get()}; + for(uint64_t i = 0; i < arithmetic_intensity; ++i){ + if( foo.get() == 1.1e12 ){ + dat_ptr[idx[0u]] = {}; + } + foo = foo + foo * saw::data{1.7342345}; + } + dat_ptr[idx[0u]] = foo; + }).wait(); } - } int main(){ diff --git a/modules/remote-sycl/tests/remote.cpp b/modules/remote-sycl/tests/remote.cpp new file mode 100644 index 0000000..4315e69 --- /dev/null +++ b/modules/remote-sycl/tests/remote.cpp @@ -0,0 +1,20 @@ +#include + +#include "../c++/remote.hpp" + +namespace { +namespace sch { +using namespace saw::schema; +} + +SAW_TEST("Remote Basics"){ + using namespace saw; + + remote sycl_rmt; + + auto eo_sycl_addr = sycl_rmt.parse_address(); + SAW_EXPECT(eo_sycl_addr.is_value(),"Couldn't parse address"); + auto& sycl_addr = eo_sycl_addr.get_value(); + +} +} -- cgit v1.2.3