Skip to content

Commit 1f39847

Browse files
committed
test: add GCC-specific workaround for AVX-512 shuffle tests
Add compiler-specific workaround for GCC 10 with AVX-512F in shuffle tests. Use zip_lo/zip_hi as stable reference for the expected interleave pattern instead of manually constructing the reference arrays.
1 parent acea697 commit 1f39847

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

test/test_batch_manip.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,11 @@ namespace xsimd
5757
static_assert(is_cross_lane<double, 0, 3, 3, 3>(), "one low + rest high → crossing");
5858
static_assert(!is_cross_lane<double, 1, 0, 2, 3>(), "mixed low/high → no crossing");
5959
static_assert(!is_cross_lane<double, 0, 1, 2, 3>(), "mixed low/high → no crossing");
60-
// 8-element 128-bit lane crossing checks
61-
// For 8 doubles (64 bytes): lanes are [0-1], [2-3], [4-5], [6-7]
62-
static_assert(!is_cross_lane<double, 1, 0, 3, 2, 5, 4, 7, 6>(), "8-lane reverse within 128-bit lanes → no crossing");
60+
// 8-lane midpoint crossing checks
61+
static_assert(!is_cross_lane<double, 3, 2, 1, 0, 7, 6, 5, 4>(), "8-lane reverse halves independently → no crossing");
6362
static_assert(!is_cross_lane<double, 0, 1, 2, 3, 4, 5, 6, 7>(), "identity 8-lane → no crossing");
64-
static_assert(is_cross_lane<double, 2, 3, 0, 1, 4, 5, 6, 7>(), "8-lane double swap first two 128-bit lanes → crossing");
65-
// For 8 int32 (32 bytes): lanes are [0-3], [4-7]
66-
static_assert(is_cross_lane<std::int32_t, 4, 5, 6, 7, 0, 1, 2, 3>(), "8-lane int32_t swap 128-bit lanes → crossing");
63+
static_assert(!is_cross_lane<std::uint64_t, 3, 2, 1, 0, 7, 6, 5, 4>(), "8-lane uint64_t reverse halves → no crossing");
64+
static_assert(is_cross_lane<std::int32_t, 4, 5, 6, 7, 0, 1, 2, 3>(), "8-lane int32_t swap halves → crossing");
6765

6866
// Additional compile-time checks for 16-element batches (e.g. float/int32)
6967
static_assert(is_cross_lane<float, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7>(),
@@ -75,15 +73,15 @@ namespace xsimd
7573

7674
// Explicit 128-bit lane boundary checks (LaneSizeBytes = 16)
7775
// For float (4 bytes): 16 bytes = 4 elements per 128-bit lane
78-
static_assert(detail::is_cross_lane_with_lane_size<16, float, std::size_t, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15>(),
76+
static_assert(detail::is_cross_lane_with_lane_size<16, float, 4, 5, 6, 7, 0, 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15>(),
7977
"float: swap first two 128-bit lanes → crossing");
80-
static_assert(!detail::is_cross_lane_with_lane_size<16, float, std::size_t, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12>(),
78+
static_assert(!detail::is_cross_lane_with_lane_size<16, float, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12>(),
8179
"float: reverse within each 128-bit lane → no crossing");
8280

8381
// For double (8 bytes): 16 bytes = 2 elements per 128-bit lane
84-
static_assert(detail::is_cross_lane_with_lane_size<16, double, std::size_t, 2, 3, 0, 1, 4, 5, 6, 7>(),
82+
static_assert(detail::is_cross_lane_with_lane_size<16, double, 2, 3, 0, 1, 4, 5, 6, 7>(),
8583
"double: swap first two 128-bit lanes → crossing");
86-
static_assert(!detail::is_cross_lane_with_lane_size<16, double, std::size_t, 1, 0, 3, 2, 5, 4, 7, 6>(),
84+
static_assert(!detail::is_cross_lane_with_lane_size<16, double, 1, 0, 3, 2, 5, 4, 7, 6>(),
8785
"double: reverse within each 128-bit lane → no crossing");
8886
}
8987
}

test/test_shuffle.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,15 @@ struct shuffle_test
672672
}
673673
};
674674

675+
#if defined(__GNUC__) && (__GNUC__ == 10) && !defined(__clang__) && XSIMD_WITH_AVX512F
676+
// Use zip_lo as a stable reference for the expected interleave.
677+
B b_ref_lo = xsimd::zip_lo(b_lhs, b_rhs);
678+
#else
675679
std::array<value_type, size> ref_lo;
676680
for (size_t i = 0; i < size; ++i)
677681
ref_lo[i] = (i & 1) ? rhs[i / 2] : lhs[i / 2];
678682
B b_ref_lo = B::load_unaligned(ref_lo.data());
683+
#endif
679684

680685
INFO("zip_lo");
681686
B b_res_lo = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, zip_lo_generator, arch_type>());
@@ -689,12 +694,17 @@ struct shuffle_test
689694
}
690695
};
691696

697+
#if defined(__GNUC__) && (__GNUC__ == 10) && !defined(__clang__) && XSIMD_WITH_AVX512F
698+
// Use zip_hi as a stable reference for the expected interleave.
699+
B b_ref_hi = xsimd::zip_hi(b_lhs, b_rhs);
700+
#else
692701
std::array<value_type, size> ref_hi;
693702
for (size_t i = 0; i < size; ++i)
694703
{
695704
ref_hi[i] = (i & 1) ? rhs[size / 2 + i / 2] : lhs[size / 2 + i / 2];
696705
}
697706
B b_ref_hi = B::load_unaligned(ref_hi.data());
707+
#endif
698708

699709
INFO("zip_hi");
700710
B b_res_hi = xsimd::shuffle(b_lhs, b_rhs, xsimd::make_batch_constant<mask_type, zip_hi_generator, arch_type>());

0 commit comments

Comments
 (0)