From dee0184f2bedfb3919309c9f372bd0cdec520e9d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 17 Jun 2024 14:33:26 +0200 Subject: Trying to fix the whole data transport description --- modules/remote-sycl/c++/remote.hpp | 93 ++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 29 deletions(-) (limited to 'modules/remote-sycl/c++/remote.hpp') diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index 4510237..4a383d1 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -20,7 +20,13 @@ class remote; template class remote_data { private: + /** + * Id representing the remote data + */ id id_; + /** + * Storage for the + */ id_map* map_; public: /** @@ -84,7 +90,6 @@ public: using Schema = schema::Array; private: uint64_t total_length_; - // typename native_data_type::type* device_data_; data* device_data_; cl::sycl::queue* queue_; @@ -94,7 +99,6 @@ public: data(uint64_t size, cl::sycl::queue& q__): total_length_{size}, device_data_{cl::sycl::malloc_device>(size, q__)}, - //device_data_{cl::sycl::malloc_device::type>(size, q__)}, queue_{&q__} { if(!device_data_){ @@ -108,7 +112,6 @@ public: data(const data& from, cl::sycl::queue& q__): total_length_{from.size()}, device_data_{cl::sycl::malloc_device>(from.size(), q__)}, - //device_data_{cl::sycl::malloc_device::type>(from.size(), q__)}, queue_{&q__} { if(!device_data_){ @@ -137,17 +140,6 @@ public: queue_->template copy>(from.device_data_, device_data_, total_length_); } - data& operator=(const data& rhs) { - total_length_ = rhs.total_length_; - device_data_ = cl::sycl::malloc_device>(rhs.size(), *rhs.queue_); - // device_data_ = cl::sycl::malloc_device::type>(rhs.size(), *rhs.queue_); - if(!device_data_){ - total_length_ = 0u; - } - queue_ = rhs.queue_; - return *this; - } - data(data&& rhs): total_length_{rhs.total_length_}, device_data_{rhs.device_data_}, @@ -190,7 +182,6 @@ public: } data& at(uint64_t i){ - //typename native_data_type::type& at(uint64_t i){ return device_data_[i]; } @@ -211,6 +202,42 @@ struct rpc_id_map_helper, Encoding, Storage> { }; } +template +class device; + +/** + * Represents a remote Sycl device. + * + */ +template<> +class device { +private: + cl::sycl::queue cmd_queue_; +public: + /** + * Copy data to device + */ + template + error_or> copy_to_device(const data>& host_data){ + (void) host_data; + return make_error(); + } + + /** + * Copy data to host + */ + template + error_or> copy_to_host(const data>& device_data){ + (void) device_data; + return make_error(); + } +}; + +/** + * Device data transport + */ + + /** * Rpc Client class for the Sycl backend. */ @@ -256,9 +283,9 @@ public: using InterfaceT = interface; private: /** - * Command queue for the sycl backend + * Device instance enabling the use of the remote device. */ - cl::sycl::queue cmd_queue_; + device* device_; /** * The interface including the relevant context class. @@ -270,26 +297,27 @@ private: */ impl::rpc_id_map_helper storage_; public: - /** - * Ask which id the server prefers as the next one. Only available for fast requests on no roundtrip setups. - */ - template - id next_free_id() const { - return std::get>(storage_.maps).next_free_id(); - } /** * Main constructor */ - rpc_server(interface cl_iface): - cmd_queue_{}, + rpc_server(device& dev__, interface cl_iface): + device_{&dev__}, cl_interface_{std::move(cl_iface)}, storage_{} {} + + /** + * Ask which id the server prefers as the next one. Only available for fast requests on no roundtrip setups. + */ + template + id next_free_id() const { + return std::get>(storage_.maps).next_free_id(); + } template remote_data request_data(id dat_id){ - return {dat_id, std::get>(storage_.maps), cmd_queue_}; + return {dat_id, std::get>(storage_.maps), device_.cmd_queue_}; } /** @@ -385,14 +413,21 @@ public: return heap>(*this); } + /** + * Connect to a device + */ + device connect_device(const remote_address&){ + return {}; + } + /** * Spin up a rpc server */ template - rpc_server listen(const remote_address&, typename rpc_server::InterfaceT iface){ + rpc_server listen(const device& dev, typename rpc_server::InterfaceT iface){ using RpcServerT = rpc_server; using InterfaceT = typename RpcServerT::InterfaceT; - return {std::move(iface)}; + return {dev, std::move(iface)}; } }; -- cgit v1.2.3