Skip to content

Commit 1924e8d

Browse files
Reorder make_batch_constant template arguments
So that we can use a default architecture, which is consistent with other API. This is an API breaking change
1 parent d18ae2b commit 1924e8d

File tree

6 files changed

+33
-33
lines changed

6 files changed

+33
-33
lines changed

include/xsimd/arch/generic/xsimd_generic_math.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ namespace xsimd
20872087
XSIMD_INLINE T reduce(Op op, batch<T, A> const& self, std::integral_constant<unsigned, Lvl>) noexcept
20882088
{
20892089
using index_type = as_unsigned_integer_t<T>;
2090-
batch<T, A> split = swizzle(self, make_batch_constant<index_type, A, split_high<index_type, Lvl / 2>>());
2090+
batch<T, A> split = swizzle(self, make_batch_constant<index_type, split_high<index_type, Lvl / 2>, A>());
20912091
return reduce(op, op(split, self), std::integral_constant<unsigned, Lvl / 2>());
20922092
}
20932093
}

include/xsimd/arch/generic/xsimd_generic_memory.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ namespace xsimd
341341
}
342342
};
343343

344-
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, A, rotate_generator>(), A {});
344+
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, rotate_generator, A>(), A {});
345345
}
346346

347347
template <size_t N, class A, class T>
@@ -362,7 +362,7 @@ namespace xsimd
362362
}
363363
};
364364

365-
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, A, rotate_generator>(), A {});
365+
return swizzle(self, make_batch_constant<as_unsigned_integer_t<T>, rotate_generator, A>(), A {});
366366
}
367367

368368
template <size_t N, class A, class T>

include/xsimd/types/xsimd_batch_constant.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,13 @@ namespace xsimd
245245

246246
namespace detail
247247
{
248-
template <typename T, class A, class G, std::size_t... Is>
248+
template <typename T, class G, class A, std::size_t... Is>
249249
XSIMD_INLINE constexpr auto make_batch_constant(detail::index_sequence<Is...>) noexcept
250250
-> batch_constant<T, A, (T)G::get(Is, sizeof...(Is))...>
251251
{
252252
return {};
253253
}
254-
template <typename T, class A, class G, std::size_t... Is>
254+
template <typename T, class G, class A, std::size_t... Is>
255255
XSIMD_INLINE constexpr auto make_batch_bool_constant(detail::index_sequence<Is...>) noexcept
256256
-> batch_bool_constant<T, A, G::get(Is, sizeof...(Is))...>
257257
{
@@ -280,10 +280,10 @@ namespace xsimd
280280
* };
281281
* @endcode
282282
*/
283-
template <typename T, class A, class G>
284-
XSIMD_INLINE constexpr auto make_batch_constant() noexcept -> decltype(detail::make_batch_constant<T, A, G>(detail::make_index_sequence<batch<T, A>::size>()))
283+
template <typename T, class G, class A=default_arch>
284+
XSIMD_INLINE constexpr auto make_batch_constant() noexcept -> decltype(detail::make_batch_constant<T, G, A>(detail::make_index_sequence<batch<T, A>::size>()))
285285
{
286-
return detail::make_batch_constant<T, A, G>(detail::make_index_sequence<batch<T, A>::size>());
286+
return detail::make_batch_constant<T, G, A>(detail::make_index_sequence<batch<T, A>::size>());
287287
}
288288

289289
template <typename T, class A, class G>

test/test_batch_constant.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ struct constant_batch_test
4040
std::generate(expected.begin(), expected.end(),
4141
[&i]()
4242
{ return generator::get(i++, size); });
43-
constexpr auto b = xsimd::make_batch_constant<value_type, arch_type, generator>();
43+
constexpr auto b = xsimd::make_batch_constant<value_type, generator, arch_type>();
4444
INFO("batch(value_type)");
4545
CHECK_BATCH_EQ((batch_type)b, expected);
4646
}
4747

4848
void test_cast() const
4949
{
50-
constexpr auto cst_b = xsimd::make_batch_constant<value_type, arch_type, generator>();
50+
constexpr auto cst_b = xsimd::make_batch_constant<value_type, generator, arch_type>();
5151
auto b0 = cst_b.as_batch();
5252
auto b1 = (batch_type)cst_b;
5353
CHECK_BATCH_EQ(b0, b1);
@@ -69,7 +69,7 @@ struct constant_batch_test
6969
std::generate(expected.begin(), expected.end(),
7070
[&i]()
7171
{ return arange::get(i++, size); });
72-
constexpr auto b = xsimd::make_batch_constant<value_type, arch_type, arange>();
72+
constexpr auto b = xsimd::make_batch_constant<value_type, arange, arch_type>();
7373
INFO("batch(value_type)");
7474
CHECK_BATCH_EQ((batch_type)b, expected);
7575
}
@@ -87,34 +87,34 @@ struct constant_batch_test
8787
{
8888
array_type expected;
8989
std::fill(expected.begin(), expected.end(), constant<3>::get(0, 0));
90-
constexpr auto b = xsimd::make_batch_constant<value_type, arch_type, constant<3>>();
90+
constexpr auto b = xsimd::make_batch_constant<value_type, constant<3>, arch_type>();
9191
INFO("batch(value_type)");
9292
CHECK_BATCH_EQ((batch_type)b, expected);
9393
}
9494

9595
void test_ops() const
9696
{
97-
constexpr auto n12 = xsimd::make_batch_constant<value_type, arch_type, constant<12>>();
98-
constexpr auto n3 = xsimd::make_batch_constant<value_type, arch_type, constant<3>>();
97+
constexpr auto n12 = xsimd::make_batch_constant<value_type, constant<12>, arch_type>();
98+
constexpr auto n3 = xsimd::make_batch_constant<value_type, constant<3>, arch_type>();
9999

100100
constexpr auto n12_add_n3 = n12 + n3;
101-
constexpr auto n15 = xsimd::make_batch_constant<value_type, arch_type, constant<15>>();
101+
constexpr auto n15 = xsimd::make_batch_constant<value_type, constant<15>, arch_type>();
102102
static_assert(std::is_same<decltype(n12_add_n3), decltype(n15)>::value, "n12 + n3 == n15");
103103

104104
constexpr auto n12_sub_n3 = n12 - n3;
105-
constexpr auto n9 = xsimd::make_batch_constant<value_type, arch_type, constant<9>>();
105+
constexpr auto n9 = xsimd::make_batch_constant<value_type, constant<9>, arch_type>();
106106
static_assert(std::is_same<decltype(n12_sub_n3), decltype(n9)>::value, "n12 - n3 == n9");
107107

108108
constexpr auto n12_mul_n3 = n12 * n3;
109-
constexpr auto n36 = xsimd::make_batch_constant<value_type, arch_type, constant<36>>();
109+
constexpr auto n36 = xsimd::make_batch_constant<value_type, constant<36>, arch_type>();
110110
static_assert(std::is_same<decltype(n12_mul_n3), decltype(n36)>::value, "n12 * n3 == n36");
111111

112112
constexpr auto n12_div_n3 = n12 / n3;
113-
constexpr auto n4 = xsimd::make_batch_constant<value_type, arch_type, constant<4>>();
113+
constexpr auto n4 = xsimd::make_batch_constant<value_type, constant<4>, arch_type>();
114114
static_assert(std::is_same<decltype(n12_div_n3), decltype(n4)>::value, "n12 / n3 == n4");
115115

116116
constexpr auto n12_mod_n3 = n12 % n3;
117-
constexpr auto n0 = xsimd::make_batch_constant<value_type, arch_type, constant<0>>();
117+
constexpr auto n0 = xsimd::make_batch_constant<value_type, constant<0>, arch_type>();
118118
static_assert(std::is_same<decltype(n12_mod_n3), decltype(n0)>::value, "n12 % n3 == n0");
119119

120120
constexpr auto n12_land_n3 = n12 & n3;
@@ -130,11 +130,11 @@ struct constant_batch_test
130130
static_assert(std::is_same<decltype(n12_uadd), decltype(n12)>::value, "+n12 == n12");
131131

132132
constexpr auto n12_inv = ~n12;
133-
constexpr auto n12_inv_ = xsimd::make_batch_constant<value_type, arch_type, constant<(value_type)~12>>();
133+
constexpr auto n12_inv_ = xsimd::make_batch_constant<value_type, constant<(value_type)~12>, arch_type>();
134134
static_assert(std::is_same<decltype(n12_inv), decltype(n12_inv_)>::value, "~n12 == n12_inv");
135135

136136
constexpr auto n12_usub = -n12;
137-
constexpr auto n12_usub_ = xsimd::make_batch_constant<value_type, arch_type, constant<(value_type)-12>>();
137+
constexpr auto n12_usub_ = xsimd::make_batch_constant<value_type, constant<(value_type)-12>, arch_type>();
138138
static_assert(std::is_same<decltype(n12_usub), decltype(n12_usub_)>::value, "-n12 == n12_usub");
139139
}
140140
};

test/test_batch_manip.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ struct swizzle_test
187187
B b_exped = B::load_unaligned(v_exped.data());
188188

189189
using index_type = typename as_index<value_type>::type;
190-
auto index_batch = xsimd::make_batch_constant<index_type, arch_type, Reversor<index_type>>();
190+
auto index_batch = xsimd::make_batch_constant<index_type, Reversor<index_type>, arch_type>();
191191

192192
B b_res = xsimd::swizzle(b_lhs, index_batch);
193193
CHECK_BATCH_EQ(b_res, b_exped);
@@ -207,7 +207,7 @@ struct swizzle_test
207207
B b_exped = B::load_unaligned(v_exped.data());
208208

209209
using index_type = typename as_index<value_type>::type;
210-
auto index_batch = xsimd::make_batch_constant<index_type, arch_type, Last<index_type>>();
210+
auto index_batch = xsimd::make_batch_constant<index_type, Last<index_type>, arch_type>();
211211

212212
B b_res = xsimd::swizzle(b_lhs, index_batch);
213213
CHECK_BATCH_EQ(b_res, b_exped);
@@ -227,7 +227,7 @@ struct swizzle_test
227227
B b_exped = B::load_unaligned(v_exped.data());
228228

229229
using index_type = typename as_index<value_type>::type;
230-
auto index_batch = xsimd::make_batch_constant<index_type, arch_type, Dup<index_type>>();
230+
auto index_batch = xsimd::make_batch_constant<index_type, Dup<index_type>, arch_type>();
231231

232232
B b_res = xsimd::swizzle(b_lhs, index_batch);
233233
CHECK_BATCH_EQ(b_res, b_exped);

test/test_shuffle.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ struct shuffle_test
498498
};
499499

500500
INFO("no op lhs");
501-
B b_res_lhs = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, no_op_lhs_generator>());
501+
B b_res_lhs = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, no_op_lhs_generator, arch_type>());
502502
CHECK_BATCH_EQ(b_res_lhs, b_lhs);
503503

504504
struct no_op_rhs_generator
@@ -510,7 +510,7 @@ struct shuffle_test
510510
};
511511

512512
INFO("no op rhs");
513-
B b_res_rhs = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, no_op_rhs_generator>());
513+
B b_res_rhs = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, no_op_rhs_generator, arch_type>());
514514
CHECK_BATCH_EQ(b_res_rhs, b_rhs);
515515
}
516516

@@ -535,7 +535,7 @@ struct shuffle_test
535535
}
536536
B b_ref = B::load_unaligned(ref.data());
537537

538-
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, generic_generator>());
538+
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, generic_generator, arch_type>());
539539
CHECK_BATCH_EQ(b_res, b_ref);
540540
}
541541

@@ -557,7 +557,7 @@ struct shuffle_test
557557
ref[i] = (i > 2) ? lhs[0] : rhs[0];
558558
B b_ref = B::load_unaligned(ref.data());
559559

560-
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, pick_generator>());
560+
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, pick_generator, arch_type>());
561561
CHECK_BATCH_EQ(b_res, b_ref);
562562
}
563563

@@ -581,7 +581,7 @@ struct shuffle_test
581581
B b_ref = B::load_unaligned(ref.data());
582582

583583
INFO("swizzle first batch");
584-
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, swizzle_lo_generator>());
584+
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, swizzle_lo_generator, arch_type>());
585585
CHECK_BATCH_EQ(b_res, b_ref);
586586
}
587587

@@ -600,7 +600,7 @@ struct shuffle_test
600600
B b_ref = B::load_unaligned(ref.data());
601601

602602
INFO("swizzle second batch");
603-
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, swizzle_hi_generator>());
603+
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, swizzle_hi_generator, arch_type>());
604604
CHECK_BATCH_EQ(b_res, b_ref);
605605
}
606606
}
@@ -643,7 +643,7 @@ struct shuffle_test
643643
B b_ref = B::load_unaligned(ref.data());
644644

645645
INFO("select");
646-
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, select_generator>());
646+
B b_res = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, select_generator, arch_type>());
647647
CHECK_BATCH_EQ(b_res, b_ref);
648648
}
649649

@@ -666,7 +666,7 @@ struct shuffle_test
666666
B b_ref_lo = B::load_unaligned(ref_lo.data());
667667

668668
INFO("zip_lo");
669-
B b_res_lo = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, zip_lo_generator>());
669+
B b_res_lo = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, zip_lo_generator, arch_type>());
670670
CHECK_BATCH_EQ(b_res_lo, b_ref_lo);
671671

672672
struct zip_hi_generator
@@ -685,7 +685,7 @@ struct shuffle_test
685685
B b_ref_hi = B::load_unaligned(ref_hi.data());
686686

687687
INFO("zip_hi");
688-
B b_res_hi = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, arch_type, zip_hi_generator>());
688+
B b_res_hi = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, zip_hi_generator, arch_type>());
689689
CHECK_BATCH_EQ(b_res_hi, b_ref_hi);
690690
}
691691
};

0 commit comments

Comments
 (0)