diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-11-18 22:46:33 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2025-11-18 22:46:33 +0100 |
| commit | b514d9e6dfceafb83cebcbb0c7ef4728b2ff0401 (patch) | |
| tree | 91d30ce7b87a10278d747f2cc9ea8a8cb8d9d3a8 /modules/remote-sycl/benchmarks | |
| parent | 2073aef795f74e5c24b7992d6c2f0fadde3fa271 (diff) | |
| download | forstio-forstio-b514d9e6dfceafb83cebcbb0c7ef4728b2ff0401.tar.gz | |
Sycl mixed precision prep
Diffstat (limited to 'modules/remote-sycl/benchmarks')
| -rw-r--r-- | modules/remote-sycl/benchmarks/SConscript | 7 | ||||
| -rw-r--r-- | modules/remote-sycl/benchmarks/mixed_precision_alternative.cpp | 35 |
2 files changed, 41 insertions, 1 deletions
diff --git a/modules/remote-sycl/benchmarks/SConscript b/modules/remote-sycl/benchmarks/SConscript index 434993c..e88c1bd 100644 --- a/modules/remote-sycl/benchmarks/SConscript +++ b/modules/remote-sycl/benchmarks/SConscript @@ -28,8 +28,13 @@ benchmarks_sycl_env.add_source_files(sycl_objects, ['kernel_mixed_precision.cpp' objects_static = [] benchmarks_env.sycl_basic = benchmarks_env.Program('#bin/benchmark_mixed_precision', ['mixed_precision.cpp', env.library_static, sycl_objects]); +benchmarks_env.mixed_alt = benchmarks_sycl_env.Program('#bin/benchmark_mixed_precision_alternative', ['mixed_precision_alternative.cpp', env.library_static]); + # Set Alias -env.benchmarks = [benchmarks_env.sycl_basic]; +env.benchmarks = [ + benchmarks_env.sycl_basic, + benchmarks_env.mixed_alt +]; env.Alias('benchmarks', env.benchmarks); if env["build_benchmarks"]: diff --git a/modules/remote-sycl/benchmarks/mixed_precision_alternative.cpp b/modules/remote-sycl/benchmarks/mixed_precision_alternative.cpp new file mode 100644 index 0000000..e1a1e90 --- /dev/null +++ b/modules/remote-sycl/benchmarks/mixed_precision_alternative.cpp @@ -0,0 +1,35 @@ +#include "../c++/data.hpp" + +namespace sch { +using namespace saw::schema; +} + +template<typename T> +void inner_work(){ + acpp::sycl::queue sycl_q; + + constexpr uint64_t dat_size = 10000u; + + data<sch::Array<T>, encode::Sycl<encode::Native>> dat{{{dat_size}},sycl_q}; + data<sch::Ref<sch::Array<T>>, encode::Sycl<encode::Native>> dat_ref{dat}; + auto dat_ptr = dat_ref.get_internal_data(); + + 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)); + } + +} + +int main(){ + using namespace saw; + inner_work<sch::Float32>(); + inner_work<sch::Float64>(); + inner_work<sch::MixedPrecision<sch::Float64,sch::Float32>>(); + return 0; +} |
