summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2024-06-24 15:23:08 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2024-06-24 15:23:08 +0200
commitcace251b73a2902fbdade9e8cd7ae0f52f0e18e1 (patch)
tree5089537cbe03506f42b04d756564909e22b6ee7d
parent86b06a3fee2cd7635a9ab486e2a35bdf1e81ce38 (diff)
Slowly adding pure data transfer classes
-rw-r--r--modules/remote-sycl/.nix/derivation.nix5
-rw-r--r--modules/remote-sycl/c++/common.hpp11
-rw-r--r--modules/remote-sycl/c++/remote.hpp8
-rw-r--r--modules/remote-sycl/c++/transfer.hpp81
-rw-r--r--modules/remote-sycl/examples/sycl_basic_kernel.cpp1
-rw-r--r--modules/remote-sycl/tests/SConscript2
6 files changed, 96 insertions, 12 deletions
diff --git a/modules/remote-sycl/.nix/derivation.nix b/modules/remote-sycl/.nix/derivation.nix
index 2247ec0..71c5dff 100644
--- a/modules/remote-sycl/.nix/derivation.nix
+++ b/modules/remote-sycl/.nix/derivation.nix
@@ -48,9 +48,10 @@ in stdenv.mkDerivation {
installPhase = ''
scons prefix=$out build_examples=${build_examples} install
'';
-
+
doCheck = true;
- checkPhase = ''
+ checkPhase = ''
+ export ACPP_APPDB_DIR=.
scons test
./bin/tests
'';
diff --git a/modules/remote-sycl/c++/common.hpp b/modules/remote-sycl/c++/common.hpp
index c1f9ddf..9bc734d 100644
--- a/modules/remote-sycl/c++/common.hpp
+++ b/modules/remote-sycl/c++/common.hpp
@@ -11,4 +11,15 @@ namespace rmt {
struct Sycl {};
}
+template<>
+class remote<rmt::Sycl>;
+
+template<typename T>
+class device;
+
+template<typename Schema, typename Encoding, typename Remote>
+class data_server;
+
+template<typename Schema, typename Encoding, typename Remote>
+class data_client;
}
diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp
index 24756be..2d0eaea 100644
--- a/modules/remote-sycl/c++/remote.hpp
+++ b/modules/remote-sycl/c++/remote.hpp
@@ -5,12 +5,6 @@
namespace saw {
-template<>
-class remote<rmt::Sycl>;
-
-template<typename T>
-class device;
-
template<typename Schema>
class data<Schema, encode::Native, rmt::Sycl> {
private:
@@ -334,7 +328,6 @@ public:
}
};
-
template<>
struct remote_address<rmt::Sycl> {
private:
@@ -353,7 +346,6 @@ class remote<rmt::Sycl> {
private:
SAW_FORBID_COPY(remote);
SAW_FORBID_MOVE(remote);
-
public:
/**
* Default constructor
diff --git a/modules/remote-sycl/c++/transfer.hpp b/modules/remote-sycl/c++/transfer.hpp
new file mode 100644
index 0000000..6849caa
--- /dev/null
+++ b/modules/remote-sycl/c++/transfer.hpp
@@ -0,0 +1,81 @@
+#pragma once
+
+#include "common.hpp"
+#include "data.hpp"
+#include <forstio/error.hpp>
+
+namespace saw {
+template<typename Schema, typename Encoding>
+class data_server<Schema, Encoding, rmt::Sycl> {
+private:
+ /**
+ * Device context class
+ */
+ device<rmt::Sycl>* device_;
+
+ /**
+ * Store for the data the server manages.
+ */
+ std::unordered_map<uint64_t, data<Schema, Encoding, rmt::Sycl>> values_;
+public:
+ /**
+ * Main constructor
+ */
+ data_server(device<rmt::Sycl>& device__):
+ device_{&device__}
+ {}
+
+ /**
+ * Receive data which we will store.
+ */
+ error_or<void> send(const data<Schema, Encoding, storage::Default>& dat, id<Schema> store_id){
+ auto eoval = device_->copy_to_device(dat);
+ if(eoval.is_error()){
+ auto& err = eoval.get_error();
+ return std::move(err);
+ }
+ return make_error<err::not_implemented>();
+ }
+
+ error_or<data<Schema, Encoding, storage::Default>> receive(id<Schema> store_id){
+ return make_error<err::not_implemented>();
+ }
+};
+
+template<typename Schema, typename Encoding>
+class data_client<Schema, Encoding, rmt::Sycl> {
+private:
+ /**
+ * Corresponding server for this client
+ */
+ data_server<Schema, Encoding, rmt::Sycl>* srv_;
+
+ /**
+ * The next id for identifying issues on the remote side.
+ */
+ uint64_t next_id_;
+public:
+ /**
+ * Main constructor
+ */
+ data_client(data_server<Schema, Encoding, rmt::Sycl>& srv__):
+ srv_{&srv__},
+ next_id_{0u}
+ {}
+
+ /**
+ * Send data to.
+ */
+ error_or<id<Schema>> send(const data<Schema, Encoding, storage::Default>& dat){
+ id<Schema> dat_id{next_id_};
+ auto eov = srv_->send(dat, dat_id);
+ if(eov.is_error()){
+ auto& err = eov.get_error();
+ return std::move(err);
+ }
+
+ ++next_id_;
+ return dat_id;
+ }
+};
+}
diff --git a/modules/remote-sycl/examples/sycl_basic_kernel.cpp b/modules/remote-sycl/examples/sycl_basic_kernel.cpp
index f9a838e..763e733 100644
--- a/modules/remote-sycl/examples/sycl_basic_kernel.cpp
+++ b/modules/remote-sycl/examples/sycl_basic_kernel.cpp
@@ -8,7 +8,6 @@ saw::rpc_server<schema::BasicInterface, saw::encode::Native, saw::rmt::Sycl> lis
[](saw::data<saw::schema::Array<saw::schema::UInt64>, saw::encode::Native, saw::rmt::Sycl>& in, cl::sycl::queue* q) -> saw::error_or<void> {
q->submit([&](cl::sycl::handler& h){
-
h.single_task([&] (){
in.at(0u).set(in.at(0u).get() + 1u);
});
diff --git a/modules/remote-sycl/tests/SConscript b/modules/remote-sycl/tests/SConscript
index 3a9a2cf..f56f0bd 100644
--- a/modules/remote-sycl/tests/SConscript
+++ b/modules/remote-sycl/tests/SConscript
@@ -12,7 +12,7 @@ dir_path = Dir('.').abspath
# Environment for base library
test_cases_env = env.Clone();
-test_cases_env['CXX'] = 'syclcc';
+test_cases_env['CXX'] = 'acpp';
test_cases_env.Append(LIBS=['forstio-test']);