From cace251b73a2902fbdade9e8cd7ae0f52f0e18e1 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 24 Jun 2024 15:23:08 +0200 Subject: Slowly adding pure data transfer classes --- modules/remote-sycl/.nix/derivation.nix | 5 +- modules/remote-sycl/c++/common.hpp | 11 +++ modules/remote-sycl/c++/remote.hpp | 8 --- modules/remote-sycl/c++/transfer.hpp | 81 ++++++++++++++++++++++ modules/remote-sycl/examples/sycl_basic_kernel.cpp | 1 - modules/remote-sycl/tests/SConscript | 2 +- 6 files changed, 96 insertions(+), 12 deletions(-) create mode 100644 modules/remote-sycl/c++/transfer.hpp diff --git a/modules/remote-sycl/.nix/derivation.nix b/modules/remote-sycl/.nix/derivation.nix index 2247ec0..71c5dff 100644 --- a/modules/remote-sycl/.nix/derivation.nix +++ b/modules/remote-sycl/.nix/derivation.nix @@ -48,9 +48,10 @@ in stdenv.mkDerivation { installPhase = '' scons prefix=$out build_examples=${build_examples} install ''; - + doCheck = true; - checkPhase = '' + checkPhase = '' + export ACPP_APPDB_DIR=. scons test ./bin/tests ''; diff --git a/modules/remote-sycl/c++/common.hpp b/modules/remote-sycl/c++/common.hpp index c1f9ddf..9bc734d 100644 --- a/modules/remote-sycl/c++/common.hpp +++ b/modules/remote-sycl/c++/common.hpp @@ -11,4 +11,15 @@ namespace rmt { struct Sycl {}; } +template<> +class remote; + +template +class device; + +template +class data_server; + +template +class data_client; } diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index 24756be..2d0eaea 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -5,12 +5,6 @@ namespace saw { -template<> -class remote; - -template -class device; - template class data { private: @@ -334,7 +328,6 @@ public: } }; - template<> struct remote_address { private: @@ -353,7 +346,6 @@ class remote { private: SAW_FORBID_COPY(remote); SAW_FORBID_MOVE(remote); - public: /** * Default constructor diff --git a/modules/remote-sycl/c++/transfer.hpp b/modules/remote-sycl/c++/transfer.hpp new file mode 100644 index 0000000..6849caa --- /dev/null +++ b/modules/remote-sycl/c++/transfer.hpp @@ -0,0 +1,81 @@ +#pragma once + +#include "common.hpp" +#include "data.hpp" +#include + +namespace saw { +template +class data_server { +private: + /** + * Device context class + */ + device* device_; + + /** + * Store for the data the server manages. + */ + std::unordered_map> values_; +public: + /** + * Main constructor + */ + data_server(device& device__): + device_{&device__} + {} + + /** + * Receive data which we will store. + */ + error_or send(const data& dat, id store_id){ + auto eoval = device_->copy_to_device(dat); + if(eoval.is_error()){ + auto& err = eoval.get_error(); + return std::move(err); + } + return make_error(); + } + + error_or> receive(id store_id){ + return make_error(); + } +}; + +template +class data_client { +private: + /** + * Corresponding server for this client + */ + data_server* srv_; + + /** + * The next id for identifying issues on the remote side. + */ + uint64_t next_id_; +public: + /** + * Main constructor + */ + data_client(data_server& srv__): + srv_{&srv__}, + next_id_{0u} + {} + + /** + * Send data to. + */ + error_or> send(const data& dat){ + id dat_id{next_id_}; + auto eov = srv_->send(dat, dat_id); + if(eov.is_error()){ + auto& err = eov.get_error(); + return std::move(err); + } + + ++next_id_; + return dat_id; + } +}; +} diff --git a/modules/remote-sycl/examples/sycl_basic_kernel.cpp b/modules/remote-sycl/examples/sycl_basic_kernel.cpp index f9a838e..763e733 100644 --- a/modules/remote-sycl/examples/sycl_basic_kernel.cpp +++ b/modules/remote-sycl/examples/sycl_basic_kernel.cpp @@ -8,7 +8,6 @@ saw::rpc_server lis [](saw::data, saw::encode::Native, saw::rmt::Sycl>& in, cl::sycl::queue* q) -> saw::error_or { q->submit([&](cl::sycl::handler& h){ - h.single_task([&] (){ in.at(0u).set(in.at(0u).get() + 1u); }); diff --git a/modules/remote-sycl/tests/SConscript b/modules/remote-sycl/tests/SConscript index 3a9a2cf..f56f0bd 100644 --- a/modules/remote-sycl/tests/SConscript +++ b/modules/remote-sycl/tests/SConscript @@ -12,7 +12,7 @@ dir_path = Dir('.').abspath # Environment for base library test_cases_env = env.Clone(); -test_cases_env['CXX'] = 'syclcc'; +test_cases_env['CXX'] = 'acpp'; test_cases_env.Append(LIBS=['forstio-test']); -- cgit v1.2.3