From 9dd079f6c90405622e4b08a3337fb91f2a9935ff Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 18 Sep 2024 20:26:52 +0200 Subject: wip --- modules/remote-hip/c++/device.hpp | 17 ++++++++++++++++- modules/remote-hip/c++/device.tmpl.hpp | 18 ++++++++++++++++++ modules/remote-hip/c++/transfer.hpp | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/remote-hip/c++/device.hpp b/modules/remote-hip/c++/device.hpp index f760024..ed2b42f 100644 --- a/modules/remote-hip/c++/device.hpp +++ b/modules/remote-hip/c++/device.hpp @@ -22,15 +22,30 @@ public: error_or copy_to_device(data& from, data>& to){ auto dev_data = to.get_device_data(); - auto eov = impl::hip_copy_to_device::apply(from, dev_data); return eov; } template error_or copy_to_host(data>& from, data& to){ + auto dev_data = from.get_device_data(); + auto eov = impl::hip_copy_to_host::apply(dev_data,to); + return make_error(); + } + + template + error_or erase_from_device(data>& dev_dat){ + (void) dev_dat; return make_error(); } + + template + error_or allocate_on_device(const typename data::Init& from, data>& to){ + (void) from; + (void) to; + return make_error(); + } + }; } diff --git a/modules/remote-hip/c++/device.tmpl.hpp b/modules/remote-hip/c++/device.tmpl.hpp index 6f5fc6a..c3d0bff 100644 --- a/modules/remote-hip/c++/device.tmpl.hpp +++ b/modules/remote-hip/c++/device.tmpl.hpp @@ -10,6 +10,14 @@ struct hip_copy_to_device { } }; +template +struct hip_copy_to_host { + static error_or apply(data** dev_dat, data& to){ + static_assert(always_false, "Unsupported case."); + return make_void(); + } +}; + template struct hip_copy_to_device, Encoding> { using Schema = schema::Primitive; @@ -25,6 +33,16 @@ struct hip_copy_to_device, Encoding> { } }; +template +struct hip_copy_to_host, Encoding> { + using Schema = schema::Primitive; + + static error_or apply(data** dev_dat, data& to){ + hipError_t copy_err = hipMemcpy(*dev_dat, &to, sizeof(data), hipMemcpyDeviceToHost); + return make_void(); + } +}; + template struct hip_copy_to_device, Encoding> { static_assert(Dim == 1u, "Only 1D arrays are supported for now."); diff --git a/modules/remote-hip/c++/transfer.hpp b/modules/remote-hip/c++/transfer.hpp index a4c4c30..5844c27 100644 --- a/modules/remote-hip/c++/transfer.hpp +++ b/modules/remote-hip/c++/transfer.hpp @@ -55,6 +55,7 @@ public: } error_or erase(id store_id){ + return make_error("Erase not implemented"); return make_void(); } -- cgit v1.2.3