12
12
#include " xsimd/xsimd.hpp"
13
13
#ifndef XSIMD_NO_SUPPORTED_ARCHITECTURE
14
14
15
+ #include < functional>
16
+ #include < numeric>
15
17
#include < random>
16
18
17
19
#include " test_utils.hpp"
@@ -20,6 +22,7 @@ template <class B>
20
22
struct xsimd_api_test
21
23
{
22
24
using batch_type = B;
25
+ using batch_bool_type = typename B::batch_bool_type;
23
26
using value_type = typename B::value_type;
24
27
static constexpr size_t size = B::size;
25
28
using array_type = std::array<value_type, size>;
@@ -81,17 +84,17 @@ struct xsimd_api_test
81
84
82
85
void test_store ()
83
86
{
84
- test_store_impl (i8_vec, " load int8_t" );
85
- test_store_impl (ui8_vec, " load uint8_t" );
86
- test_store_impl (i16_vec, " load int16_t" );
87
- test_store_impl (ui16_vec, " load uint16_t" );
88
- test_store_impl (i32_vec, " load int32_t" );
89
- test_store_impl (ui32_vec, " load uint32_t" );
90
- test_store_impl (i64_vec, " load int64_t" );
91
- test_store_impl (ui64_vec, " load uint64_t" );
92
- test_store_impl (f_vec, " load float" );
87
+ test_store_impl (i8_vec, " store int8_t" );
88
+ test_store_impl (ui8_vec, " store uint8_t" );
89
+ test_store_impl (i16_vec, " store int16_t" );
90
+ test_store_impl (ui16_vec, " store uint16_t" );
91
+ test_store_impl (i32_vec, " store int32_t" );
92
+ test_store_impl (ui32_vec, " store uint32_t" );
93
+ test_store_impl (i64_vec, " store int64_t" );
94
+ test_store_impl (ui64_vec, " store uint64_t" );
95
+ test_store_impl (f_vec, " store float" );
93
96
#if XSIMD_WITH_NEON64 || !XSIMD_WITH_NEON
94
- test_store_impl (d_vec, " load double" );
97
+ test_store_impl (d_vec, " store double" );
95
98
#endif
96
99
}
97
100
@@ -133,13 +136,29 @@ struct xsimd_api_test
133
136
batch_type b = batch_type::load (v.data (), xsimd::aligned_mode ());
134
137
V res (size);
135
138
139
+ bool * b_data = new bool [size];
140
+
136
141
xsimd::store_as (res.data (), b, xsimd::unaligned_mode ());
137
142
INFO (name, " unaligned" );
138
143
CHECK_VECTOR_EQ (res, v);
139
144
145
+ std::fill (b_data, b_data + size, false );
146
+ batch_bool_type bb = (b == b);
147
+ xsimd::store_as (b_data, bb, xsimd::unaligned_mode ());
148
+ INFO (name, " batch_bool unaligned" );
149
+ CHECK_UNARY (std::accumulate (b_data, b_data + size, true , std::logical_and<bool >()));
150
+
140
151
xsimd::store_as (res.data (), b, xsimd::aligned_mode ());
141
152
INFO (name, " aligned" );
142
153
CHECK_VECTOR_EQ (res, v);
154
+
155
+ std::fill (b_data, b_data + size, false );
156
+ bb = (b == b);
157
+ xsimd::store_as (b_data, bb, xsimd::aligned_mode ());
158
+ INFO (name, " batch_bool aligned" );
159
+ CHECK_UNARY (std::accumulate (b_data, b_data + size, true , std::logical_and<bool >()));
160
+
161
+ delete[] b_data;
143
162
}
144
163
145
164
template <class T >
0 commit comments