From 86b06a3fee2cd7635a9ab486e2a35bdf1e81ce38 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 21 Jun 2024 19:44:34 +0200 Subject: Moving forward with basic test for sycl --- modules/remote-sycl/c++/remote.hpp | 71 +++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 36 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 54b7a7b..24756be 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -11,11 +11,30 @@ class remote; template class device; +template +class data { +private: + cl::sycl::buffer> data_; +public: + data(data& data__): + data_{&data__, 1u} + {} + + auto& get_handle() { + return data_; + } + + template + auto access(cl::sycl::handler& h){ + return data_.template get_access(h); + } +}; + /** * Remote data class for the Sycl backend. */ template -class remote_data { +class remote_data final { private: /** * An identifier to the data being held on the remote @@ -30,20 +49,15 @@ public: /** * Main constructor */ - remote_data(data& remote_data__, cl::sycl::queue& queue__): - remote_data_{&remote_data__}, + remote_data(id data_id__, cl::sycl::queue& queue__): + data_id_{data_id__}, queue_{&queue__} {} /** * Destructor specifically designed to deallocate on the device. */ - ~remote_data(){ - if(remote_data_){ - cl::sycl::free(remote_data_,queue_); - remote_data_ = nullptr; - } - } + ~remote_data(){} SAW_FORBID_COPY(remote_data); SAW_FORBID_MOVE(remote_data); @@ -82,7 +96,7 @@ private: /** * The actual data */ - data* device_data_; + data* device_data_; /** * The sycl queue object */ @@ -91,7 +105,7 @@ public: /** * Main constructor */ - device_data(data& device_data__, cl::sycl::queue& queue__): + device_data(data& device_data__, cl::sycl::queue& queue__): device_data_{&device_data__}, queue_{&queue__} {} @@ -111,6 +125,11 @@ public: }; namespace impl { +template +struct device_id_map { + std::vector> data; +}; + template struct rpc_id_map_helper { static_assert(always_false, "Only supports Interface schema types."); @@ -122,9 +141,12 @@ struct rpc_id_map_helper, Encoding, Storage> { }; } +} +// Maybe a helper impl tmpl file? +namespace saw { + /** * Represents a remote Sycl device. - * */ template<> class device final { @@ -160,11 +182,6 @@ public: } }; -/** - * Device data transport - */ - - /** * Rpc Client class for the Sycl backend. */ @@ -222,7 +239,7 @@ private: /** * Basic storage for response data. */ - // impl::rpc_id_map_helper storage_; + impl::rpc_id_map_helper storage_; public: /** @@ -369,22 +386,4 @@ public: } }; -template -template -error_or, encode::Native, rmt::Sycl>> data, encode::Native, rmt::Sycl>::copy_to_device(const data, encode::Native, Storage>& host_data, device& dev){ - /** - * Retrieve handle - */ - auto& cmd_handle = dev.get_handle(); - - uint64_t* dev_len = cl::sycl::malloc_device(1u, cmd_handle); - uint64_t len = host_data.size(); - cmd_handle.template copy(&len,dev_len, 1u); - - auto dev_dat = cl::sycl::malloc_device>(host_data.size(), cmd_handle); - cmd_handle.copy(&host_data.at(0), dev_dat, host_data.size()); - cmd_handle.wait(); - - return data,encode::Native, rmt::Sycl>{dev_len, dev_dat, cmd_handle}; -} } -- cgit v1.2.3