From 1fb10980808d66dfa6dec4ac87857d5c13bf7298 Mon Sep 17 00:00:00 2001 From: Claudius 'keldu' Holeksa Date: Thu, 22 Aug 2024 11:45:47 +0200 Subject: Removing storage as a parameter --- modules/codec-json/c++/json.tmpl.hpp | 6 +- modules/codec-json/tests/codec-json.cpp | 38 ++++----- modules/codec-netcdf/tests/codec-netcdf.cpp | 6 +- modules/codec/c++/base64.hpp | 2 +- modules/codec/c++/data.hpp | 123 ++++++++++++++-------------- modules/codec/c++/data_raw.hpp | 34 ++++---- modules/codec/c++/id_map.hpp | 8 +- modules/codec/c++/interface.hpp | 57 +++++++------ modules/codec/tests/codec.cpp | 58 ++++++------- modules/codec/tests/csv.cpp | 2 +- modules/remote-sycl/c++/device.hpp | 2 +- modules/remote-sycl/c++/rpc.hpp | 10 +-- modules/remote-sycl/c++/transfer.hpp | 2 +- modules/remote-sycl/examples/sycl_basic.cpp | 6 +- modules/remote-thread/c++/remote.hpp | 20 ++--- modules/remote/c++/transfer.hpp | 8 +- modules/remote/c++/transfer_loopback.hpp | 14 ++-- 17 files changed, 196 insertions(+), 200 deletions(-) diff --git a/modules/codec-json/c++/json.tmpl.hpp b/modules/codec-json/c++/json.tmpl.hpp index 8663d5a..bead73a 100644 --- a/modules/codec-json/c++/json.tmpl.hpp +++ b/modules/codec-json/c++/json.tmpl.hpp @@ -837,7 +837,7 @@ struct json_decode, ToDecode> { using Schema = schema::Array; template - static error_or decode_flat_level(buffer_view& buff, std::vector>& to, std::array& index, std::array& dims, bool log_dim){ + static error_or decode_flat_level(buffer_view& buff, std::vector>& to, std::array& index, std::array& dims, bool log_dim){ if constexpr (Level == D) { json_helper::skip_whitespace(buff); @@ -903,7 +903,7 @@ struct json_decode, ToDecode> { } template - static error_or decode_unflat_level(std::vector>& flat, data, ToDecode>& to, std::array& index, std::size_t& flat_index) { + static error_or decode_unflat_level(std::vector>& flat, data, ToDecode>& to, std::array& index, std::size_t& flat_index) { if constexpr ( Level == D ){ auto& flat_data = flat.at(flat_index); to.at(index) = std::move(flat_data); @@ -925,7 +925,7 @@ struct json_decode, ToDecode> { std::array index; std::array dims; std::fill(dims.begin(), dims.end(), 0); - std::vector> flat_array; + std::vector> flat_array; auto eov = decode_flat_level<0>(buff, flat_array, index, dims, true); if(eov.is_error()){ return eov; diff --git a/modules/codec-json/tests/codec-json.cpp b/modules/codec-json/tests/codec-json.cpp index bc1540e..1d6c0f0 100644 --- a/modules/codec-json/tests/codec-json.cpp +++ b/modules/codec-json/tests/codec-json.cpp @@ -34,7 +34,7 @@ using TestStructArrayStruct = Struct< SAW_TEST("UInt8 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(121); @@ -54,7 +54,7 @@ SAW_TEST("UInt8 write"){ SAW_TEST("UInt16 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(24413); @@ -74,7 +74,7 @@ SAW_TEST("UInt16 write"){ SAW_TEST("UInt32 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(44123); @@ -94,7 +94,7 @@ SAW_TEST("UInt32 write"){ SAW_TEST("UInt64 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(243345543); @@ -114,7 +114,7 @@ SAW_TEST("UInt64 write"){ SAW_TEST("Int8 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(-121); @@ -134,7 +134,7 @@ SAW_TEST("Int8 write"){ SAW_TEST("Int16 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(-24413); @@ -154,7 +154,7 @@ SAW_TEST("Int16 write"){ SAW_TEST("Int32 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(44123); @@ -174,7 +174,7 @@ SAW_TEST("Int32 write"){ SAW_TEST("Int64 write"){ using namespace saw; - data native_int; + data native_int; data json_int; native_int.set(243345543); @@ -194,7 +194,7 @@ SAW_TEST("Int64 write"){ SAW_TEST("String write and read"){ using namespace saw; - data nat_str; + data nat_str; data json_str; nat_str.set("foo"); @@ -221,7 +221,7 @@ SAW_TEST("String write and read"){ SAW_TEST("Tuple read and write"){ using namespace saw; - data native_tup; + data native_tup; data json_tup; auto& nat_zero = native_tup.template get<0>(); @@ -250,7 +250,7 @@ SAW_TEST("Tuple read and write"){ SAW_TEST("Array write"){ using namespace saw; - data native{3u}; + data native{3u}; data json; native.at(0).set("foo"); @@ -270,7 +270,7 @@ SAW_TEST("Array write"){ SAW_TEST("Three Dim Array write and read"){ using namespace saw; - data native{2,1,2}; + data native{2,1,2}; data json; native.at(0,0,0).set("multi"); @@ -300,7 +300,7 @@ SAW_TEST("Three Dim Array write and read"){ SAW_TEST("Struct read and write"){ using namespace saw; - data native; + data native; data json; native.get<"foo">().set(5); @@ -325,7 +325,7 @@ SAW_TEST("Struct read and write"){ SAW_TEST("Array Struct Empty read and write"){ using namespace saw; - data native{0u}; + data native{0u}; data json; codec json_codec; @@ -345,7 +345,7 @@ SAW_TEST("Array Struct Empty read and write"){ SAW_TEST("Array Struct read and write"){ using namespace saw; - data native{4u}; + data native{4u}; data json; native.at(0).get<"foo">().set(5); @@ -374,7 +374,7 @@ SAW_TEST("Array Struct read and write"){ SAW_TEST("Struct Array Struct read and write"){ using namespace saw; - data native; + data native; native.template get<"banana">() = {4u}; data json; @@ -404,7 +404,7 @@ SAW_TEST("Struct Array Struct read and write"){ SAW_TEST("Int8 read"){ using namespace saw; - data native_int; + data native_int; data json_int{"43"}; codec json_codec; @@ -422,7 +422,7 @@ SAW_TEST("Int8 read"){ SAW_TEST("Int64 read"){ using namespace saw; - data native_int; + data native_int; data json_int{"-453"}; codec json_codec; @@ -440,7 +440,7 @@ SAW_TEST("Int64 read"){ SAW_TEST("Tuple Pretty Encode and Decode"){ using namespace saw; - data native_tup; + data native_tup; data json_tup; auto& nat_zero = native_tup.template get<0>(); diff --git a/modules/codec-netcdf/tests/codec-netcdf.cpp b/modules/codec-netcdf/tests/codec-netcdf.cpp index a47294f..7e624df 100644 --- a/modules/codec-netcdf/tests/codec-netcdf.cpp +++ b/modules/codec-netcdf/tests/codec-netcdf.cpp @@ -46,7 +46,7 @@ std::array tests_data_array_nc = { SAW_TEST("NetCDF Struct Primitive write"){ using namespace saw; - data native; + data native; native.template get<"data">().set(5); native.template get<"other">().set(32.0); @@ -69,7 +69,7 @@ SAW_TEST("NetCDF Struct Primitive read"){ using namespace saw; data netcdf{tests_data_primitive_nc}; - data native; + data native; codec codec; @@ -84,7 +84,7 @@ SAW_TEST("NetCDF Struct Array read"){ data netcdf{tests_data_array_nc}; - data native; + data native; codec codec; diff --git a/modules/codec/c++/base64.hpp b/modules/codec/c++/base64.hpp index 0c264be..141a63d 100644 --- a/modules/codec/c++/base64.hpp +++ b/modules/codec/c++/base64.hpp @@ -6,7 +6,7 @@ struct Base64 {}; } template<> -class data { +class data { public: using Schema = schema::String; private: diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 77edf8e..5d3e4ee 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -17,9 +17,6 @@ #include "schema_meta.hpp" namespace saw { -namespace storage { -struct Default {}; -} namespace encode { struct Native { @@ -85,7 +82,7 @@ struct native_data_type> { using type = double; }; -template +template class data { private: static_assert(always_false, "Type not supported."); @@ -121,8 +118,8 @@ public: } }; -template -class data, encode::Native, Storage> { +template +class data, encode::Native> { public: using Schema = schema::Primitive; using MetaSchema = typename meta_schema::MetaSchema; @@ -144,29 +141,29 @@ public: typename native_data_type::type get() const {return value_;} - data operator*(const data& rhs)const{ + data operator*(const data& rhs)const{ return {get() * rhs.get()}; } - data operator/(const data& rhs)const{ + data operator/(const data& rhs)const{ return {get() / rhs.get()}; } - data operator+(const data& rhs)const{ + data operator+(const data& rhs)const{ return {get() + rhs.get()}; } - data& operator+=(const data& rhs)const{ + data& operator+=(const data& rhs)const{ value_ += rhs.get(); return *this; } - data& operator-=(const data& rhs)const{ + data& operator-=(const data& rhs)const{ value_ -= rhs.get(); return *this; } - data operator-(const data& rhs)const{ + data operator-(const data& rhs)const{ return {get() - rhs.get()}; } @@ -184,7 +181,7 @@ public: * Casts */ template - data cast_to() const { + data cast_to() const { auto raw_to = static_cast::type>(value_); return {raw_to}; } @@ -193,13 +190,13 @@ public: /** * Mixed precision class for native formats */ -template -class data, schema::Primitive>, encode::Native, Storage>{ +template +class data, schema::Primitive>, encode::Native>{ public: using Schema = schema::MixedPrecision, schema::Primitive>; using MetaSchema = typename meta_schema::MetaSchema; private: - data value_; + data value_; public: data():value_{}{} data(data):value_{}{} @@ -210,7 +207,7 @@ public: return value_.template cast_to().get(); } - data(const saw::data& val){ + data(const saw::data& val){ value_ = val.template cast_to(); } @@ -218,65 +215,65 @@ public: value_.set(static_cast(val)); } - data operator*(const data& rhs) const { + data operator*(const data& rhs) const { using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left * right}; } - data operator*(const data& rhs) const { + data operator*(const data& rhs) const { using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = rhs.get(); return {left * right}; } - data operator/(const data& rhs)const{ + data operator/(const data& rhs)const{ using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left / right}; } - data operator+(const data& rhs)const{ + data operator+(const data& rhs)const{ using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left + right}; } - data& operator+=(const data& rhs)const{ + data& operator+=(const data& rhs)const{ *this = *this + rhs.get(); return *this; } - data operator-(const data& rhs)const{ + data operator-(const data& rhs)const{ using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left - right}; } - data& operator-=(const data& rhs) const { + data& operator-=(const data& rhs) const { *this = *this - rhs.get(); return *this; } template - bool operator==(const data& rhs)const{ + bool operator==(const data& rhs)const{ return get() == rhs.get(); } template - bool operator<(const data& rhs) const { + bool operator<(const data& rhs) const { return get() < rhs.get(); } }; /* template -class data>, encode::Native, storage::Default { +class data>, encode::Native { public: using Schema = schema::Ref>; private: @@ -299,16 +296,16 @@ public: * Union type for native data classes */ template -class data...>, encode::Native, storage::Default> { +class data...>, encode::Native> { public: using Schema = schema::Union...>; using MetaSchema = typename meta_schema::MetaSchema; private: - std::variant...> value_; + std::variant...> value_; template struct init_helper { - static void apply(std::variant...>& val, data&& init){ + static void apply(std::variant...>& val, data&& init){ if( init.index() == i ){ auto& val_i = val.template init(); val_i = {std::move(init.template get())}; @@ -332,12 +329,12 @@ public: SAW_DEFAULT_MOVE(data); template - void set(data::value, T...>::type, encode::Native, storage::Default> val){ + void set(data::value, T...>::type, encode::Native> val){ value_ = std::move(val); } template - data::value, T...>::type, encode::Native, storage::Default>& init(){ + data::value, T...>::type, encode::Native>& init(){ value_.template emplace::value>(); return get(); } @@ -348,12 +345,12 @@ public: } template - data::value, T...>::type, encode::Native, storage::Default>& get(){ + data::value, T...>::type, encode::Native>& get(){ return std::get::value>(value_); } template - const data::value, T...>::type, encode::Native, storage::Default>& get() const{ + const data::value, T...>::type, encode::Native>& get() const{ return std::get::value>(value_); } }; @@ -362,7 +359,7 @@ public: * Data class which represents a struct in the native format. */ template -class data...>, encode::Native, storage::Default> { +class data...>, encode::Native> { public: using Schema = schema::Struct...>; using MetaSchema = typename meta_schema::MetaSchema; @@ -370,11 +367,11 @@ private: /** * Tuple storing the member values. */ - std::tuple...> value_; + std::tuple...> value_; template struct init_helper { - static void apply(std::tuple...>& val, data&& init){ + static void apply(std::tuple...>& val, data&& init){ auto& val_i = val.template get(); auto& init_i = init.template get(); @@ -409,7 +406,7 @@ public: literal, literals... >::value , T...>::type - , encode::Native, storage::Default>& get(){ + , encode::Native>& get(){ return std::get::value>(value_); } @@ -423,7 +420,7 @@ public: literal, literals... >::value , T...>::type - , encode::Native, storage::Default>& get() const { + , encode::Native>& get() const { return std::get::value>(value_); } @@ -436,16 +433,16 @@ public: }; template -class data, encode::Native, storage::Default> { +class data, encode::Native> { public: using Schema = schema::Tuple; using MetaSchema = typename meta_schema::MetaSchema; private: - std::tuple...> value_; + std::tuple...> value_; template struct init_helper { - static void apply(std::tuple...>& val, data&& init){ + static void apply(std::tuple...>& val, data&& init){ auto& val_i = val.template get(); auto& init_i = init.template get(); @@ -468,12 +465,12 @@ public: SAW_DEFAULT_MOVE(data); template - data::type, encode::Native, storage::Default>& get(){ + data::type, encode::Native>& get(){ return std::get(value_); } template - const data::type, encode::Native, storage::Default>& get() const{ + const data::type, encode::Native>& get() const{ return std::get(value_); } @@ -524,14 +521,14 @@ public: }; template -class data, encode::Native, storage::Default> { +class data, encode::Native> { public: using Schema = schema::Array; using MetaSchema = typename meta_schema::MetaSchema; private: // data> dims_; std::array dims_; - std::vector> value_; + std::vector> value_; uint64_t get_full_size() const { uint64_t s = 1; @@ -570,7 +567,7 @@ class data, encode::Native, storage::Default> { } template - error_or add(saw::data data){ + error_or add(saw::data data){ /** @todo * Generally the last dimension can always accept a element so to say. * Changing the others would require moving data due to the stride changing. @@ -605,29 +602,29 @@ class data, encode::Native, storage::Default> { static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension"); } - data& at(const std::array& ind){ + data& at(const std::array& ind){ return value_.at(this->get_flat_index(ind)); } - const data& at(const std::array& ind) const { + const data& at(const std::array& ind) const { return value_.at(this->get_flat_index(ind)); } template - data& at(Dims... i){ + data& at(Dims... i){ return value_.at(this->get_flat_index(std::array{static_cast(i)...})); } template - const data& at(Dims... i) const { + const data& at(Dims... i) const { return value_.at(this->get_flat_index(std::array{static_cast(i)...})); } - data& at(const data>& i){ + data& at(const data>& i){ return value_.at(this->get_flat_index(i)); } - const data& at(const data>& i)const{ + const data& at(const data>& i)const{ return value_.at(this->get_flat_index(i)); } @@ -675,14 +672,14 @@ private: }; template -class data, encode::Native, storage::Default> { +class data, encode::Native> { public: using Schema = schema::FixedArray; using MetaSchema = typename meta_schema::MetaSchema; private: - //using inner_type = std::array, multiply_helper::value>; + //using inner_type = std::array, multiply_helper::value>; //std::unique_ptr value_; - using ArrayT = std::array, ct_multiply::value>; + using ArrayT = std::array, ct_multiply::value>; ArrayT value_; public: @@ -692,29 +689,29 @@ public: value_{value__} {} - data& at(const std::array& ind){ + data& at(const std::array& ind){ return value_.at(this->get_flat_index(ind)); } - const data& at(const std::array& ind) const { + const data& at(const std::array& ind) const { return value_.at(this->get_flat_index(ind)); } template - data& at(Dims... i) { + data& at(Dims... i) { return value_.at(this->get_flat_index({i...})); } template - const data& at(Dims... i) const { + const data& at(Dims... i) const { return value_.at(this->get_flat_index({i...})); } - data& at(const data>& i){ + data& at(const data>& i){ return value_.at(this->get_flat_index(i)); } - const data& at(const data>& i)const{ + const data& at(const data>& i)const{ return value_.at(this->get_flat_index(i)); } @@ -748,7 +745,7 @@ private: * Data type representing string. */ template<> -class data { +class data { public: using Schema = schema::String; using MetaSchema = typename meta_schema::MetaSchema; diff --git a/modules/codec/c++/data_raw.hpp b/modules/codec/c++/data_raw.hpp index 40751a3..de5e7f0 100644 --- a/modules/codec/c++/data_raw.hpp +++ b/modules/codec/c++/data_raw.hpp @@ -211,7 +211,7 @@ public: * Data class which represents a struct in the native format. */ template -class data...>, encode::NativeRaw, storage::Default> { +class data...>, encode::NativeRaw> { public: using Schema = schema::Struct...>; using MetaSchema = typename meta_schema::MetaSchema; @@ -219,7 +219,7 @@ private: /** * Tuple storing the member values. */ - std::tuple...> value_; + std::tuple...> value_; template struct init_helper { @@ -258,7 +258,7 @@ public: literal, literals... >::value , T...>::type - , encode::NativeRaw, storage::Default>& get(){ + , encode::NativeRaw>& get(){ return std::get::value>(value_); } @@ -272,7 +272,7 @@ public: literal, literals... >::value , T...>::type - , encode::NativeRaw, storage::Default>& get() const { + , encode::NativeRaw>& get() const { return std::get::value>(value_); } @@ -285,12 +285,12 @@ public: }; template -class data, encode::NativeRaw, storage::Default> { +class data, encode::NativeRaw> { public: using Schema = schema::Tuple; using MetaSchema = typename meta_schema::MetaSchema; private: - std::tuple...> value_; + std::tuple...> value_; template struct init_helper { @@ -317,12 +317,12 @@ public: SAW_DEFAULT_MOVE(data); template - data::type, encode::NativeRaw, storage::Default>& get(){ + data::type, encode::NativeRaw>& get(){ return std::get(value_); } template - const data::type, encode::NativeRaw, storage::Default>& get() const{ + const data::type, encode::NativeRaw>& get() const{ return std::get(value_); } @@ -332,7 +332,7 @@ public: }; template -class data, encode::NativeRaw, storage::Default> { +class data, encode::NativeRaw> { public: using Schema = schema::Array; using MetaSchema = typename meta_schema::MetaSchema; @@ -348,7 +348,7 @@ class data, encode::NativeRaw, storage::Default> { std::conditional< is_primitive::value, typename native_data_type::type, - data + data > > value_; @@ -390,7 +390,7 @@ class data, encode::NativeRaw, storage::Default> { } template - error_or add(saw::data data){ + error_or add(saw::data data){ /** @todo * Generally the last dimension can always accept a element so to say. * Changing the others would require moving data due to the stride changing. @@ -425,29 +425,29 @@ class data, encode::NativeRaw, storage::Default> { static_assert(sizeof...(Dims)==Dim, "Argument size must be equal to the Dimension"); } - data& at(const std::array& ind){ + data& at(const std::array& ind){ return value_.at(this->get_flat_index(ind)); } - const data& at(const std::array& ind) const { + const data& at(const std::array& ind) const { return value_.at(this->get_flat_index(ind)); } template - data& at(Dims... i){ + data& at(Dims... i){ return value_.at(this->get_flat_index(std::array{static_cast(i)...})); } template - const data& at(Dims... i) const { + const data& at(Dims... i) const { return value_.at(this->get_flat_index(std::array{static_cast(i)...})); } - data& at(const data>& i){ + data& at(const data>& i){ return value_.at(this->get_flat_index(i)); } - const data& at(const data>& i)const{ + const data& at(const data>& i)const{ return value_.at(this->get_flat_index(i)); } diff --git a/modules/codec/c++/id_map.hpp b/modules/codec/c++/id_map.hpp index 18a331f..56becf0 100644 --- a/modules/codec/c++/id_map.hpp +++ b/modules/codec/c++/id_map.hpp @@ -19,7 +19,7 @@ private: /** * Container which stores the primary data */ - std::vector> data_; + std::vector> data_; /** * Container which tracks free'd/fragmented elements within the * main container @@ -65,7 +65,7 @@ public: * Inserts an element into the container and returns either an id on success * or an error on failure. */ - error_or> insert(data val) noexcept { + error_or> insert(data val) noexcept { /// @todo Fix size_t and id base type if(free_ids_.empty()){ try { @@ -90,7 +90,7 @@ public: /** * Insert as data with associated id. This can fail when it doesn't adhere to the standard approach. */ - error_or insert_as(data val, id id) noexcept { + error_or insert_as(data val, id id) noexcept { if(free_ids_.empty()){ if( id.get_value() != data_.size() ){ return make_error("Can't insert_as with provided ID. Doesn't match."); @@ -178,7 +178,7 @@ public: * Returns an error on failure and returns * a value pointer on success. */ - error_or*> find(const id& val){ + error_or*> find(const id& val){ if(val.get_value() >= data_.size()){ return make_error("ID is too large"); } diff --git a/modules/codec/c++/interface.hpp b/modules/codec/c++/interface.hpp index e1c9a12..f31b778 100644 --- a/modules/codec/c++/interface.hpp +++ b/modules/codec/c++/interface.hpp @@ -8,44 +8,44 @@ #include "data.hpp" namespace saw { -template +template class function; namespace impl { -template +template struct FuncReturnTypeHelper { - using Type = data; + using Type = data; }; -template -struct FuncReturnTypeHelper { +template +struct FuncReturnTypeHelper { using Type = void; }; -template +template struct FuncTypeHelper { - using Type = std::function::Type>(data&, Ctx)>; + using Type = std::function::Type>(data&, Ctx)>; }; -template -struct FuncTypeHelper { - using Type = std::function::Type>(data&)>; +template +struct FuncTypeHelper { + using Type = std::function::Type>(data&)>; }; } -template -class function, Encode, Storage, Context> { +template +class function, Encode, Context> { private: - typename impl::FuncTypeHelper::Type func_; - using ResponseDataType = typename impl::FuncReturnTypeHelper::Type; + typename impl::FuncTypeHelper::Type func_; + using ResponseDataType = typename impl::FuncReturnTypeHelper::Type; public: template function(Func func): func_{std::move(func)} {} - error_or call(data& req, Context ctx = {}){ + error_or call(data& req, Context ctx = {}){ if constexpr (std::is_same_v){ (void) ctx; return func_(req); @@ -55,17 +55,17 @@ public: } }; -template +template class interface; -template -class interface, Names>...>, Encode, Storage, Context> { +template +class interface, Names>...>, Encode, Context> { public: using Schema = schema::Interface,Names>...>; private: - std::tuple, Encode, Storage, Context>...> funcs_; + std::tuple, Encode, Context>...> funcs_; public: - interface(function, Encode, Storage, Context>... funcs): + interface(function, Encode, Context>... funcs): funcs_{std::move(funcs)...} {} @@ -88,7 +88,6 @@ public: , Responses...>::type > , Encode - , Storage , Context >& get(){ return std::get::value>(funcs_); @@ -102,14 +101,14 @@ public: Lit, Names... >::value , Responses...>::type - , Encode, Storage>::Type > call( + , Encode>::Type > call( data< typename parameter_pack_type< parameter_key_pack_index< Lit, Names... >::value , Requests...>::type - , Encode, Storage>& req, + , Encode>& req, Context ctx = {} ){ if constexpr (std::is_same_v) { @@ -121,19 +120,19 @@ public: } }; -template +template struct function_factory { template - static function create(Func func){ - return function {std::move(func)}; + static function create(Func func){ + return function {std::move(func)}; } }; -template +template struct interface_factory { template - static interface create(Func... func){ - return interface{std::move(func)...}; + static interface create(Func... func){ + return interface{std::move(func)...}; } }; } diff --git a/modules/codec/tests/codec.cpp b/modules/codec/tests/codec.cpp index 1bec214..7ad1c89 100644 --- a/modules/codec/tests/codec.cpp +++ b/modules/codec/tests/codec.cpp @@ -54,7 +54,7 @@ using TestInterface = Interface< SAW_TEST("One Dimensional Array") { using namespace saw; - data arr{500u}; + data arr{500u}; int bar = 0; @@ -73,7 +73,7 @@ SAW_TEST("One Dimensional Array") { SAW_TEST("One dim Array Default init"){ using namespace saw; - data arr; + data arr; SAW_EXPECT(arr.get_dim_size(0) == 0, "Dim should be size 0"); SAW_EXPECT(arr.size() == 0, "Total size should also be zero"); @@ -82,7 +82,7 @@ SAW_TEST("One dim Array Default init"){ SAW_TEST("One dimensional Array Add"){ using namespace saw; - data arr{5u}; + data arr{5u}; int bar = 0; @@ -99,7 +99,7 @@ SAW_TEST("One dimensional Array Add"){ SAW_TEST("Two Dimensional Array") { using namespace saw; - data arr{10,30u}; + data arr{10,30u}; int expected_sum = (300 * 301) / 2; @@ -123,7 +123,7 @@ SAW_TEST("Two Dimensional Array") { SAW_TEST("Three Dimensional Array") { using namespace saw; - data arr{10,10u,3}; + data arr{10,10u,3}; int expected_sum = (300 * 301) / 2; int bar = 0; @@ -149,7 +149,7 @@ SAW_TEST("Three Dimensional Array") { SAW_TEST("KelSimple UInt16 write"){ using namespace saw; - data native; + data native; data simple; codec codec; @@ -172,7 +172,7 @@ SAW_TEST("KelSimple UInt16 write"){ SAW_TEST("KelSimple UInt32 write"){ using namespace saw; - data native; + data native; data simple; codec codec; @@ -195,7 +195,7 @@ SAW_TEST("KelSimple UInt32 write"){ SAW_TEST("KelSimple Array write and read back"){ using namespace saw; - data native{2,3}; + data native{2,3}; data simple; codec codec; @@ -228,7 +228,7 @@ SAW_TEST("KelSimple Array write and read back"){ SAW_TEST("KelSimple Struct write and read back"){ using namespace saw; - data native; + data native; data simple; auto& tda = native.template get<"two_dim_array">(); @@ -259,7 +259,7 @@ SAW_TEST("KelSimple Struct write and read back"){ SAW_TEST("Native Union same type compilation"){ using namespace saw; - data native; + data native; native.template init<"two">().set(50u); @@ -272,10 +272,10 @@ SAW_TEST("Native Union same type compilation"){ SAW_TEST("KelSimple Union write and read back"){ using namespace saw; - data native; + data native; data simple; - native.template set<"number">(data{}); + native.template set<"number">(data{}); native.template get<"number">().set(410); codec codec; @@ -296,7 +296,7 @@ SAW_TEST("KelSimple Union write and read back"){ SAW_TEST("KelSimple Tuple write and read back"){ using namespace saw; - data native; + data native; data simple; auto& tda = native.template get<0>(); @@ -327,7 +327,7 @@ SAW_TEST("KelSimple Tuple write and read back"){ SAW_TEST("KelSimple String write and read back"){ using namespace saw; - data native; + data native; data simple; std::string str = "FooBananaJoe"; @@ -352,14 +352,14 @@ SAW_TEST("Function basics"){ using namespace saw; { - data native; + data native; native.get<0>().set(5); native.get<1>().set(40); - auto func_add = function_factory::create( - [](data req){ - data resp; + auto func_add = function_factory::create( + [](data req){ + data resp; resp.set(req.get<0>().get() + req.get<1>().get()); @@ -378,26 +378,26 @@ SAW_TEST("Function basics"){ SAW_TEST("Interface basics"){ using namespace saw; - data native; + data native; auto func_add = - [](data& req){ - data resp; + [](data& req){ + data resp; resp.set(req.get<0>().get() + req.get<1>().get()); return resp; }; auto func_sub = - [](data& req){ - data resp; + [](data& req){ + data resp; resp.set(req.get<0>().get() - req.get<1>().get()); return resp; }; - auto func_multiply = [](data& req){ - data resp; + auto func_multiply = [](data& req){ + data resp; resp.set(req.get<0>().get() * req.get<1>().get()); @@ -409,10 +409,10 @@ SAW_TEST("Interface basics"){ return void_t{}; }; - auto iface = interface_factory::create(std::move(func_add), std::move(func_sub), std::move(func_multiply), std::move(func_void)); + auto iface = interface_factory::create(std::move(func_add), std::move(func_sub), std::move(func_multiply), std::move(func_void)); { - data native; + data native; native.get<0>().set(5); native.get<1>().set(40); @@ -423,7 +423,7 @@ SAW_TEST("Interface basics"){ SAW_EXPECT(val.get() == 45, "Sum is incorrect"); } { - data native; + data native; native.get<0>().set(5); native.get<1>().set(40); @@ -434,7 +434,7 @@ SAW_TEST("Interface basics"){ SAW_EXPECT(val.get() == -35, "Sum is incorrect"); } { - data native; + data native; native.get<0>().set(5); native.get<1>().set(40); diff --git a/modules/codec/tests/csv.cpp b/modules/codec/tests/csv.cpp index 638b864..ac394ce 100644 --- a/modules/codec/tests/csv.cpp +++ b/modules/codec/tests/csv.cpp @@ -22,7 +22,7 @@ SAW_TEST("Codec Csv Encode Basic"){ using namespace saw; size_t n_size = 3; - data native_data{n_size}; + data native_data{n_size}; { auto& row = native_data.at(0); row.template get<"string">().set("foo"); diff --git a/modules/remote-sycl/c++/device.hpp b/modules/remote-sycl/c++/device.hpp index 6d4dbbf..a050078 100644 --- a/modules/remote-sycl/c++/device.hpp +++ b/modules/remote-sycl/c++/device.hpp @@ -37,7 +37,7 @@ public: template error_or> copy_to_host(data>& dev_data){ /** - data host_data; + data host_data; cmd_queue_.submit([&](cl::sycl::handler& h){ auto acc_buff = dev_data.template access(h); h.copy(acc_buff, &host_data); diff --git a/modules/remote-sycl/c++/rpc.hpp b/modules/remote-sycl/c++/rpc.hpp index da2eeaa..8cb4d8d 100644 --- a/modules/remote-sycl/c++/rpc.hpp +++ b/modules/remote-sycl/c++/rpc.hpp @@ -48,14 +48,14 @@ public: /** * Wait for the data */ - error_or> wait(){ + error_or> wait(){ return make_error(); } /** * Request data asynchronously */ - // conveyor> on_receive(); /// Stopped here + // conveyor> on_receive(); /// Stopped here }; /** @@ -151,7 +151,7 @@ public: > > call(const data_or_id::type::RequestT, Encoding>& input){ auto next_free_id = srv_->template next_free_id::type::ResponseT>(); - return srv_->template call(input, next_free_id); + return srv_->template call(input, next_free_id); } }; @@ -180,7 +180,7 @@ private: /** * The interface including the relevant context class. */ - interface cl_interface_; + interface cl_interface_; public: @@ -205,7 +205,7 @@ public: /** template - remote_data request_data(id dat_id){ + remote_data request_data(id dat_id){ return {dat_id, std::get>(storage_.maps), device_->get_handle()}; } */ diff --git a/modules/remote-sycl/c++/transfer.hpp b/modules/remote-sycl/c++/transfer.hpp index e39165b..b6a21f0 100644 --- a/modules/remote-sycl/c++/transfer.hpp +++ b/modules/remote-sycl/c++/transfer.hpp @@ -131,7 +131,7 @@ public: * Requests data from the server */ template - error_or> receive(id store_id){ + error_or> receive(id store_id){ auto& vals = std::get>>>(values_); auto find_res = vals.find(store_id.get_value()); if(find_res == vals.end()){ diff --git a/modules/remote-sycl/examples/sycl_basic.cpp b/modules/remote-sycl/examples/sycl_basic.cpp index bc4d997..a4bc595 100644 --- a/modules/remote-sycl/examples/sycl_basic.cpp +++ b/modules/remote-sycl/examples/sycl_basic.cpp @@ -21,7 +21,7 @@ int main(){ auto device = remote_ctx.connect_device(*rmt_addr); auto rpc_server = listen_basic_sycl(remote_ctx, device, *rmt_addr); - saw::rpc_client client{rpc_server}; + saw::rpc_client client{rpc_server}; saw::id> id_zero{0u}; saw::data, saw::encode::Native> ex_data{1u}; @@ -38,7 +38,7 @@ int main(){ id_zero = eov.get_value(); } { - auto rmt_data = rpc_server.request_data, saw::storage::Default>(id_zero); + auto rmt_data = rpc_server.request_data>(id_zero); auto eo_rd = rmt_data.wait(); if(eo_rd.is_error()){ auto& err = eo_rd.get_error(); @@ -64,7 +64,7 @@ int main(){ id_one = eov.get_value(); } { - auto rmt_data = rpc_server.request_data, saw::storage::Default>(id_one); + auto rmt_data = rpc_server.request_data>(id_one); auto eo_rd = rmt_data.wait(); if(eo_rd.is_error()){ auto& err = eo_rd.get_error(); diff --git a/modules/remote-thread/c++/remote.hpp b/modules/remote-thread/c++/remote.hpp index 39c64a6..280101a 100644 --- a/modules/remote-thread/c++/remote.hpp +++ b/modules/remote-thread/c++/remote.hpp @@ -36,7 +36,7 @@ class thread_rpc_communication_handler final { private: std::mutex mut_; - using FunctionT = std::function(rpc_server&)>; + using FunctionT = std::function(rpc_server&)>; std::deque dispatches_; // TODO Need a send + receive + erase request queue @@ -48,12 +48,12 @@ public: error_or call(id dat_id){ std::lock_guard lock{mut_}; - dispatches_.emplace_back([dat_id](rpc_server& srv){ + dispatches_.emplace_back([dat_id](rpc_server& srv){ srv.template call(dat_id); }); } - error_or run_next_dispatch(rpc_server& srv){ + error_or run_next_dispatch(rpc_server& srv){ std::lock_guard lock{mut_}; if(dispatches_.empty()){ return make_error("Dispatch Queue is empty"); @@ -67,19 +67,19 @@ public: } -template -class rpc_server { +template +class rpc_server { private: - our> comms_; + our> comms_; public: }; -template -class rpc_client { +template +class rpc_client { private: - our> comms_; + our> comms_; public: - rpc_client(our> comms__): + rpc_client(our> comms__): comms_{std::move(comms__)} {} }; diff --git a/modules/remote/c++/transfer.hpp b/modules/remote/c++/transfer.hpp index f68497b..5a2e2b2 100644 --- a/modules/remote/c++/transfer.hpp +++ b/modules/remote/c++/transfer.hpp @@ -32,14 +32,14 @@ template class data_client; namespace impl { -template +template struct data_server_redux { using type = std::tuple<>; }; -template -struct data_server_redux> { - using type = std::tuple>...>; +template +struct data_server_redux> { + using type = std::tuple>...>; }; } } diff --git a/modules/remote/c++/transfer_loopback.hpp b/modules/remote/c++/transfer_loopback.hpp index 39ae402..bc23498 100644 --- a/modules/remote/c++/transfer_loopback.hpp +++ b/modules/remote/c++/transfer_loopback.hpp @@ -102,7 +102,7 @@ public: template class data_server, Encoding, rmt::Loopback> final : public i_data_server { private: - typename impl::data_server_redux>::type>::type values_; + typename impl::data_server_redux>::type>::type values_; ptr> remote_; remote_address rmt_address_; @@ -134,7 +134,7 @@ public: * Get data from client */ template - error_or send(const data& dat, id store_id){ + error_or send(const data& dat, id store_id){ auto& vals = std::get>>(values_); try { @@ -166,7 +166,7 @@ public: } template - error_or> receive(id store_id){ + error_or> receive(id store_id){ auto& vals = std::get>>(values_); auto find_res = vals.find(store_id.get_value()); @@ -189,7 +189,7 @@ public: } template - error_or*> find(id store_id){ + error_or*> find(id store_id){ auto& vals = std::get>>(values_); auto find_res = vals.find(store_id.get_value()); if(find_res == vals.end()){ @@ -245,7 +245,7 @@ public: /** * Receive data */ - conveyor> receive(id dat_id){ + conveyor> receive(id dat_id){ auto eov = srv_().receive(dat_id); if(eov.is_error()){ auto& err = eov.get_error(); @@ -310,7 +310,7 @@ public: * Send data to the remote. */ template - error_or> send(const data& dat){ + error_or> send(const data& dat){ id dat_id{next_id_}; auto eov = srv_().send(dat, dat_id); if(eov.is_error()){ @@ -341,7 +341,7 @@ public: * Receive data */ template - conveyor> receive(id dat_id){ + conveyor> receive(id dat_id){ auto eov = srv_().receive(dat_id); if(eov.is_error()){ auto& err = eov.get_error(); -- cgit v1.2.3