SUNphi  1.0
SIMD.hpp
Go to the documentation of this file.
1 #ifndef _SIMD_HPP
2 #define _SIMD_HPP
3 
4 /// \file SIMD.hpp
5 ///
6 /// \brief Header file for Same Instruction Different Data instructions and types
7 
8 #include <cstdlib>
9 
10 #include <utility/Unused.hpp>
11 
12 namespace SUNphi
13 {
14  /// Basic alignement for AVX-512, to be generalized
15  static constexpr size_t ALIGNMENT=
16  64;
17  MAYBE_UNUSED(ALIGNMENT);
18 
19  /// Number of components of a SIMD vector of type F
20  template <typename F> // Fundamental type
21  [[ maybe_unused ]]
22  constexpr int NSIMD_COMPONENTS=
23  ALIGNMENT/sizeof(F);
24 
25  /// Check if a certain number can be the size of a SIMD vector
26  template <typename F> // Fundamental type
27  constexpr bool canBeSizeOfSIMDVector(const int size) ///< Size to be checked
28  {
29  return size>=0 and (size%NSIMD_COMPONENTS<F>)==0;
30  }
31 
32  /// Check if a certain number can be a factor of the size of a SIMD vector
33  template <typename F> // Fundamental type
34  constexpr bool canBeFactorOfSIMDVector(const int size) ///< Size to be checked
35  {
36  return size>=0 and (NSIMD_COMPONENTS<F>%size)==0;
37  }
38 }
39 
40 #endif
#define MAYBE_UNUSED(A)
Suppress the "Unused Variable" warning at any scope.
Definition: Unused.hpp:23
constexpr int NSIMD_COMPONENTS
Number of components of a SIMD vector of type F.
Definition: SIMD.hpp:22
decltype(auto) operator+(T1 &&smet1, T2 &&smet2)
Implement smet1+smet2.
Definition: Add.hpp:87