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/c++/common.hpp | 11 +++++ modules/remote-sycl/c++/remote.hpp | 8 ---- modules/remote-sycl/c++/transfer.hpp | 81 ++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 modules/remote-sycl/c++/transfer.hpp (limited to 'modules/remote-sycl/c++') 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; + } +}; +} -- cgit v1.2.3