Skip to content

Commit b3c882c

Browse files
JohanMabilleserge-sans-paille
authored andcommitted
Fixed kernel::store for booleans
1 parent 339fade commit b3c882c

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

include/xsimd/arch/generic/xsimd_generic_memory.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ namespace xsimd
514514
}
515515

516516
// store
517-
template <class T, class A>
517+
template <class A, class T>
518518
XSIMD_INLINE void store(batch_bool<T, A> const& self, bool* mem, requires_arch<generic>) noexcept
519519
{
520520
using batch_type = batch<T, A>;

test/test_api.cpp

+29-10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include "xsimd/xsimd.hpp"
1313
#ifndef XSIMD_NO_SUPPORTED_ARCHITECTURE
1414

15+
#include <functional>
16+
#include <numeric>
1517
#include <random>
1618

1719
#include "test_utils.hpp"
@@ -20,6 +22,7 @@ template <class B>
2022
struct xsimd_api_test
2123
{
2224
using batch_type = B;
25+
using batch_bool_type = typename B::batch_bool_type;
2326
using value_type = typename B::value_type;
2427
static constexpr size_t size = B::size;
2528
using array_type = std::array<value_type, size>;
@@ -81,17 +84,17 @@ struct xsimd_api_test
8184

8285
void test_store()
8386
{
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");
9396
#if XSIMD_WITH_NEON64 || !XSIMD_WITH_NEON
94-
test_store_impl(d_vec, "load double");
97+
test_store_impl(d_vec, "store double");
9598
#endif
9699
}
97100

@@ -133,13 +136,29 @@ struct xsimd_api_test
133136
batch_type b = batch_type::load(v.data(), xsimd::aligned_mode());
134137
V res(size);
135138

139+
bool* b_data = new bool[size];
140+
136141
xsimd::store_as(res.data(), b, xsimd::unaligned_mode());
137142
INFO(name, " unaligned");
138143
CHECK_VECTOR_EQ(res, v);
139144

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+
140151
xsimd::store_as(res.data(), b, xsimd::aligned_mode());
141152
INFO(name, " aligned");
142153
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;
143162
}
144163

145164
template <class T>

0 commit comments

Comments
 (0)