From 60d0f8da2b754d1deb0dbb59f6e6783ba4c692c4 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 29 May 2024 21:16:06 +0200 Subject: Reworked id_map and trying to fix sycl launch --- modules/remote-sycl/c++/remote.hpp | 51 ++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 11 deletions(-) (limited to 'modules/remote-sycl/c++') diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index d4b114a..003dd0e 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include @@ -21,12 +21,12 @@ template class remote_data { private: id id_; - id_map* map_; + id_map* map_; public: /** * Main constructor */ - remote_data(const id& id, id_map>& map): + remote_data(const id& id, id_map& map): id_{id}, map_{&map} {} @@ -55,7 +55,7 @@ struct rpc_id_map_helper { template struct rpc_id_map_helper, Encoding> { - std::tuple>...> maps; + std::tuple...> maps; }; } /** @@ -78,7 +78,7 @@ private: interface cl_interface_; /** - * + * Basic storage for response data. */ impl::rpc_id_map_helper storage_; public: @@ -90,11 +90,11 @@ public: template remote_data request_data(id dat){ - return {dat, std::get>>(storage_.maps)}; + return {dat, std::get>(storage_.maps)}; } /** - * rpc call + * Rpc call */ template error_or< @@ -103,15 +103,44 @@ public: > > call(data_or_id::type::RequestT, Encoding> input){ - auto eod = cl_interface_.template call(std::move(input), &cmd_queue_); + /** + * First check if it's data or an id. + * If it's an id, check if it's registered within the storage and retrieve it. + */ + auto eoinp = [&,this]() -> error_or::type::RequestT, Encoding>* > { + if(input.is_id()){ + // storage_.maps + auto& inner_map = std::get::type::RequestT, Encoding >> (storage_.maps); + auto eov = inner_map.find(input.get_id()); + if(eov.is_error()){ + return std::move(eov.get_error()); + } + return eov.get_value(); + }else { + return &input.get_data(); + } + }(); + if(eoinp.is_error()){ + return std::move(eoinp.get_error()); + } + auto& inp = *(eoinp.get_value()); + + auto eod = cl_interface_.template call(std::move(inp), &cmd_queue_); if(eod.is_error()){ return std::move(eod.get_error()); } - // using ResponseTMap = id_map> - - return id::type::ResponseT>{}; + /** + * Store returned data in rpc storage + */ + auto& val = eod.get_value(); + auto& inner_map = std::get::type::RequestT, Encoding >> (storage_.maps); + auto eoid = inner_map.insert(std::move(val)); + if(eoid.is_error()){ + return std::move(eoid.get_error()); + } + return eoid.get_value(); } }; -- cgit v1.2.3