auveh
Auto-vectorization helpers for C++
Loading...
Searching...
No Matches
auveh
width.hpp
Go to the documentation of this file.
1
#ifndef AUVEH_WIDTH_HPP
2
#define AUVEH_WIDTH_HPP
3
4
#if __has_include(<simd>)
5
#include <simd>
6
#else
7
#include <algorithm>
8
#include <type_traits>
9
#endif
10
16
namespace
auveh
{
17
29
template
<
typename
Type_>
30
constexpr
int
width
() {
31
#if __has_include(<simd>)
32
return
std::simd::basic_vec<Type_>::size();
33
#else
34
#if defined(__AVX512F__)
35
constexpr
int
w = 512;
36
#elif defined(__AVX2__)
37
constexpr
int
w = 256;
38
#elif defined(__AVX__)
39
constexpr
int
w = [&](){
40
if
constexpr
(std::is_integral<Type_>::value) {
41
return
128;
42
}
else
{
43
return
256;
44
}
45
}();
46
#elif defined(__SSE__)
47
constexpr
int
w = 128;
48
#elif defined(__ARM_NEON)
49
constexpr
int
w = 128;
50
#elif defined(__ARM_FEATURE_SVE)
51
// Technically SVE is variable length, but we will consider the smallest possible unit as our common denominator.
52
// Not sure how many machines will actually be created with higher lengths, anyway.
53
constexpr
int
w = 128;
54
#else
55
constexpr
int
w = 0;
56
#endif
57
return
std::max(w, 1);
58
#endif
59
}
60
61
}
62
63
#endif
auveh
Auto-vectorization helpers.
auveh::width
constexpr int width()
Definition
width.hpp:30
Generated by
1.12.0