summaryrefslogtreecommitdiff
path: root/modules/remote-sycl/c++/transfer.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/remote-sycl/c++/transfer.hpp')
-rw-r--r--modules/remote-sycl/c++/transfer.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/remote-sycl/c++/transfer.hpp b/modules/remote-sycl/c++/transfer.hpp
index 5d76e7c..00c85e4 100644
--- a/modules/remote-sycl/c++/transfer.hpp
+++ b/modules/remote-sycl/c++/transfer.hpp
@@ -53,6 +53,26 @@ public:
return void_t{};
}
+ template<typename Sch>
+ error_or<void> allocate(const data<typename meta_schema<Sch>::MetaSchema, Encoding, storage::Default>& dat, id<Sch> store_id){
+ auto& vals = std::get<std::unordered_map<uint64_t, data<Sch,Encoding,rmt::Sycl>>>(values_);
+ auto eoval = device_->template allocate_on_device<Sch, Encoding, storage::Default>(dat);
+ if(eoval.is_error()){
+ auto& err = eoval.get_error();
+ return std::move(err);
+ }
+ auto& val = eoval.get_value();
+ try {
+ auto insert_res = vals.insert(std::make_pair(store_id.get_value(), std::move(val)));
+ if(!insert_res.second){
+ return make_error<err::already_exists>();
+ }
+ }catch ( std::exception& ){
+ return make_error<err::out_of_memory>();
+ }
+ return void_t{};
+ }
+
/**
* Requests data from the server
*/