-
Notifications
You must be signed in to change notification settings - Fork 0
/
amlarray.h
77 lines (67 loc) · 1.46 KB
/
amlarray.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Created by af on 10.03.21.
//
class AML_TYPE_NAME(Array1) {
public:
AML_TYPE a;
};
class AML_TYPE_NAME(Array2) {
public:
AML_TYPE a[2];
};
class AML_TYPE_NAME(Array3) {
public:
AML_TYPE a[3];
};
class AML_TYPE_NAME(Array4) {
public:
#if AML_TYPE_ID == 1
AML_PREFIX(doublevec4) v{};
#elif AML_TYPE_ID == 2
AML_PREFIX(floatvec4) v{};
#endif
AML_CONSTEXPR AML_FUNCTION AML_TYPE_NAME(Array4) *add(const AML_TYPE_NAME(Array4) a) {
#if defined(__cpp_lib_is_constant_evaluated)
if (std::is_constant_evaluated()) {
v.c[0] += a.v.c[0];
v.c[1] += a.v.c[1];
v.c[2] += a.v.c[2];
v.c[3] += a.v.c[3];
return this;
}
#endif
#if defined(USE_AVX) && AML_TYPE_ID == 1 && !defined(USE_CUDA)
v.avx = _mm256_add_pd(v.avx, a.v.avx);
#elif defined(USE_SSE) && AML_TYPE_ID == 1 && !defined(USE_CUDA) // SSE2
v.sse[0] = _mm_add_pd(v.sse[0], a.v.sse[0]);
v.sse[1] = _mm_add_pd(v.sse[1], a.v.sse[1]);
#elif defined(USE_NEON) && AML_TYPE_ID == 1 && !defined(USE_CUDA)
v.neon[0] = vaddq_f64(v.neon[0], a.v.neon[0]);
v.neon[1] = vaddq_f64(v.neon[1], a.v.neon[1]);
#else
v.c[0] += a.v.c[0];
v.c[1] += a.v.c[1];
v.c[2] += a.v.c[2];
v.c[3] += a.v.c[3];
#endif
return this;
}
constexpr AML_FUNCTION auto f(int a) -> int {
return a;
}
};
class AML_TYPE_NAME(Array8) {
public:
AML_TYPE a;
};
class AML_TYPE_NAME(Array16) {
public:
AML_TYPE a;
};
template<const int size>
class AML_TYPE_NAME(ArrayN) {
public:
AML_TYPE a[size];
AML_TYPE_NAME(ArrayN)() {
}
};