39 template <
class ReturnElementType,
class... SrcTypes>
50 static constexpr auto isSigned = std::is_signed_v<Type>;
52 static constexpr auto isUnsigned = std::is_unsigned_v<Type>;
54 static constexpr auto isInt = std::is_integral_v<Type>;
56 static constexpr auto isSignedInt = isSigned & isInt;
60 static constexpr auto isInt32 = std::same_as<int32_t, Type>;
62 static constexpr auto isUint32 = std::same_as<uint32_t, Type>;
64 static constexpr auto isInt64 = std::same_as<int64_t, Type>;
66 static constexpr auto isUint64 = std::same_as<uint64_t, Type>;
68 static constexpr auto isFloat = std::same_as<float, Type>;
70 static constexpr auto isDouble = std::same_as<double, Type>;
114 using Accelerate = platform_vec_ops::AppleAccelerate<typename CommonElement::Type>;
117 using IPP = platform_vec_ops::IntelIPP<typename CommonElement::Type>;
121 template <
class ExpressionTypes>
133template <
size_t i,
class RuntimeArgs, is::expression Expression>
134constexpr void tryApplyingRuntimeArgsToThisExpression (
const RuntimeArgs& args, Expression& e)
136 if constexpr (RuntimeArgs::template hasValue<i>())
138 std::apply ([&] (
const auto&... args)
141 "The expression does not implement a applyRuntimeArgs overload that matches the argument types passed.");
142 e.applyRuntimeArgs (args...);
143 }, args.template get<i>());
145 else if constexpr (has::applyRuntimeArgs<Expression>)
149 e.applyRuntimeArgs();
153template <
size_t i,
class RuntimeArgs, is::anyVctrOrExpression Src>
154constexpr void tryApplyingRuntimeArgsToSrc (
const RuntimeArgs& args, Src& src)
156 if constexpr (has::iterateOverRuntimeArgChain<Src, i, RuntimeArgs> && i < RuntimeArgs::size())
157 src.template iterateOverRuntimeArgChain<i> (args);
160template <
class A,
class B, auto op>
163 using type =
decltype (op (std::declval<A>(), std::declval<B>()));
166template <
class A, std::common_with<A> B, auto op>
176template <
class A,
class B, auto op>
195#define VCTR_COMMON_UNARY_EXPRESSION_MEMBERS(ExpressionName, srcName) \
197 using Expression = ExpressionTypes<value_type, SrcType>; \
201 template <class Src> \
202 constexpr ExpressionName (Src&& s) : srcName (std::forward<Src> (s)) {} \
204 constexpr const auto& getStorageInfo() const { return srcName.getStorageInfo(); } \
206 constexpr size_t size () const { return srcName.size (); } \
208 constexpr bool isNotAliased (const void* other) const { return srcName.isNotAliased (other); } \
210 template <size_t i, class RuntimeArgs> \
211 constexpr void iterateOverRuntimeArgChain (const RuntimeArgs& rtArgs) \
213 tryApplyingRuntimeArgsToThisExpression<i> (rtArgs, *this); \
214 tryApplyingRuntimeArgsToSrc<i + 1> (rtArgs, srcName); \
232#define VCTR_COMMON_BINARY_VEC_VEC_EXPRESSION_MEMBERS(ExpressionName, srcAName, srcBName) \
234 using Expression = ExpressionTypes<value_type, SrcAType, SrcBType>; \
235 using SrcAStorageInfoType = std::invoke_result_t<decltype (&std::remove_cvref_t<SrcAType>::getStorageInfo), SrcAType>; \
236 using SrcBStorageInfoType = std::invoke_result_t<decltype (&std::remove_cvref_t<SrcBType>::getStorageInfo), SrcBType>; \
240 const ::vctr::CombinedStorageInfo<std::remove_cvref_t<SrcAStorageInfoType>, std::remove_cvref_t<SrcBStorageInfoType>> storageInfo; \
243 template <class SrcA, class SrcB> \
244 constexpr ExpressionName (SrcA&& a, SrcB&& b) \
245 : srcAName (std::forward<SrcA> (a)), \
246 srcBName (std::forward<SrcB> (b)), \
247 storageInfo (srcAName.getStorageInfo(), srcBName.getStorageInfo()) \
250 constexpr const auto& getStorageInfo() const { return storageInfo; } \
252 constexpr size_t size() const { return srcAName.size(); } \
254 constexpr bool isNotAliased (const void* dst) const \
256 if constexpr (is::expression<SrcAType> && is::anyVctr<SrcBType>) \
258 return dst != srcBName.data(); \
261 if constexpr (is::anyVctr<SrcAType> && is::expression<SrcBType>) \
263 return dst != srcAName.data(); \
283#define VCTR_COMMON_BINARY_SINGLE_VEC_EXPRESSION_MEMBERS(ExpressionName, srcVecName, srcSingleName) \
285 using Expression = ExpressionTypes<value_type, SrcType>; \
287 SrcType srcVecName; \
288 typename Expression::CommonSrcElement::Type srcSingleName; \
291 template <class Src> \
292 constexpr ExpressionName (typename Expression::CommonSrcElement::Type a, Src&& b) \
293 : srcVecName (std::forward<Src> (b)), \
297 constexpr const auto& getStorageInfo() const { return srcVecName.getStorageInfo(); } \
299 constexpr size_t size() const { return srcVecName.size(); } \
300 constexpr bool isNotAliased (const void* other) const { return srcVecName.isNotAliased (other); }
303#define VCTR_FORWARD_PREPARE_SIMD_EVALUATION_UNARY_EXPRESSION_MEMBER_FUNCTIONS \
304 void prepareNeonEvaluation() const \
305 requires ::vctr::has::prepareNeonEvaluation<SrcType> \
307 src.prepareNeonEvaluation(); \
310 VCTR_FORCEDINLINE VCTR_TARGET ("avx") void prepareAVXEvaluation() const \
311 requires ::vctr::has::prepareAVXEvaluation<SrcType> && Expression::CommonElement::isRealFloat \
313 src.prepareAVXEvaluation(); \
316 VCTR_FORCEDINLINE VCTR_TARGET ("avx2") void prepareAVXEvaluation() const \
317 requires ::vctr::has::prepareAVXEvaluation<SrcType> && Expression::CommonElement::isInt \
319 src.prepareAVXEvaluation(); \
322 VCTR_FORCEDINLINE VCTR_TARGET ("sse4.1") void prepareSSEEvaluation() const \
323 requires ::vctr::has::prepareSSEEvaluation<SrcType> \
325 src.prepareSSEEvaluation(); \
329#define VCTR_FORWARD_PREPARE_SIMD_EVALUATION_BINARY_EXPRESSION_MEMBER_FUNCTIONS(srcAName, srcBName) \
330 void prepareNeonEvaluation() const \
331 requires ::vctr::has::prepareNeonEvaluation<SrcAType> && ::vctr::has::prepareNeonEvaluation<SrcBType> \
333 srcAName.prepareNeonEvaluation(); \
334 srcBName.prepareNeonEvaluation(); \
337 VCTR_FORCEDINLINE VCTR_TARGET ("avx") void prepareAVXEvaluation() const \
338 requires ::vctr::has::prepareAVXEvaluation<SrcAType> && ::vctr::has::prepareAVXEvaluation<SrcBType> && Expression::CommonElement::isRealFloat \
340 srcAName.prepareAVXEvaluation(); \
341 srcBName.prepareAVXEvaluation(); \
344 VCTR_FORCEDINLINE VCTR_TARGET ("avx2") void prepareAVXEvaluation() const \
345 requires ::vctr::has::prepareAVXEvaluation<SrcAType> && ::vctr::has::prepareAVXEvaluation<SrcBType> && Expression::CommonElement::isInt \
347 srcAName.prepareAVXEvaluation(); \
348 srcBName.prepareAVXEvaluation(); \
351 VCTR_FORCEDINLINE VCTR_TARGET ("sse4.1") void prepareSSEEvaluation() const \
352 requires ::vctr::has::prepareSSEEvaluation<SrcAType> && ::vctr::has::prepareSSEEvaluation<SrcBType> \
354 srcAName.prepareSSEEvaluation(); \
355 srcBName.prepareSSEEvaluation(); \
Constrains a pack of elements to be the same type.
Definition: GenericConcepts.h:142
Constrains a type to have a function applyRuntimeArgs (const Args&...)
Definition: ContainerAndExpressionConcepts.h:180
Constrains a type to represent a complex valued floating point number (e.g.
Definition: NumericTypeConcepts.h:87
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:83
The main namespace of the VCTR project.
Definition: Array.h:24
typename detail::CommonVecExpressionType< A, B, op >::type CommonVecExpressionType
Used to figure out the value_type for binary vector-vector operations.
Definition: ExpressionTemplate.h:177
Definition: AVXRegister.h:28
Some common traits you want to check when constraining expression template functions.
Definition: ExpressionTemplate.h:45
Supplies some handy typedefs and traits needed when implementing expression templates.
Definition: ExpressionTemplate.h:41
static constexpr auto allElementTypesSame
Indicates if all source element types and the return types are same.
Definition: ExpressionTemplate.h:80
platform_vec_ops::AppleAccelerate< typename CommonElement::Type > Accelerate
The platform_vec_ops::AppleAccelerate type for the common element type.
Definition: ExpressionTemplate.h:114
platform_vec_ops::IntelIPP< typename CommonElement::Type > IPP
The platform_vec_ops::IntelIPP type for the common element type.
Definition: ExpressionTemplate.h:117
The base class to every expression template.
Definition: ExpressionTemplate.h:37
Definition: NeonRegister.h:28
Definition: SSERegister.h:28
Helper template to define a union of all supported SIMD types.
Definition: ExpressionTemplate.h:123