From 7b6e0ca99f8521e034452f0d0243a7f3e33843a9 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Tue, 28 May 2024 17:23:20 +0200 Subject: Docs and Sycl fixes --- default.nix | 3 +- docs/Doxygen.in | 1 + modules/async/c++/async.hpp | 15 +++++++++ modules/codec/c++/data.hpp | 39 ++++++++++++++++++++++ modules/core/c++/id_map.hpp | 5 +++ modules/remote-sycl/.nix/derivation.nix | 2 +- modules/remote-sycl/examples/SConscript | 8 ++++- modules/remote-sycl/examples/sycl_basic.cpp | 21 +++--------- modules/remote-sycl/examples/sycl_basic.hpp | 13 ++++++++ modules/remote-sycl/examples/sycl_basic_kernel.cpp | 12 +++++++ 10 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 modules/remote-sycl/examples/sycl_basic.hpp create mode 100644 modules/remote-sycl/examples/sycl_basic_kernel.cpp 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 child = nullptr; conveyor_node_with_child_mixin(own &&child_, @@ -56,6 +68,9 @@ public: error_or> swap_child(own &&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 class data...>, encode::Native> { private: + /** + * Tuple storing the member values. + */ std::tuple>...> value_; public: + /** + * Default constructor. + */ data() = default; SAW_DEFAULT_COPY(data); SAW_DEFAULT_MOVE(data); + /** + * Get the member value based on the string_literal. + */ template data< typename parameter_pack_type< @@ -225,6 +237,9 @@ public: return std::get::value>(value_); } + /** + * Get the member value based on the string_literal. + */ template const data< typename parameter_pack_type< @@ -236,6 +251,9 @@ public: return std::get::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> { 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 find(const id& val){ if(val.get_value() >= data_.size()){ return make_error("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, "increment"> ->; -} +#include "./sycl_basic.hpp" int main(){ saw::remote remote_ctx; @@ -26,20 +18,15 @@ int main(){ return -1; } - saw::interface, cl::sycl::queue*> iface{ - [](saw::data in, cl::sycl::queue* q) -> saw::data { - return {in.get() + 1u}; - } - }; - auto rpc_server = remote_ctx.template listen>(*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{1u}); if(eov.is_error()){ return -2; } auto& val = eov.get_value(); - std::cout<<"Value: "<, "increment"> +>; +} + +saw::rpc_server, saw::rmt::Sycl> listen_basic_sycl(saw::remote& ctx, saw::remote_address& 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, rmt::Sycl> listen_basic_sycl(remote& ctx, remote_address& addr){ + saw::interface, cl::sycl::queue*> iface{ + [](saw::data in, cl::sycl::queue* q) -> saw::data { + return {in.get() + 1u}; + } + }; + auto rpc_server = remote_ctx.template listen>(*rmt_addr, std::move(iface)); + + return rpc_server; +} -- cgit v1.2.3