From 601113a445658d8b15273dd91c66cf20daf50d30 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Thu, 20 Jun 2024 16:35:25 +0200 Subject: Changing towards a better allocated structure for sycl --- modules/codec/c++/data.hpp | 8 ++++---- modules/codec/c++/interface.hpp | 19 +++++-------------- modules/codec/tests/codec.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 22 deletions(-) (limited to 'modules/codec') diff --git a/modules/codec/c++/data.hpp b/modules/codec/c++/data.hpp index 8e0e029..5ebe579 100644 --- a/modules/codec/c++/data.hpp +++ b/modules/codec/c++/data.hpp @@ -176,21 +176,21 @@ public: } data operator*(const data& rhs) const { - using CalcType = typename native_data_type::type; + 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{ - using CalcType = typename native_data_type::type; + 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{ - using CalcType = typename native_data_type::type; + using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left + right}; @@ -202,7 +202,7 @@ public: } data operator-(const data& rhs)const{ - using CalcType = typename native_data_type::type; + using CalcType = typename native_data_type::type; CalcType left = static_cast(value_.get()); CalcType right = static_cast(rhs.get()); return {left - right}; diff --git a/modules/codec/c++/interface.hpp b/modules/codec/c++/interface.hpp index 0186f09..0f41f55 100644 --- a/modules/codec/c++/interface.hpp +++ b/modules/codec/c++/interface.hpp @@ -14,12 +14,12 @@ class function; namespace impl { template struct FuncTypeHelper { - using Type = std::function(data, Ctx)>; + using Type = std::function(data&, Ctx)>; }; template struct FuncTypeHelper { - using Type = std::function(data)>; + using Type = std::function(data&)>; }; } @@ -41,15 +41,6 @@ public: return func_(req, ctx); } } - - error_or> call(data&& req, Context ctx = {}){ - if constexpr (std::is_same_v){ - (void) ctx; - return func_(std::move(req)); - } else { - return func_(std::move(req), ctx); - } - } }; template @@ -106,14 +97,14 @@ public: Lit, Names... >::value , Requests...>::type - , Encode, Storage> req, + , Encode, Storage>& req, Context ctx = {} ){ if constexpr (std::is_same_v) { (void) ctx; - return get().call(std::move(req)); + return get().call(req); }else{ - return get().call(std::move(req), ctx); + return get().call(req, ctx); } } }; diff --git a/modules/codec/tests/codec.cpp b/modules/codec/tests/codec.cpp index 10d9d0c..720b734 100644 --- a/modules/codec/tests/codec.cpp +++ b/modules/codec/tests/codec.cpp @@ -364,7 +364,7 @@ SAW_TEST("Function basics"){ } ); - auto eov = func_add.call(std::move(native)); + auto eov = func_add.call(native); SAW_EXPECT(eov.is_value(), "Returned value is an error"); auto& val = eov.get_value(); @@ -408,7 +408,7 @@ SAW_TEST("Interface basics"){ native.get<0>().set(5); native.get<1>().set(40); - auto eov = iface.template call<"add">(std::move(native)); + auto eov = iface.template call<"add">(native); SAW_EXPECT(eov.is_value(), "Returned value is an error"); auto& val = eov.get_value(); @@ -419,7 +419,7 @@ SAW_TEST("Interface basics"){ native.get<0>().set(5); native.get<1>().set(40); - auto eov = iface.template call<"sub">(std::move(native)); + auto eov = iface.template call<"sub">(native); SAW_EXPECT(eov.is_value(), "Returned value is an error"); auto& val = eov.get_value(); @@ -430,7 +430,7 @@ SAW_TEST("Interface basics"){ native.get<0>().set(5); native.get<1>().set(40); - auto eov = iface.template call<"multiply">(std::move(native)); + auto eov = iface.template call<"multiply">(native); SAW_EXPECT(eov.is_value(), "Returned value is an error"); auto& val = eov.get_value(); -- cgit v1.2.3