diff options
Diffstat (limited to 'modules/remote-sycl/c++/remote.hpp')
-rw-r--r-- | modules/remote-sycl/c++/remote.hpp | 71 |
1 files changed, 35 insertions, 36 deletions
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<rmt::Sycl>; template<typename T> class device; +template<typename Schema> +class data<Schema, encode::Native, rmt::Sycl> { +private: + cl::sycl::buffer<data<Schema, encode::Native, storage::Default>> data_; +public: + data(data<Schema, encode::Native, storage::Default>& data__): + data_{&data__, 1u} + {} + + auto& get_handle() { + return data_; + } + + template<cl::sycl::access::mode AccessMode> + auto access(cl::sycl::handler& h){ + return data_.template get_access<AccessMode>(h); + } +}; + /** * Remote data class for the Sycl backend. */ template<typename T, typename Encoding, typename Storage> -class remote_data<T, Encoding, Storage, rmt::Sycl> { +class remote_data<T, Encoding, Storage, rmt::Sycl> final { private: /** * An identifier to the data being held on the remote @@ -30,20 +49,15 @@ public: /** * Main constructor */ - remote_data(data<T,Encoding,Storage>& remote_data__, cl::sycl::queue& queue__): - remote_data_{&remote_data__}, + remote_data(id<T> 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<Schema,Encoding,Storage>* device_data_; + data<Schema,Encoding,storage::Default>* device_data_; /** * The sycl queue object */ @@ -91,7 +105,7 @@ public: /** * Main constructor */ - device_data(data<Schema,Encoding,Storage>& device_data__, cl::sycl::queue& queue__): + device_data(data<Schema,Encoding,storage::Default>& device_data__, cl::sycl::queue& queue__): device_data_{&device_data__}, queue_{&queue__} {} @@ -111,6 +125,11 @@ public: }; namespace impl { +template<typename Schema, typename Encoding, typename Backend> +struct device_id_map { + std::vector<device_data<Schema, Encoding, Backend>> data; +}; + template<typename Iface, typename Encoding, typename Storage> struct rpc_id_map_helper { static_assert(always_false<Iface, Encoding,Storage>, "Only supports Interface schema types."); @@ -122,9 +141,12 @@ struct rpc_id_map_helper<schema::Interface<Members...>, Encoding, Storage> { }; } +} +// Maybe a helper impl tmpl file? +namespace saw { + /** * Represents a remote Sycl device. - * */ template<> class device<rmt::Sycl> final { @@ -161,11 +183,6 @@ public: }; /** - * Device data transport - */ - - -/** * Rpc Client class for the Sycl backend. */ template<typename Iface, typename Encoding, typename Storage> @@ -222,7 +239,7 @@ private: /** * Basic storage for response data. */ - // impl::rpc_id_map_helper<Iface, Encoding, rmt::Sycl> storage_; + impl::rpc_id_map_helper<Iface, Encoding, rmt::Sycl> storage_; public: /** @@ -369,22 +386,4 @@ public: } }; -template<typename T, uint64_t D> -template<typename Storage> -error_or<data<schema::Array<T,D>, encode::Native, rmt::Sycl>> data<schema::Array<T,D>, encode::Native, rmt::Sycl>::copy_to_device(const data<schema::Array<T,D>, encode::Native, Storage>& host_data, device<rmt::Sycl>& dev){ - /** - * Retrieve handle - */ - auto& cmd_handle = dev.get_handle(); - - uint64_t* dev_len = cl::sycl::malloc_device<uint64_t>(1u, cmd_handle); - uint64_t len = host_data.size(); - cmd_handle.template copy<uint64_t>(&len,dev_len, 1u); - - auto dev_dat = cl::sycl::malloc_device<data<T,encode::Native,storage::Default>>(host_data.size(), cmd_handle); - cmd_handle.copy(&host_data.at(0), dev_dat, host_data.size()); - cmd_handle.wait(); - - return data<schema::Array<T,D>,encode::Native, rmt::Sycl>{dev_len, dev_dat, cmd_handle}; -} } |