summaryrefslogtreecommitdiff
path: root/modules/remote-sycl
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-07-21 23:03:23 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-07-21 23:03:23 +0200
commitfdf1b23129d73b27b28756e77da9b02215878721 (patch)
tree772ebc08eae70b5c09c4882dd3d07ef31c053c07 /modules/remote-sycl
parente5bf2f231e5ebaa13baf0742149d71fc8777e823 (diff)
Fake remote allocation.
Diffstat (limited to 'modules/remote-sycl')
-rw-r--r--modules/remote-sycl/c++/device.hpp5
-rw-r--r--modules/remote-sycl/c++/transfer.hpp20
2 files changed, 25 insertions, 0 deletions
diff --git a/modules/remote-sycl/c++/device.hpp b/modules/remote-sycl/c++/device.hpp
index ae19524..3561da7 100644
--- a/modules/remote-sycl/c++/device.hpp
+++ b/modules/remote-sycl/c++/device.hpp
@@ -25,6 +25,11 @@ public:
error_or<data<Schema, Encoding, rmt::Sycl>> copy_to_device(const data<Schema, Encoding, Storage>& host_data){
return data<Schema, Encoding, rmt::Sycl>{host_data};
}
+
+ template<typename Schema, typename Encoding, typename Storage>
+ error_or<data<Schema, Encoding, rmt::Sycl>> allocate_on_device(const data<typename meta_schema<Schema>::MetaSchema, Encoding, Storage>& host_meta){
+ return copy_to_device(data<Schema, Encoding, Storage>{host_meta});
+ }
/**
* Copy data to host
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
*/