Expression Templates Library (ETL)
no_vectorization.hpp
1 //=======================================================================
2 // Copyright (c) 2014-2023 Baptiste Wicht
3 // Distributed under the terms of the MIT License.
4 // (See accompanying file LICENSE or copy at
5 // http://opensource.org/licenses/MIT)
6 //=======================================================================
7 
8 #pragma once
9 
10 namespace etl {
11 
15 template <typename T>
17  static constexpr bool vectorizable = false;
18  static constexpr size_t size = 1;
19  static constexpr size_t alignment = alignof(T);
20 
21  using intrinsic_type = T;
22 };
23 
29 struct no_vec {
33  template <typename T>
35 
39  template <typename T>
41 
47  template <typename F, typename M>
48  static inline void storeu([[maybe_unused]] F* memory, [[maybe_unused]] M value) {}
49 
55  template <typename F, typename M>
56  static inline void store([[maybe_unused]] F* memory, [[maybe_unused]] M value) {}
57 
63  template <typename F>
64  static F load([[maybe_unused]] const F* memory) {
65  return F();
66  }
67 
73  template <typename F>
74  static F loadu([[maybe_unused]] const F* memory) {
75  return F();
76  }
77 
83  template <typename F>
84  static F set([[maybe_unused]] F value) {
85  return F();
86  }
87 
93  template <typename F>
94  static F round_up([[maybe_unused]] F x) {
95  return F();
96  }
97 
104  template <typename M>
105  static M add([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
106  return M();
107  }
108 
115  template <typename M>
116  static M sub([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
117  return M();
118  }
119 
127  template <typename M>
128  static M fmadd([[maybe_unused]] M a, [[maybe_unused]] M b, [[maybe_unused]] M c) {
129  return M();
130  }
131 
138  template <typename M>
139  static M mul([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
140  return M();
141  }
142 
149  template <typename M>
150  static M div([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
151  return M();
152  }
153 
160  template <typename M>
161  static M max([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
162  return M();
163  }
164 
171  template <typename M>
172  static M min([[maybe_unused]] M lhs, [[maybe_unused]] M rhs) {
173  return M();
174  }
175 
181  template <typename M>
182  static M sqrt([[maybe_unused]] M value) {
183  return M();
184  }
185 
191  template <typename M>
192  static M minus([[maybe_unused]] M value) {
193  return M();
194  }
195 
199  template <typename M>
200  static M hadd([[maybe_unused]] M value) {
201  return M();
202  }
203 
207  template <typename T>
208  static T zero() {
209  return T();
210  }
211 };
212 
213 } //end of namespace etl
static M minus([[maybe_unused]] M value)
Compute the negative value of the input.
Definition: no_vectorization.hpp:192
static M sqrt([[maybe_unused]] M value)
Vector square root.
Definition: no_vectorization.hpp:182
static M mul([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector multiplication or lhs and rhs.
Definition: no_vectorization.hpp:139
Define traits to get vectorization information for types when no vector mode is available.
Definition: no_vectorization.hpp:16
static M min([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector minimum or lhs and rhs.
Definition: no_vectorization.hpp:172
static F round_up([[maybe_unused]] F x)
Create a vector containing the rounded up values.
Definition: no_vectorization.hpp:94
static constexpr size_t alignment
Necessary number of bytes of alignment for this type.
Definition: no_vectorization.hpp:19
static M div([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector division or lhs and rhs.
Definition: no_vectorization.hpp:150
static M fmadd([[maybe_unused]] M a, [[maybe_unused]] M b, [[maybe_unused]] M c)
Vector multiplication of a and b and add the result to c.
Definition: no_vectorization.hpp:128
Root namespace for the ETL library.
Definition: adapter.hpp:15
static F load([[maybe_unused]] const F *memory)
Aligned load a vector from memory.
Definition: no_vectorization.hpp:64
static void store([[maybe_unused]] F *memory, [[maybe_unused]] M value)
Aligned store value to memory.
Definition: no_vectorization.hpp:56
static constexpr size_t size
Numbers of elements done at once.
Definition: no_vectorization.hpp:18
static F loadu([[maybe_unused]] const F *memory)
Unaligned load a vector from memory.
Definition: no_vectorization.hpp:74
T intrinsic_type
The intrinsic type.
Definition: no_vectorization.hpp:21
static M add([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector addition or lhs and rhs.
Definition: no_vectorization.hpp:105
static M max([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector maximum or lhs and rhs.
Definition: no_vectorization.hpp:161
static T zero()
Return a vector type filled with zeroes of the correct type.
Definition: no_vectorization.hpp:208
static M sub([[maybe_unused]] M lhs, [[maybe_unused]] M rhs)
Vector subtraction or lhs and rhs.
Definition: no_vectorization.hpp:116
static constexpr bool vectorizable
Boolean flag indicating if the type is vectorizable or not.
Definition: no_vectorization.hpp:17
static M hadd([[maybe_unused]] M value)
Perform an horizontal sum of the given vector.
Definition: no_vectorization.hpp:200
typename traits< T >::intrinsic_type vec_type
The vector type for this vectorization implementation.
Definition: no_vectorization.hpp:40
Vectorization support when no vectorization is enabled.
Definition: no_vectorization.hpp:29
static void storeu([[maybe_unused]] F *memory, [[maybe_unused]] M value)
Unaligned store value to memory.
Definition: no_vectorization.hpp:48