summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default.nix3
-rw-r--r--docs/Doxygen.in1
-rw-r--r--modules/async/c++/async.hpp15
-rw-r--r--modules/codec/c++/data.hpp39
-rw-r--r--modules/core/c++/id_map.hpp5
-rw-r--r--modules/remote-sycl/.nix/derivation.nix2
-rw-r--r--modules/remote-sycl/examples/SConscript8
-rw-r--r--modules/remote-sycl/examples/sycl_basic.cpp21
-rw-r--r--modules/remote-sycl/examples/sycl_basic.hpp13
-rw-r--r--modules/remote-sycl/examples/sycl_basic_kernel.cpp12
10 files changed, 99 insertions, 20 deletions
diff --git a/default.nix b/default.nix
index 688a478..52a36a1 100644
--- a/default.nix
+++ b/default.nix
@@ -78,7 +78,8 @@ in rec {
inherit stdenv;
inherit clang-tools;
openmp = pkgs.llvmPackages_17.openmp;
- #build_examples = "true";
+
+ build_examples = "true";
};
tools = pkgs.callPackage modules/tools/.nix/derivation.nix {
diff --git a/docs/Doxygen.in b/docs/Doxygen.in
index 59f2014..6124483 100644
--- a/docs/Doxygen.in
+++ b/docs/Doxygen.in
@@ -5,3 +5,4 @@ PROJECT_NAME = forstio
RECURSIVE = YES
FILE_PATTERNS = *.cpp *.hpp
INPUT = ../modules
+EXCLUDE_SYMBOLS = *::impl::*
diff --git a/modules/async/c++/async.hpp b/modules/async/c++/async.hpp
index b56742c..0f58536 100644
--- a/modules/async/c++/async.hpp
+++ b/modules/async/c++/async.hpp
@@ -12,6 +12,12 @@
namespace saw {
class conveyor_storage;
+
+/**
+ * The inner base conveyor node type.
+ * It serves as a base for the asynchronous pipe/conveyor
+ * structure.
+ */
class conveyor_node {
public:
conveyor_node();
@@ -40,8 +46,14 @@ public:
virtual void notify_parent_attached(conveyor_node &){};
};
+/**
+ * Conveyor helper type to provide some basic storage for child conveyor nodes.
+ */
class conveyor_node_with_child_mixin final {
public:
+ /**
+ * The child itself.
+ */
own<conveyor_node> child = nullptr;
conveyor_node_with_child_mixin(own<conveyor_node> &&child_,
@@ -56,6 +68,9 @@ public:
error_or<own<conveyor_node>> swap_child(own<conveyor_node> &&swapee);
};
+/**
+ * Conveyor helper type to provide some basic reference helper.
+ */
class conveyor_node_with_parent_mixin final {
public:
conveyor_node *parent = nullptr;
diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp
index c7af0d4..2a5f082 100644
--- a/modules/codec/c++/data.hpp
+++ b/modules/codec/c++/data.hpp
@@ -205,15 +205,27 @@ public:
}
};
+/**
+ * Data class which represents a struct in the native format.
+ */
template<typename... T, string_literal... literals>
class data<schema::Struct<schema::Member<T, literals>...>, encode::Native<storage::Default>> {
private:
+ /**
+ * Tuple storing the member values.
+ */
std::tuple<data<T,encode::Native<storage::Default>>...> value_;
public:
+ /**
+ * Default constructor.
+ */
data() = default;
SAW_DEFAULT_COPY(data);
SAW_DEFAULT_MOVE(data);
+ /**
+ * Get the member value based on the string_literal.
+ */
template<string_literal literal>
data<
typename parameter_pack_type<
@@ -225,6 +237,9 @@ public:
return std::get<parameter_key_pack_index<literal, literals...>::value>(value_);
}
+ /**
+ * Get the member value based on the string_literal.
+ */
template<string_literal literal>
const data<
typename parameter_pack_type<
@@ -236,6 +251,9 @@ public:
return std::get<parameter_key_pack_index<literal, literals...>::value>(value_);
}
+ /**
+ * Return the amount of members.
+ */
constexpr size_t size() const {
return sizeof...(T);
}
@@ -469,9 +487,15 @@ private:
}
};
+/**
+ * Data type representing string.
+ */
template<>
class data<schema::String, encode::Native<storage::Default>> {
private:
+ /**
+ * The native way to represent strings.
+ */
std::string value_;
public:
data() = default;
@@ -483,18 +507,30 @@ public:
value_.resize(size_);
}
+ /**
+ * Return the length of the string.
+ */
std::size_t size() const {
return value_.size();
}
+ /**
+ * set the inner string to str.
+ */
void set(std::string str){
value_ = std::move(str);
}
+ /**
+ * Get a char reference at position i.
+ */
char& at(size_t i) {
return value_.at(i);
}
+ /**
+ * Get a char reference at position i.
+ */
const char& at(size_t i) const {
return value_.at(i);
}
@@ -507,6 +543,9 @@ public:
value_.at(i) = val;
}
+ /**
+ * Check if a string_view is equal to this type.
+ */
bool operator==(const std::string_view& val)const{
return value_ == val;
}
diff --git a/modules/core/c++/id_map.hpp b/modules/core/c++/id_map.hpp
index e1c1b3f..1df2178 100644
--- a/modules/core/c++/id_map.hpp
+++ b/modules/core/c++/id_map.hpp
@@ -140,6 +140,11 @@ public:
return void_t{};
}
+ /**
+ * Tries to find a value based on an id.
+ * Returns an error on failure and returns
+ * a value pointer on success.
+ */
error_or<T*> find(const id<T>& val){
if(val.get_value() >= data_.size()){
return make_error<err::not_found>("ID is too large");
diff --git a/modules/remote-sycl/.nix/derivation.nix b/modules/remote-sycl/.nix/derivation.nix
index 0ce1cfa..2b00ada 100644
--- a/modules/remote-sycl/.nix/derivation.nix
+++ b/modules/remote-sycl/.nix/derivation.nix
@@ -44,7 +44,7 @@ in stdenv.mkDerivation {
scons prefix=$out build_examples=${build_examples} install
'';
- doCheck = true;
+ doCheck = false;
checkPhase = ''
scons test
./bin/tests
diff --git a/modules/remote-sycl/examples/SConscript b/modules/remote-sycl/examples/SConscript
index 7fa9429..1e77251 100644
--- a/modules/remote-sycl/examples/SConscript
+++ b/modules/remote-sycl/examples/SConscript
@@ -12,14 +12,20 @@ dir_path = Dir('.').abspath
# Environment for base library
examples_env = env.Clone();
+examples_sycl_env = examples_env.Clone();
+examples_sycl_env['CXX'] = 'syclcc';
+
examples_env.sources = sorted(glob.glob(dir_path + "/*.cpp"))
examples_env.headers = sorted(glob.glob(dir_path + "/*.hpp"))
env.sources += examples_env.sources;
env.headers += examples_env.headers;
+sycl_objects = [];
+examples_sycl_env.add_source_files(sycl_objects, ['sycl_basic_kernel.cpp'], shared=True);
+
objects_static = []
-examples_env.sycl_basic = examples_env.Program('#bin/sycl_basic', ['sycl_basic.cpp', env.library_static]);
+examples_env.sycl_basic = examples_env.Program('#bin/sycl_basic', ['sycl_basic.cpp', env.library_static, sycl_objects]);
# Set Alias
env.examples = [examples_env.sycl_basic];
diff --git a/modules/remote-sycl/examples/sycl_basic.cpp b/modules/remote-sycl/examples/sycl_basic.cpp
index a180d23..abea738 100644
--- a/modules/remote-sycl/examples/sycl_basic.cpp
+++ b/modules/remote-sycl/examples/sycl_basic.cpp
@@ -1,12 +1,4 @@
-#include "../c++/remote.hpp"
-
-namespace schema {
-using namespace saw::schema;
-
-using BasicInterface = Interface<
- Member<Function<UInt64, UInt64>, "increment">
->;
-}
+#include "./sycl_basic.hpp"
int main(){
saw::remote<saw::rmt::Sycl> remote_ctx;
@@ -26,20 +18,15 @@ int main(){
return -1;
}
- saw::interface<schema::BasicInterface, saw::encode::Native<saw::storage::Default>, cl::sycl::queue*> iface{
- [](saw::data<saw::schema::UInt64> in, cl::sycl::queue* q) -> saw::data<saw::schema::UInt64> {
- return {in.get() + 1u};
- }
- };
- auto rpc_server = remote_ctx.template listen<schema::BasicInterface, saw::encode::Native<saw::storage::Default>>(*rmt_addr, std::move(iface));
+ auto rpc_server = listen_basic_sycl(remote_ctx, *rmt_addr);
{
- auto eov = rpc_server.template call<"increment">({1u});
+ auto eov = rpc_server.template call<"increment">(saw::id<schema::UInt64>{1u});
if(eov.is_error()){
return -2;
}
auto& val = eov.get_value();
- std::cout<<"Value: "<<val<<std::endl;
+ // std::cout<<"Value: "<<val<<std::endl;
}
diff --git a/modules/remote-sycl/examples/sycl_basic.hpp b/modules/remote-sycl/examples/sycl_basic.hpp
new file mode 100644
index 0000000..0d4b5d2
--- /dev/null
+++ b/modules/remote-sycl/examples/sycl_basic.hpp
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "../c++/remote.hpp"
+
+namespace schema {
+using namespace saw::schema;
+
+using BasicInterface = Interface<
+ Member<Function<UInt64, UInt64>, "increment">
+>;
+}
+
+saw::rpc_server<schema::BasicInterface, saw::encode::Native<saw::storage::Default>, saw::rmt::Sycl> listen_basic_sycl(saw::remote<saw::rmt::Sycl>& ctx, saw::remote_address<saw::rmt::Sycl>& addr);
diff --git a/modules/remote-sycl/examples/sycl_basic_kernel.cpp b/modules/remote-sycl/examples/sycl_basic_kernel.cpp
new file mode 100644
index 0000000..eb79bb8
--- /dev/null
+++ b/modules/remote-sycl/examples/sycl_basic_kernel.cpp
@@ -0,0 +1,12 @@
+#include "sycl_basic.hpp"
+
+rpc_server<schema::BasicInterface, encode::Native<storage::Default>, rmt::Sycl> listen_basic_sycl(remote<rmt::Sycl>& ctx, remote_address<rmt::Sycl>& addr){
+ saw::interface<schema::BasicInterface, saw::encode::Native<saw::storage::Default>, cl::sycl::queue*> iface{
+ [](saw::data<saw::schema::UInt64> in, cl::sycl::queue* q) -> saw::data<saw::schema::UInt64> {
+ return {in.get() + 1u};
+ }
+ };
+ auto rpc_server = remote_ctx.template listen<schema::BasicInterface, saw::encode::Native<saw::storage::Default>>(*rmt_addr, std::move(iface));
+
+ return rpc_server;
+}