Skip to content

Commit c5cca10

Browse files
Move swizzle masks compile-time tests to test
There is no need to run those at every compilation step
1 parent ef4a389 commit c5cca10

File tree

2 files changed

+48
-37
lines changed

2 files changed

+48
-37
lines changed

include/xsimd/arch/common/xsimd_common_swizzle.hpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -166,43 +166,6 @@ namespace xsimd
166166
XSIMD_INLINE constexpr bool is_cross_lane(batch_constant<T, A, Vs...>) noexcept { return detail::is_cross_lane<Vs...>(); }
167167
template <typename T, class A, T... Vs>
168168
XSIMD_INLINE constexpr bool no_duplicates(batch_constant<T, A, Vs...>) noexcept { return no_duplicates_impl<0, sizeof...(Vs), T, Vs...>(); }
169-
// ────────────────────────────────────────────────────────────────────────
170-
// compile-time tests (identity, all-different, dup-lo, dup-hi)
171-
// 8-lane identity
172-
static_assert(is_identity<std::uint32_t, 0, 1, 2, 3, 4, 5, 6, 7>(), "identity failed");
173-
// 8-lane reverse is all-different but not identity
174-
static_assert(is_all_different<std::uint32_t, 7, 6, 5, 4, 3, 2, 1, 0>(), "all-diff failed");
175-
static_assert(!is_identity<std::uint32_t, 7, 6, 5, 4, 3, 2, 1, 0>(), "identity on reverse");
176-
// 8-lane dup-lo (repeat 0..3 twice)
177-
static_assert(is_dup_lo<std::uint32_t, 0, 1, 2, 3, 0, 1, 2, 3>(), "dup_lo failed");
178-
static_assert(!is_dup_hi<std::uint32_t, 0, 1, 2, 3, 0, 1, 2, 3>(), "dup_hi on dup_lo");
179-
// 8-lane dup-hi (repeat 4..7 twice)
180-
static_assert(is_dup_hi<std::uint32_t, 4, 5, 6, 7, 4, 5, 6, 7>(), "dup_hi failed");
181-
static_assert(!is_dup_lo<std::uint32_t, 4, 5, 6, 7, 4, 5, 6, 7>(), "dup_lo on dup_hi");
182-
// ────────────────────────────────────────────────────────────────────────
183-
// 4-lane identity
184-
static_assert(is_identity<std::uint32_t, 0, 1, 2, 3>(), "4-lane identity failed");
185-
// 4-lane reverse all-different but not identity
186-
static_assert(is_all_different<std::uint32_t, 3, 2, 1, 0>(), "4-lane all-diff failed");
187-
static_assert(!is_identity<std::uint32_t, 3, 2, 1, 0>(), "4-lane identity on reverse");
188-
// 4-lane dup-lo (repeat 0..1 twice)
189-
static_assert(is_dup_lo<std::uint32_t, 0, 1, 0, 1>(), "4-lane dup_lo failed");
190-
static_assert(!is_dup_hi<std::uint32_t, 0, 1, 0, 1>(), "4-lane dup_hi on dup_lo");
191-
// 4-lane dup-hi (repeat 2..3 twice)
192-
static_assert(is_dup_hi<std::uint32_t, 2, 3, 2, 3>(), "4-lane dup_hi failed");
193-
static_assert(!is_dup_lo<std::uint32_t, 2, 3, 2, 3>(), "4-lane dup_lo on dup_hi");
194-
195-
static_assert(is_cross_lane<0, 1, 0, 1>(), "dup-lo only → crossing");
196-
static_assert(is_cross_lane<2, 3, 2, 3>(), "dup-hi only → crossing");
197-
static_assert(is_cross_lane<0, 3, 3, 3>(), "one low + rest high → crossing");
198-
static_assert(!is_cross_lane<1, 0, 2, 3>(), "mixed low/high → no crossing");
199-
static_assert(!is_cross_lane<0, 1, 2, 3>(), "mixed low/high → no crossing");
200-
201-
static_assert(no_duplicates_v<0, 1, 2, 3>(), "N=4: [0,1,2,3] → distinct");
202-
static_assert(!no_duplicates_v<0, 1, 2, 2>(), "N=4: [0,1,2,2] → dup");
203-
204-
static_assert(no_duplicates_v<0, 1, 2, 3, 4, 5, 6, 7>(), "N=8: [0..7] → distinct");
205-
static_assert(!no_duplicates_v<0, 1, 2, 3, 4, 5, 6, 0>(), "N=8: last repeats 0");
206169

207170
} // namespace detail
208171
} // namespace kernel

test/test_batch_manip.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,54 @@
1515

1616
#include "test_utils.hpp"
1717

18+
// Compile time tests for include/xsimd/arch/common/xsimd_common_swizzle.hpp
19+
namespace xsimd
20+
{
21+
namespace kernel
22+
{
23+
namespace detail
24+
{
25+
// ────────────────────────────────────────────────────────────────────────
26+
// compile-time tests (identity, all-different, dup-lo, dup-hi)
27+
// 8-lane identity
28+
static_assert(is_identity<std::uint32_t, 0, 1, 2, 3, 4, 5, 6, 7>(), "identity failed");
29+
// 8-lane reverse is all-different but not identity
30+
static_assert(is_all_different<std::uint32_t, 7, 6, 5, 4, 3, 2, 1, 0>(), "all-diff failed");
31+
static_assert(!is_identity<std::uint32_t, 7, 6, 5, 4, 3, 2, 1, 0>(), "identity on reverse");
32+
// 8-lane dup-lo (repeat 0..3 twice)
33+
static_assert(is_dup_lo<std::uint32_t, 0, 1, 2, 3, 0, 1, 2, 3>(), "dup_lo failed");
34+
static_assert(!is_dup_hi<std::uint32_t, 0, 1, 2, 3, 0, 1, 2, 3>(), "dup_hi on dup_lo");
35+
// 8-lane dup-hi (repeat 4..7 twice)
36+
static_assert(is_dup_hi<std::uint32_t, 4, 5, 6, 7, 4, 5, 6, 7>(), "dup_hi failed");
37+
static_assert(!is_dup_lo<std::uint32_t, 4, 5, 6, 7, 4, 5, 6, 7>(), "dup_lo on dup_hi");
38+
// ────────────────────────────────────────────────────────────────────────
39+
// 4-lane identity
40+
static_assert(is_identity<std::uint32_t, 0, 1, 2, 3>(), "4-lane identity failed");
41+
// 4-lane reverse all-different but not identity
42+
static_assert(is_all_different<std::uint32_t, 3, 2, 1, 0>(), "4-lane all-diff failed");
43+
static_assert(!is_identity<std::uint32_t, 3, 2, 1, 0>(), "4-lane identity on reverse");
44+
// 4-lane dup-lo (repeat 0..1 twice)
45+
static_assert(is_dup_lo<std::uint32_t, 0, 1, 0, 1>(), "4-lane dup_lo failed");
46+
static_assert(!is_dup_hi<std::uint32_t, 0, 1, 0, 1>(), "4-lane dup_hi on dup_lo");
47+
// 4-lane dup-hi (repeat 2..3 twice)
48+
static_assert(is_dup_hi<std::uint32_t, 2, 3, 2, 3>(), "4-lane dup_hi failed");
49+
static_assert(!is_dup_lo<std::uint32_t, 2, 3, 2, 3>(), "4-lane dup_lo on dup_hi");
50+
51+
static_assert(is_cross_lane<0, 1, 0, 1>(), "dup-lo only → crossing");
52+
static_assert(is_cross_lane<2, 3, 2, 3>(), "dup-hi only → crossing");
53+
static_assert(is_cross_lane<0, 3, 3, 3>(), "one low + rest high → crossing");
54+
static_assert(!is_cross_lane<1, 0, 2, 3>(), "mixed low/high → no crossing");
55+
static_assert(!is_cross_lane<0, 1, 2, 3>(), "mixed low/high → no crossing");
56+
57+
static_assert(no_duplicates_v<0, 1, 2, 3>(), "N=4: [0,1,2,3] → distinct");
58+
static_assert(!no_duplicates_v<0, 1, 2, 2>(), "N=4: [0,1,2,2] → dup");
59+
60+
static_assert(no_duplicates_v<0, 1, 2, 3, 4, 5, 6, 7>(), "N=8: [0..7] → distinct");
61+
static_assert(!no_duplicates_v<0, 1, 2, 3, 4, 5, 6, 0>(), "N=8: last repeats 0");
62+
}
63+
}
64+
}
65+
1866
namespace xsimd
1967
{
2068
template <template <class> class Pattern, class Vec>

0 commit comments

Comments
 (0)