VecCore 0.8.1
C++ Library for Portable SIMD Vectorization
Loading...
Searching...
No Matches
SIMDSizes.h
Go to the documentation of this file.
1#ifndef VECCORE_SIMD_SIZES_H
2#define VECCORE_SIMD_SIZES_H
3
4namespace vecCore {
5
6// traits to choose a default vector size depending on the architecture
7// TODO: this has to be completed for types and architectures
8// TODO: we may replace this by calculating from compiler types ( if this is compiler-portable )
9template <typename T>
10constexpr size_t SIMDWidth()
11{
12 return 1;
13}
14#ifdef __AVX512__
15template <>
16constexpr size_t SIMDWidth<double>()
17{
18 return 8;
19}
20template <>
21constexpr size_t SIMDWidth<float>()
22{
23 return 16;
24}
25template <>
26constexpr size_t SIMDWidth<uint32_t>()
27{
28 return 16;
29}
30template <>
31constexpr size_t SIMDWidth<Int32_s>()
32{
33 return 16;
34}
35template <>
36constexpr size_t SIMDWidth<uint16_t>()
37{
38 return 32;
39}
40template <>
41constexpr size_t SIMDWidth<Int16_s>()
42{
43 return 32;
44}
45#elif __AVX2__
46template <>
47constexpr size_t SIMDWidth<double>()
48{
49 return 4;
50}
51template <>
52constexpr size_t SIMDWidth<float>()
53{
54 return 8;
55}
56template <>
57constexpr size_t SIMDWidth<uint32_t>()
58{
59 return 8;
60}
61template <>
62constexpr size_t SIMDWidth<Int32_s>()
63{
64 return 8;
65}
66template <>
67constexpr size_t SIMDWidth<uint16_t>()
68{
69 return 16;
70}
71template <>
72constexpr size_t SIMDWidth<Int16_s>()
73{
74 return 16;
75}
76#elif __AVX__
77template <>
78constexpr size_t SIMDWidth<double>()
79{
80 return 4;
81}
82template <>
83constexpr size_t SIMDWidth<float>()
84{
85 return 8;
86}
87template <>
88constexpr size_t SIMDWidth<uint32_t>()
89{
90 return 4;
91}
92template <>
93constexpr size_t SIMDWidth<Int32_s>()
94{
95 return 4;
96}
97template <>
98constexpr size_t SIMDWidth<uint16_t>()
99{
100 return 16;
101}
102template <>
103constexpr size_t SIMDWidth<Int16_s>()
104{
105 return 16;
106}
107#elif __SSE__
108template <>
109constexpr size_t SIMDWidth<double>()
110{
111 return 2;
112}
113template <>
114constexpr size_t SIMDWidth<float>()
115{
116 return 4;
117}
118template <>
119constexpr size_t SIMDWidth<uint32_t>()
120{
121 return 4;
122}
123template <>
124constexpr size_t SIMDWidth<Int32_s>()
125{
126 return 4;
127}
128template <>
129constexpr size_t SIMDWidth<uint16_t>()
130{
131 return 8;
132}
133template <>
134constexpr size_t SIMDWidth<Int16_s>()
135{
136 return 8;
137}
138#endif
139}
140
141#endif
constexpr size_t SIMDWidth()
Definition: SIMDSizes.h:10