Skip to content

Commit e80055d

Browse files
committed
add batch_bool kernel::load with requires_arch<avx512f>
1 parent 5e8a090 commit e80055d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

include/xsimd/arch/generic/xsimd_generic_memory.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@ namespace xsimd
260260
return buffer[i];
261261
}
262262

263+
// load
264+
template <class A, class T>
265+
XSIMD_INLINE batch_bool<T, A> load(bool const* mem, batch_bool<T, A>, requires_arch<generic>) noexcept
266+
{
267+
using batch_type = batch<T, A>;
268+
batch_type ref(0);
269+
constexpr auto size = batch_bool<T, A>::size;
270+
alignas(A::alignment()) T buffer[size];
271+
for (std::size_t i = 0; i < size; ++i)
272+
buffer[i] = mem[i] ? 1 : 0;
273+
return ref != batch_type::load_aligned(&buffer[0]);
274+
}
275+
263276
// load_aligned
264277
namespace detail
265278
{

include/xsimd/arch/xsimd_avx512f.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,19 @@ namespace xsimd
11931193
return detail::compare_int_avx512f<A, T, _MM_CMPINT_LE>(self, other);
11941194
}
11951195

1196+
// load
1197+
template <class A, class T>
1198+
XSIMD_INLINE batch_bool<T, A> load(bool const* mem, batch_bool<T, A>, requires_arch<avx512f>) noexcept
1199+
{
1200+
using register_type = typename batch_bool<T, A>::register_type;
1201+
constexpr auto size = batch_bool<T, A>::size;
1202+
register_type mask = 0;
1203+
for (std::size_t i = 0; i < size; ++i)
1204+
mask |= (register_type(mem[i] ? 1 : 0) << i);
1205+
1206+
return mask;
1207+
}
1208+
11961209
// load_aligned
11971210
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
11981211
XSIMD_INLINE batch<T, A> load_aligned(T const* mem, convert<T>, requires_arch<avx512f>) noexcept

include/xsimd/types/xsimd_batch.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -968,11 +968,7 @@ namespace xsimd
968968
template <class T, class A>
969969
XSIMD_INLINE batch_bool<T, A> batch_bool<T, A>::load_aligned(bool const* mem) noexcept
970970
{
971-
batch_type ref(0);
972-
alignas(A::alignment()) T buffer[size];
973-
for (std::size_t i = 0; i < size; ++i)
974-
buffer[i] = mem[i] ? 1 : 0;
975-
return ref != batch_type::load_aligned(&buffer[0]);
971+
return kernel::load<A>(mem, batch_bool<T, A>(), A {});
976972
}
977973

978974
template <class T, class A>

0 commit comments

Comments
 (0)