diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-06-17 14:33:26 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-06-17 14:33:26 +0200 |
commit | dee0184f2bedfb3919309c9f372bd0cdec520e9d (patch) | |
tree | 4ab795a9e265430757c1919f0ef304522f236d55 /modules/remote-sycl | |
parent | 5329652f839b99b95d63cd471ff73d251f74d911 (diff) |
Trying to fix the whole data transport description
Diffstat (limited to 'modules/remote-sycl')
-rw-r--r-- | modules/remote-sycl/c++/remote.hpp | 93 |
1 files changed, 64 insertions, 29 deletions
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<rmt::Sycl>; template<typename T, typename Encoding, typename Storage> class remote_data<T, Encoding, Storage, rmt::Sycl> { private: + /** + * Id representing the remote data + */ id<T> id_; + /** + * Storage for the + */ id_map<T,Encoding,rmt::Sycl>* map_; public: /** @@ -84,7 +90,6 @@ public: using Schema = schema::Array<T,D>; private: uint64_t total_length_; - // typename native_data_type<T>::type* device_data_; data<T,encode::Native,storage::Default>* 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<data<T,encode::Native,storage::Default>>(size, q__)}, - //device_data_{cl::sycl::malloc_device<typename native_data_type<T>::type>(size, q__)}, queue_{&q__} { if(!device_data_){ @@ -108,7 +112,6 @@ public: data(const data<Schema, Encoding, Storage>& from, cl::sycl::queue& q__): total_length_{from.size()}, device_data_{cl::sycl::malloc_device<data<T,encode::Native,storage::Default>>(from.size(), q__)}, - //device_data_{cl::sycl::malloc_device<typename native_data_type<T>::type>(from.size(), q__)}, queue_{&q__} { if(!device_data_){ @@ -137,17 +140,6 @@ public: queue_->template copy<data<T,encode::Native,storage::Default>>(from.device_data_, device_data_, total_length_); } - data<Schema, encode::Native, rmt::Sycl>& operator=(const data<Schema, encode::Native, rmt::Sycl>& rhs) { - total_length_ = rhs.total_length_; - device_data_ = cl::sycl::malloc_device<data<T,encode::Native,storage::Default>>(rhs.size(), *rhs.queue_); - // device_data_ = cl::sycl::malloc_device<typename native_data_type<T>::type>(rhs.size(), *rhs.queue_); - if(!device_data_){ - total_length_ = 0u; - } - queue_ = rhs.queue_; - return *this; - } - data(data<Schema, encode::Native, rmt::Sycl>&& rhs): total_length_{rhs.total_length_}, device_data_{rhs.device_data_}, @@ -190,7 +182,6 @@ public: } data<T, encode::Native, storage::Default>& at(uint64_t i){ - //typename native_data_type<T>::type& at(uint64_t i){ return device_data_[i]; } @@ -211,6 +202,42 @@ struct rpc_id_map_helper<schema::Interface<Members...>, Encoding, Storage> { }; } +template<typename T> +class device; + +/** + * Represents a remote Sycl device. + * + */ +template<> +class device<rmt::Sycl> { +private: + cl::sycl::queue cmd_queue_; +public: + /** + * Copy data to device + */ + template<typename Schema, typename Encoding, typename Storage, typename EncodingHost, typename StorageHost> + error_or<data<Schema, Encoding, Storage>> copy_to_device(const data<Schema, EncodingHost, StorageHost>>& host_data){ + (void) host_data; + return make_error<err::not_implemented>(); + } + + /** + * Copy data to host + */ + template<typename Schema, typename Encoding, typename Storage, typename EncodingDevice, typename StorageDevice> + error_or<data<Schema, Encoding, Storage>> copy_to_host(const data<Schema, EncodingDevice, StorageDevice>>& device_data){ + (void) device_data; + return make_error<err::not_implemented>(); + } +}; + +/** + * Device data transport + */ + + /** * Rpc Client class for the Sycl backend. */ @@ -256,9 +283,9 @@ public: using InterfaceT = interface<Iface, Encoding, rmt::Sycl, InterfaceCtxT>; private: /** - * Command queue for the sycl backend + * Device instance enabling the use of the remote device. */ - cl::sycl::queue cmd_queue_; + device<rmt::Sycl>* device_; /** * The interface including the relevant context class. @@ -270,26 +297,27 @@ private: */ impl::rpc_id_map_helper<Iface, Encoding, rmt::Sycl> storage_; public: - /** - * Ask which id the server prefers as the next one. Only available for fast requests on no roundtrip setups. - */ - template<typename T> - id<T> next_free_id() const { - return std::get<id_map<T,Encoding,rmt::Sycl>>(storage_.maps).next_free_id(); - } /** * Main constructor */ - rpc_server(interface<Iface, Encoding, rmt::Sycl, InterfaceCtxT> cl_iface): - cmd_queue_{}, + rpc_server(device<rmt::Sycl>& dev__, interface<Iface, Encoding, rmt::Sycl, InterfaceCtxT> 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<typename T> + id<T> next_free_id() const { + return std::get<id_map<T,Encoding,rmt::Sycl>>(storage_.maps).next_free_id(); + } template<typename IdT, typename Storage> remote_data<IdT, Encoding, Storage, rmt::Sycl> request_data(id<IdT> dat_id){ - return {dat_id, std::get<id_map<IdT,Encoding,rmt::Sycl>>(storage_.maps), cmd_queue_}; + return {dat_id, std::get<id_map<IdT,Encoding,rmt::Sycl>>(storage_.maps), device_.cmd_queue_}; } /** @@ -386,13 +414,20 @@ public: } /** + * Connect to a device + */ + device<rmt::Sycl> connect_device(const remote_address<rmt::Sycl>&){ + return {}; + } + + /** * Spin up a rpc server */ template<typename Iface, typename Encoding> - rpc_server<Iface, Encoding, rmt::Sycl> listen(const remote_address<rmt::Sycl>&, typename rpc_server<Iface, Encoding, rmt::Sycl>::InterfaceT iface){ + rpc_server<Iface, Encoding, rmt::Sycl> listen(const device<rmt::Sycl>& dev, typename rpc_server<Iface, Encoding, rmt::Sycl>::InterfaceT iface){ using RpcServerT = rpc_server<Iface, Encoding, rmt::Sycl>; using InterfaceT = typename RpcServerT::InterfaceT; - return {std::move(iface)}; + return {dev, std::move(iface)}; } }; |