VCTR
Loading...
Searching...
No Matches
SIMDFilter.h
1/*
2 ==============================================================================
3 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
5 Copyright 2022- by sonible GmbH.
6
7 This file is part of VCTR - Versatile Container Templates Reconceptualized.
8
9 VCTR is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License version 3
11 only, as published by the Free Software Foundation.
12
13 VCTR is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License version 3 for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 version 3 along with VCTR. If not, see <https://www.gnu.org/licenses/>.
20 ==============================================================================
21*/
22
23namespace vctr::expressions
24{
25
26template <size_t extent, class SrcType>
28{
29public:
30 using value_type = ValueType<SrcType>;
31
32 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (SSEFilter, src)
33
34 VCTR_FORCEDINLINE constexpr value_type operator[] (size_t i) const
35 {
36 return src[i];
37 }
38
39 //==============================================================================
40 VCTR_FORCEDINLINE VCTR_TARGET ("sse4.1") SSERegister<value_type> getSSE (size_t i) const
41 requires (archX64 && has::getSSE<SrcType>)
42 {
43 return src.getSSE (i);
44 }
45};
46
47template <size_t extent, class SrcType>
49{
50public:
51 using value_type = ValueType<SrcType>;
52
53 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (AVXFilter, src)
54
55 VCTR_FORCEDINLINE constexpr value_type operator[] (size_t i) const
56 {
57 return src[i];
58 }
59
60 //==============================================================================
61 VCTR_FORCEDINLINE VCTR_TARGET ("avx") AVXRegister<value_type> getAVX (size_t i) const
63 {
64 return src.getAVX (i);
65 }
66
67 VCTR_FORCEDINLINE VCTR_TARGET ("avx2") AVXRegister<value_type> getAVX (size_t i) const
69 {
70 return src.getAVX (i);
71 }
72};
73
74template <size_t extent, class SrcType>
76{
77public:
78 using value_type = ValueType<SrcType>;
79
80 VCTR_COMMON_UNARY_EXPRESSION_MEMBERS (NeonFilter, src)
81
82 VCTR_FORCEDINLINE constexpr value_type operator[] (size_t i) const
83 {
84 return src[i];
85 }
86
87 //==============================================================================
88 NeonRegister<value_type> getNeon (size_t i) const
89 requires (archARM && has::getNeon<SrcType>)
90 {
91 return src.getNeon (i);
92 }
93};
94
95} // namespace vctr::expressions
96
97namespace vctr
98{
99
107
115
123
124#if VCTR_ARM
125constexpr inline ExpressionChainBuilder<expressions::NeonFilter> useNeonOrAVX;
126constexpr inline ExpressionChainBuilder<expressions::NeonFilter> useNeonOrSSE;
127#else
128constexpr inline ExpressionChainBuilder<expressions::AVXFilter> useNeonOrAVX;
129constexpr inline ExpressionChainBuilder<expressions::SSEFilter> useNeonOrSSE;
130#endif
131} // namespace vctr
Definition: SIMDFilter.h:49
Definition: SIMDFilter.h:76
Definition: SIMDFilter.h:28
Constrains a type to have a member function getAVX (size_t) const.
Definition: ContainerAndExpressionConcepts.h:78
Constrains a type to have a member function getNeon (size_t) const.
Definition: ContainerAndExpressionConcepts.h:74
Constrains a type to have a member function getSSE (size_t) const.
Definition: ContainerAndExpressionConcepts.h:82
Constrains a type to represent a real valued floating point number.
Definition: NumericTypeConcepts.h:79
constexpr ExpressionChainBuilder< expressions::SSEFilter > useSSE
This filter expression ensures that only SSE based accelerated evaluation of the previous expression ...
Definition: SIMDFilter.h:106
constexpr ExpressionChainBuilder< expressions::AVXFilter > useAVX
This filter expression ensures that only AVX based accelerated evaluation of the previous expression ...
Definition: SIMDFilter.h:114
constexpr ExpressionChainBuilder< expressions::NeonFilter > useNeon
This filter expression ensures that only Neon based accelerated evaluation of the previous expression...
Definition: SIMDFilter.h:122
The main namespace of the VCTR project.
Definition: Array.h:24
typename detail::ValueType< std::remove_cvref_t< T > >::Type ValueType
If T is an expression template, it equals its return type, if it's a type that defines value_type as ...
Definition: Traits.h:201
Definition: AVXRegister.h:28
An expression chain builder is an object which supplies various operator<< overloads which build chai...
Definition: ExpressionChainBuilder.h:136
The base class to every expression template.
Definition: ExpressionTemplate.h:37
Definition: NeonRegister.h:28
Definition: SSERegister.h:28