From 5329652f839b99b95d63cd471ff73d251f74d911 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 14 Jun 2024 14:33:22 +0200 Subject: Fixed calc of sycl vals --- modules/remote-sycl/c++/remote.hpp | 47 ++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'modules/remote-sycl/c++') diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index bcc8a3c..4510237 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -22,22 +22,34 @@ class remote_data { private: id id_; id_map* map_; - cl::sycl::queue* queue_; public: /** * Main constructor */ remote_data(const id& id, id_map& map, cl::sycl::queue& queue__): id_{id}, - map_{&map}, - queue_{&queue__} + map_{&map} {} /** * Wait for the data */ error_or> wait(){ + auto eov = map_->find(id_); + if(eov.is_error()){ + auto& err = eov.get_error(); + return std::move(err); + } + auto& val = eov.get_value(); + std::cout<<"Values Sycl in Map: "<size()<template copy_to_host(); + if(eocop.is_error()){ + return eocop; + } + return eocop.get_value(); + } } /** @@ -87,7 +99,9 @@ public: { if(!device_data_){ total_length_ = 0u; + return; } + queue_->wait(); } template @@ -102,6 +116,7 @@ public: return; } queue_->template copy>(&from.at(0), device_data_, total_length_); + queue_->wait(); } data(const data& from): @@ -116,7 +131,10 @@ public: // device_data_ = cl::sycl::malloc_device::type>(from.size(), *queue_); if(!device_data_){ total_length_ = 0u; + return; } + + queue_->template copy>(from.device_data_, device_data_, total_length_); } data& operator=(const data& rhs) { @@ -158,7 +176,20 @@ public: } } - data& at(uint64_t i){ + /** + * Allocate appropriate meta data and then copy to host + */ + template + error_or> copy_to_host() const { + data data_{total_length_}; + + /// TODO Check success + queue_->template copy>(device_data_, &data_.at(0), total_length_); + queue_->wait(); + return data_; + } + + data& at(uint64_t i){ //typename native_data_type::type& at(uint64_t i){ return device_data_[i]; } @@ -247,6 +278,9 @@ public: return std::get>(storage_.maps).next_free_id(); } + /** + * Main constructor + */ rpc_server(interface cl_iface): cmd_queue_{}, cl_interface_{std::move(cl_iface)}, @@ -255,12 +289,11 @@ public: template remote_data request_data(id dat_id){ - /// @TODO Fix so I can receive data - return {dat_id, std::get>(storage_.maps)}; + return {dat_id, std::get>(storage_.maps), cmd_queue_}; } /** - * Rpc call + * Rpc call based on the name */ template error_or< -- cgit v1.2.3