1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // UNSUPPORTED: c++98, c++03, c++11, c++14
11
12 // <experimental/simd>
13 //
14 // [simd.traits]
15 // template <class T> struct ex::is_simd;
16 // template <class T> inline constexpr bool ex::is_simd_v =
17 // ex::is_simd<T>::value;
18
19 #include <cstdint>
20 #include <experimental/simd>
21 #include "test_macros.h"
22
23 namespace ex = std::experimental::parallelism_v2;
24
25 struct UserType {};
26
27 static_assert(ex::is_simd<ex::native_simd<int8_t>>::value, "");
28 static_assert(ex::is_simd<ex::native_simd<int16_t>>::value, "");
29 static_assert(ex::is_simd<ex::native_simd<int32_t>>::value, "");
30 static_assert(ex::is_simd<ex::native_simd<int64_t>>::value, "");
31 static_assert(ex::is_simd<ex::native_simd<uint8_t>>::value, "");
32 static_assert(ex::is_simd<ex::native_simd<uint16_t>>::value, "");
33 static_assert(ex::is_simd<ex::native_simd<uint32_t>>::value, "");
34 static_assert(ex::is_simd<ex::native_simd<uint64_t>>::value, "");
35 static_assert(ex::is_simd<ex::native_simd<float>>::value, "");
36 static_assert(ex::is_simd<ex::native_simd<double>>::value, "");
37
38 static_assert(ex::is_simd<ex::fixed_size_simd<int8_t, 1>>::value, "");
39 static_assert(ex::is_simd<ex::fixed_size_simd<int16_t, 1>>::value, "");
40 static_assert(ex::is_simd<ex::fixed_size_simd<int32_t, 1>>::value, "");
41 static_assert(ex::is_simd<ex::fixed_size_simd<int64_t, 1>>::value, "");
42 static_assert(ex::is_simd<ex::fixed_size_simd<uint8_t, 1>>::value, "");
43 static_assert(ex::is_simd<ex::fixed_size_simd<uint16_t, 1>>::value, "");
44 static_assert(ex::is_simd<ex::fixed_size_simd<uint32_t, 1>>::value, "");
45 static_assert(ex::is_simd<ex::fixed_size_simd<uint64_t, 1>>::value, "");
46 static_assert(ex::is_simd<ex::fixed_size_simd<float, 1>>::value, "");
47 static_assert(ex::is_simd<ex::fixed_size_simd<double, 1>>::value, "");
48
49 static_assert(ex::is_simd<ex::fixed_size_simd<int8_t, 3>>::value, "");
50 static_assert(ex::is_simd<ex::fixed_size_simd<int16_t, 3>>::value, "");
51 static_assert(ex::is_simd<ex::fixed_size_simd<int32_t, 3>>::value, "");
52 static_assert(ex::is_simd<ex::fixed_size_simd<int64_t, 3>>::value, "");
53 static_assert(ex::is_simd<ex::fixed_size_simd<uint8_t, 3>>::value, "");
54 static_assert(ex::is_simd<ex::fixed_size_simd<uint16_t, 3>>::value, "");
55 static_assert(ex::is_simd<ex::fixed_size_simd<uint32_t, 3>>::value, "");
56 static_assert(ex::is_simd<ex::fixed_size_simd<uint64_t, 3>>::value, "");
57 static_assert(ex::is_simd<ex::fixed_size_simd<float, 3>>::value, "");
58 static_assert(ex::is_simd<ex::fixed_size_simd<double, 3>>::value, "");
59
60 static_assert(ex::is_simd<ex::fixed_size_simd<int8_t, 32>>::value, "");
61 static_assert(ex::is_simd<ex::fixed_size_simd<int16_t, 32>>::value, "");
62 static_assert(ex::is_simd<ex::fixed_size_simd<int32_t, 32>>::value, "");
63 static_assert(ex::is_simd<ex::fixed_size_simd<int64_t, 32>>::value, "");
64 static_assert(ex::is_simd<ex::fixed_size_simd<uint8_t, 32>>::value, "");
65 static_assert(ex::is_simd<ex::fixed_size_simd<uint16_t, 32>>::value, "");
66 static_assert(ex::is_simd<ex::fixed_size_simd<uint32_t, 32>>::value, "");
67 static_assert(ex::is_simd<ex::fixed_size_simd<uint64_t, 32>>::value, "");
68 static_assert(ex::is_simd<ex::fixed_size_simd<float, 32>>::value, "");
69 static_assert(ex::is_simd<ex::fixed_size_simd<double, 32>>::value, "");
70
71 static_assert(!ex::is_simd<void>::value, "");
72 static_assert(!ex::is_simd<int>::value, "");
73 static_assert(!ex::is_simd<float>::value, "");
74 static_assert(!ex::is_simd<ex::simd_mask<int>>::value, "");
75 static_assert(!ex::is_simd<ex::simd_mask<float>>::value, "");
76 static_assert(!ex::is_simd<UserType>::value, "");
77
78 static_assert(ex::is_simd_v<ex::native_simd<int8_t>>, "");
79 static_assert(ex::is_simd_v<ex::native_simd<int16_t>>, "");
80 static_assert(ex::is_simd_v<ex::native_simd<int32_t>>, "");
81 static_assert(ex::is_simd_v<ex::native_simd<int64_t>>, "");
82 static_assert(ex::is_simd_v<ex::native_simd<uint8_t>>, "");
83 static_assert(ex::is_simd_v<ex::native_simd<uint16_t>>, "");
84 static_assert(ex::is_simd_v<ex::native_simd<uint32_t>>, "");
85 static_assert(ex::is_simd_v<ex::native_simd<uint64_t>>, "");
86 static_assert(ex::is_simd_v<ex::native_simd<float>>, "");
87 static_assert(ex::is_simd_v<ex::native_simd<double>>, "");
88
89 static_assert(ex::is_simd_v<ex::fixed_size_simd<int8_t, 1>>, "");
90 static_assert(ex::is_simd_v<ex::fixed_size_simd<int16_t, 1>>, "");
91 static_assert(ex::is_simd_v<ex::fixed_size_simd<int32_t, 1>>, "");
92 static_assert(ex::is_simd_v<ex::fixed_size_simd<int64_t, 1>>, "");
93 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint8_t, 1>>, "");
94 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint16_t, 1>>, "");
95 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint32_t, 1>>, "");
96 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint64_t, 1>>, "");
97 static_assert(ex::is_simd_v<ex::fixed_size_simd<float, 1>>, "");
98 static_assert(ex::is_simd_v<ex::fixed_size_simd<double, 1>>, "");
99
100 static_assert(ex::is_simd_v<ex::fixed_size_simd<int8_t, 3>>, "");
101 static_assert(ex::is_simd_v<ex::fixed_size_simd<int16_t, 3>>, "");
102 static_assert(ex::is_simd_v<ex::fixed_size_simd<int32_t, 3>>, "");
103 static_assert(ex::is_simd_v<ex::fixed_size_simd<int64_t, 3>>, "");
104 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint8_t, 3>>, "");
105 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint16_t, 3>>, "");
106 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint32_t, 3>>, "");
107 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint64_t, 3>>, "");
108 static_assert(ex::is_simd_v<ex::fixed_size_simd<float, 3>>, "");
109 static_assert(ex::is_simd_v<ex::fixed_size_simd<double, 3>>, "");
110
111 static_assert(ex::is_simd_v<ex::fixed_size_simd<int8_t, 32>>, "");
112 static_assert(ex::is_simd_v<ex::fixed_size_simd<int16_t, 32>>, "");
113 static_assert(ex::is_simd_v<ex::fixed_size_simd<int32_t, 32>>, "");
114 static_assert(ex::is_simd_v<ex::fixed_size_simd<int64_t, 32>>, "");
115 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint8_t, 32>>, "");
116 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint16_t, 32>>, "");
117 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint32_t, 32>>, "");
118 static_assert(ex::is_simd_v<ex::fixed_size_simd<uint64_t, 32>>, "");
119 static_assert(ex::is_simd_v<ex::fixed_size_simd<float, 32>>, "");
120 static_assert(ex::is_simd_v<ex::fixed_size_simd<double, 32>>, "");
121
122 static_assert(!ex::is_simd_v<void>, "");
123 static_assert(!ex::is_simd_v<int>, "");
124 static_assert(!ex::is_simd_v<float>, "");
125 static_assert(!ex::is_simd_v<ex::simd_mask<int>>, "");
126 static_assert(!ex::is_simd_v<ex::simd_mask<float>>, "");
127 static_assert(!ex::is_simd_v<UserType>, "");
128
main()129 int main() {}
130