diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
commit | 7479b39379bcf79dfa73a61643538832c2571c49 (patch) | |
tree | 115666ec7696d12df2a9449e18f1fc5d4cf76cb8 /modules/remote-sycl | |
parent | 059dc4308ac731d2b3c324166d87b8d527b9d217 (diff) |
Trying to get rpc interaction with iface working
Diffstat (limited to 'modules/remote-sycl')
-rw-r--r-- | modules/remote-sycl/c++/remote.hpp | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index 0d10ba7..70c8032 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -1,6 +1,8 @@ #pragma once #include <forstio/io_codec/rpc.hpp> +#include <forstio/codec/data.hpp> +#include <forstio/id_map.hpp> #include <CL/sycl.hpp> @@ -12,12 +14,91 @@ struct Sycl {}; template<> class remote<rmt::Sycl>; -template<typename Iface, typename Encode> -class rpc_server<Iface, Encode, rmt::Sycl> { +/** + * Remote data class for the Sycl backend. + */ +template<typename T, typename Encoding> +class remote_data<T, Encoding, rmt::Sycl> { private: + id<T> id_; + id_map<T>* map_; +public: + /** + * Main constructor + */ + remote_data(const id<T>& id, id_map<data<T, Encoding>>& map): + id_{id}, + map_{&map} + {} + + /** + * Request data asynchronously + */ + conveyor<data<T,Encoding>> on_receive(); /// Stopped here +}; +namespace impl { + +template<typename Iface, typename Encoding> +struct rpc_id_map_helper { + static_assert(always_false<Iface, Encoding>, "Only support Interface schema types."); +}; + +template<typename... Members, typename Encoding> +struct rpc_id_map_helper<schema::Interface<Members...>, Encoding> { + std::tuple<id_map<data<typename Members::ValueType::ResponseT, Encoding>>...> maps; +}; +} +/** + * Rpc Server class for the Sycl backend. + */ +template<typename Iface, typename Encoding> +class rpc_server<Iface, Encoding, rmt::Sycl> { +private: + using IfaceCtx = cl::sycl::queue*; + /** + * Command queue for the sycl backend + */ cl::sycl::queue cmd_queue_; + + /** + * The interface including the relevant context class. + */ + interface<Iface, Encoding, IfaceCtx> cl_interface_; + + /** + * + */ + impl::rpc_id_map_helper<Iface, Encoding> storage_; public: + rpc_server(interface<Iface, Encoding, IfaceCtx> cl_iface): + cmd_queue_{}, + cl_interface_{std::move(cl_iface)}, + storage_{} + {} + template<typename IdT> + remote_data<IdT, Encoding, rmt::Sycl> request_data(id<IdT> dat){ + return {data, std::get<id_map<data<IdT, Encoding>>>(storage_.maps)}; + } + + /** + * rpc call + */ + template<string_literal Name> + error_or< + id< + typename schema_member_type<Name, Iface>::type::ValueType::ResponseT + > + > call(data_or_id<typename schema_member_type<Name, Iface>::type::ValueType::RequestT, Encoding> input){ + + auto eod = cmd_queue_.template call<Name>(std::move(input), &cmd_queue_); + + if(eod.is_error()){ + return std::move(eod.get_error()); + } + + return id<typename schema_member_type<Name, Iface>::type::ValueType::ResponseT>{}; + } }; @@ -59,7 +140,7 @@ public: */ template<typename Iface, typename Encoding> conveyor<rpc_server<Iface, Encoding, rmt::Sycl>> listen(const remote_address<rmt::Sycl>&){ - + return {}; } }; |