Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions include/xsimd/arch/xsimd_emulated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,15 @@ namespace xsimd
}

// set
template <class A, class T, size_t N, class... Values>
// no A parameter on either set overload: callers pass no explicit template argument, so deduction stays constrained
template <class T, size_t N, class... Values>
XSIMD_INLINE batch<T, emulated<N>> set(batch<T, emulated<N>> const&, requires_arch<emulated<N>>, Values... values) noexcept
{
static_assert(sizeof...(Values) == batch<T, emulated<N>>::size, "consistent init");
return { typename batch<T, emulated<N>>::register_type { static_cast<T>(values)... } };
}

template <class A, class T, size_t N, class... Values>
template <class T, size_t N, class... Values>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why only for this one and not the one above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I missed it. I will fix shortly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only fixed the overload my std::simd repro hit without looking around too much.

XSIMD_INLINE batch_bool<T, emulated<N>> set(batch_bool<T, emulated<N>> const&, requires_arch<emulated<N>>, Values... values) noexcept
{
static_assert(sizeof...(Values) == batch<T, emulated<N>>::size, "consistent init");
Expand Down
11 changes: 6 additions & 5 deletions include/xsimd/types/xsimd_batch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ namespace xsimd
template <class T, class A>
template <class... Ts>
XSIMD_INLINE batch<T, A>::batch(T val0, T val1, Ts... vals) noexcept
: batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<T>(vals)...))
: batch(kernel::set(batch {}, A {}, val0, val1, static_cast<T>(vals)...))
{
detail::static_check_supported_config<T, A>();
static_assert(sizeof...(Ts) + 2 == size, "The constructor requires as many arguments as batch elements.");
Expand Down Expand Up @@ -1215,7 +1215,7 @@ namespace xsimd
template <class T, class A>
template <class... Ts>
XSIMD_INLINE batch_bool<T, A>::batch_bool(bool val0, bool val1, Ts... vals) noexcept
: batch_bool(kernel::set<A>(batch_bool {}, A {}, val0, val1, static_cast<bool>(vals)...))
: batch_bool(make_register(std::index_sequence<> {}, val0, val1, static_cast<bool>(vals)...))
{
static_assert(sizeof...(Ts) + 2 == size, "The constructor requires as many arguments as batch elements.");
}
Expand Down Expand Up @@ -1387,7 +1387,8 @@ namespace xsimd
template <class... V>
XSIMD_INLINE auto batch_bool<T, A>::make_register(std::index_sequence<>, V... v) noexcept -> register_type
{
return kernel::set<A>(batch_bool<T, A>(), A {}, v...).data;
// no explicit template argument here: kernel::set<A> would instantiate unrelated register types
return kernel::set(batch_bool<T, A>(), A {}, v...).data;
}

/*******************************
Expand Down Expand Up @@ -1425,7 +1426,7 @@ namespace xsimd
template <class T, class A>
template <class... Ts>
XSIMD_INLINE batch<std::complex<T>, A>::batch(value_type val0, value_type val1, Ts... vals) noexcept
: batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<value_type>(vals)...))
: batch(kernel::set(batch {}, A {}, val0, val1, static_cast<value_type>(vals)...))
{
static_assert(sizeof...(Ts) + 2 == size, "as many arguments as batch elements");
}
Expand Down Expand Up @@ -1657,7 +1658,7 @@ namespace xsimd
template <class T, class A>
template <bool i3ec, class... Ts>
XSIMD_INLINE batch<std::complex<T>, A>::batch(xtl::xcomplex<T, T, i3ec> val0, xtl::xcomplex<T, T, i3ec> val1, Ts... vals) noexcept
: batch(kernel::set<A>(batch {}, A {}, val0, val1, static_cast<xtl::xcomplex<T, T, i3ec>>(vals)...))
: batch(kernel::set(batch {}, A {}, val0, val1, static_cast<xtl::xcomplex<T, T, i3ec>>(vals)...))
{
static_assert(sizeof...(Ts) + 2 == size, "as many arguments as batch elements");
}
Expand Down
21 changes: 21 additions & 0 deletions test/test_batch_bool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,4 +1002,25 @@ TEST_CASE_TEMPLATE("batch_bool mask hygiene", B, BATCH_TYPES)
}
}

#if XSIMD_WITH_EMULATED
TEST_CASE("emulated batch_bool construction")
{
using M = xsimd::batch_bool<float, xsimd::emulated<96>>;

M const all_true(true);
CHECK(all_true.get(0));
CHECK(all_true.get(M::size - 1));

M const lanes(true, false, true);
CHECK(lanes.get(0));
CHECK_FALSE(lanes.get(1));
CHECK(lanes.get(2));

xsimd::batch<float, xsimd::emulated<96>> const values(1.f, 2.f, 3.f);
CHECK(values.get(0) == 1.f);
CHECK(values.get(1) == 2.f);
CHECK(values.get(2) == 3.f);
}
#endif

#endif
Loading