From 6831edddd22d2d8dbb73c88fb612c0bdd5b8ba19 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 11 Jun 2024 16:05:47 +0200 Subject: Intermediate commit while working on design issues --- modules/remote-sycl/c++/remote.hpp | 100 ++++++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 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 dbbefcb..d311ca5 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -4,7 +4,7 @@ #include #include -#include +#include namespace saw { namespace rmt { @@ -37,13 +37,77 @@ public: conveyor> on_receive(); /// Stopped here }; +/** + * + */ +template +class data, encode::Native> { +public: + using Schema = schema::Primitive; + using NativeType = typename native_data_type::type; +private: + /** + * + */ + NativeType val_; +public: + /** + * + */ + data(NativeType val__): + val_{val__} + {} + + NativeType get(){ + return val_; + } +}; + template class data, encode::Native> { +public: + using Schema = schema::Array; private: - cl::sycl::buffer::type, D> device_data_; + uint64_t total_length_; + typename native_data_type::type* device_data_; + // data* device_data_; + cl::sycl::queue* queue_; + static_assert(is_primitive::value, "Only supports primitives for now"); static_assert(D==1u, "For now we only support 1D Arrays"); public: + data(uint64_t size, cl::sycl::queue& q__): + total_length_{size}, + device_data_{cl::sycl::malloc_device::type>(size, q__)}, + queue_{&q__} + { + if(!device_data_){ + total_length_ = 0u; + } + } + + template + data(const data& from, cl::sycl::queue& q__): + total_length_{from.size()}, + device_data_{cl::sycl::malloc_device::type>(from.size(), q__)}, + queue_{&q__} + { + if(!device_data_){ + total_length_ = 0u; + } + } + + ~data(){ + // free data + if(device_data_){ + /// SYCL FREE + cl::sycl::free(device_data_, *queue_); + } + } + + data>& at(uint64_t i){ + return device_data_[i]; + } }; namespace impl { @@ -58,6 +122,36 @@ struct rpc_id_map_helper, Encoding> { std::tuple...> maps; }; } +/** + * Rpc Client class for the Sycl backend. + */ +template +class rpc_client { +public: +private: + /** + * Server this client is tied to + */ + rpc_server* srv_; +public: + rpc_client(rpc_server& srv): + srv_{&srv} + {} + + /** + * Rpc call + */ + template + error_or< + id< + typename schema_member_type::type::ResponseT + > + > call(data_or_id::type::RequestT, ClientEncoding> input){ + return make_error("RpcClient side is not implemented"); + } + +}; + /** * Rpc Server class for the Sycl backend. */ @@ -103,6 +197,8 @@ public: > > call(data_or_id::type::RequestT, Encoding> input){ + + /** * 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. -- cgit v1.2.3