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 = PlatformVectorOps::AppleAccelerate<typename CommonElement::Type>;
117 using IPP = PlatformVectorOps::IntelIPP<typename CommonElement::Type>;
124template <
size_t i,
class RuntimeArgs, is::expression Expression>
125constexpr void tryApplyingRuntimeArgsToThisExpression (
const RuntimeArgs& args, Expression& e)
127 if constexpr (RuntimeArgs::template hasValue<i>())
129 std::apply ([&] (
const auto&... args)
132 "The expression does not implement a applyRuntimeArgs overload that matches the argument types passed.");
133 e.applyRuntimeArgs (args...);
134 }, args.template get<i>());
136 else if constexpr (has::applyRuntimeArgs<Expression>)
140 e.applyRuntimeArgs();
144template <
size_t i,
class RuntimeArgs, is::anyVctrOrExpression Src>
145constexpr void tryApplyingRuntimeArgsToSrc (
const RuntimeArgs& args, Src& src)
147 if constexpr (has::iterateOverRuntimeArgChain<Src, i, RuntimeArgs> && i < RuntimeArgs::size())
148 src.template iterateOverRuntimeArgChain<i> (args);
169#define VCTR_COMMON_UNARY_EXPRESSION_MEMBERS(ExpressionName, srcName) \
171 using Expression = ExpressionTypes<value_type, SrcType>; \
175 template <class Src> \
176 constexpr ExpressionName (Src&& s) : srcName (std::forward<Src> (s)) {} \
178 constexpr const auto& getStorageInfo() const { return srcName.getStorageInfo(); } \
180 constexpr size_t size () const { return srcName.size (); } \
182 constexpr bool isNotAliased (const void* other) const { return srcName.isNotAliased (other); } \
184 template <size_t i, class RuntimeArgs> \
185 constexpr void iterateOverRuntimeArgChain (const RuntimeArgs& rtArgs) \
187 tryApplyingRuntimeArgsToThisExpression<i> (rtArgs, *this); \
188 tryApplyingRuntimeArgsToSrc<i + 1> (rtArgs, srcName); \
206#define VCTR_COMMON_BINARY_VEC_VEC_EXPRESSION_MEMBERS(ExpressionName, srcAName, srcBName) \
208 using Expression = ExpressionTypes<value_type, SrcAType, SrcBType>; \
209 using SrcAStorageInfoType = std::invoke_result_t<decltype (&std::remove_cvref_t<SrcAType>::getStorageInfo), SrcAType>; \
210 using SrcBStorageInfoType = std::invoke_result_t<decltype (&std::remove_cvref_t<SrcBType>::getStorageInfo), SrcBType>; \
214 const CombinedStorageInfo<std::remove_cvref_t<SrcAStorageInfoType>, std::remove_cvref_t<SrcBStorageInfoType>> storageInfo; \
217 template <class SrcA, class SrcB> \
218 constexpr ExpressionName (SrcA&& a, SrcB&& b) \
219 : srcAName (std::forward<SrcA> (a)), \
220 srcBName (std::forward<SrcB> (b)), \
221 storageInfo (srcAName.getStorageInfo(), srcBName.getStorageInfo()) \
224 constexpr const auto& getStorageInfo() const { return storageInfo; } \
226 constexpr size_t size() const { return srcAName.size(); } \
228 constexpr bool isNotAliased (const void* dst) const \
230 if constexpr (is::expression<SrcAType> && is::anyVctr<SrcBType>) \
232 return dst != srcBName.data(); \
235 if constexpr (is::anyVctr<SrcAType> && is::expression<SrcBType>) \
237 return dst != srcAName.data(); \
257#define VCTR_COMMON_BINARY_SINGLE_VEC_EXPRESSION_MEMBERS(ExpressionName, srcVecName, srcSingleName) \
259 using Expression = ExpressionTypes<value_type, SrcType>; \
261 SrcType srcVecName; \
262 typename Expression::CommonSrcElement::Type srcSingleName; \
263 const typename Expression::SSESrc srcSingleName##AsSSE; \
264 const typename Expression::NeonSrc srcSingleName##AsNeon; \
267 template <class Src> \
268 constexpr ExpressionName (typename Expression::CommonSrcElement::Type a, Src&& b) \
269 : srcVecName (std::forward<Src> (b)), \
271 srcSingleName##AsSSE (Expression::SSESrc::broadcast (a)), \
272 srcSingleName##AsNeon (Expression::NeonSrc::broadcast (a)) \
275 constexpr const auto& getStorageInfo() const { return srcVecName.getStorageInfo(); } \
277 constexpr size_t size() const { return srcVecName.size(); } \
278 constexpr bool isNotAliased (const void* other) const { return srcVecName.isNotAliased (other); }
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:162
Constrains a type to represent a complex valued floating point number (e.g.
Definition: NumericTypeConcepts.h:83
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:79
The main namespace of the VCTR project.
Definition: Array.h:24
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
PlatformVectorOps::IntelIPP< typename CommonElement::Type > IPP
The PlatformVectorOps::IntelIPP type for the common element type.
Definition: ExpressionTemplate.h:117
static constexpr auto allElementTypesSame
Indicates if all source element types and the return types are same.
Definition: ExpressionTemplate.h:80
PlatformVectorOps::AppleAccelerate< typename CommonElement::Type > Accelerate
The PlatformVectorOps::AppleAccelerate type for the common element type.
Definition: ExpressionTemplate.h:114
The base class to every expression template.
Definition: ExpressionTemplate.h:37
Definition: NeonRegister.h:28
Definition: SSERegister.h:28