[libcxx-commits] [libcxx] [libc++] <experimental/simd> Reduce types for template parameter U in tests (PR #83781)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Mar 25 04:57:18 PDT 2024
https://github.com/joy2myself updated https://github.com/llvm/llvm-project/pull/83781
>From 32abb85267e893338836c257fdf704ed19f5a6dd Mon Sep 17 00:00:00 2001
From: Yin Zhang <zhangyin2018 at iscas.ac.cn>
Date: Mon, 4 Mar 2024 15:31:33 +0800
Subject: [PATCH] [libc++] <experimental/simd> Reduce types for template
parameter U in tests
---
.../simd/simd.class/simd_ctor_broadcast.pass.cpp | 4 ++--
.../simd/simd.class/simd_ctor_conversion.pass.cpp | 4 ++--
.../simd/simd.class/simd_ctor_load.pass.cpp | 6 +++---
.../simd_mask_ctor_conversion.pass.cpp | 4 ++--
.../simd.reference/reference_assignment.pass.cpp | 6 +++---
libcxx/test/std/experimental/simd/test_utils.h | 12 ++++++++++++
6 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_broadcast.pass.cpp b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_broadcast.pass.cpp
index 679cb1aa167c57..8a291632a8ab1e 100644
--- a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_broadcast.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_broadcast.pass.cpp
@@ -41,7 +41,7 @@ struct CheckSimdBroadcastCtorFromVectorizedType {
std::array<T, array_size> expected_value;
std::fill(expected_value.begin(), expected_value.end(), 3);
- types::for_each(arithmetic_no_bool_types(), BroadCastHelper<T, SimdAbi, array_size>(expected_value));
+ types::for_each(simd_test_types(), BroadCastHelper<T, SimdAbi, array_size>(expected_value));
}
};
@@ -110,7 +110,7 @@ template <class T, std::size_t>
struct CheckBroadcastCtorTraits {
template <class SimdAbi>
void operator()() {
- types::for_each(arithmetic_no_bool_types(), CheckBroadcastCtorTraitsHelper<T, SimdAbi>());
+ types::for_each(simd_test_types(), CheckBroadcastCtorTraitsHelper<T, SimdAbi>());
static_assert(!has_broadcast_ctor<no_implicit_type<T>, T, SimdAbi>::value);
static_assert(has_broadcast_ctor<implicit_type<T>, T, SimdAbi>::value);
diff --git a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_conversion.pass.cpp b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_conversion.pass.cpp
index 5920d62e0e5a61..add6265d7f8940 100644
--- a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_conversion.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_conversion.pass.cpp
@@ -50,7 +50,7 @@ struct CheckConversionSimdCtor {
for (size_t i = 0; i < array_size; ++i)
expected_value[i] = static_cast<T>(i);
- types::for_each(arithmetic_no_bool_types(), ConversionHelper<T, SimdAbi, array_size>(expected_value));
+ types::for_each(simd_test_types(), ConversionHelper<T, SimdAbi, array_size>(expected_value));
}
};
@@ -74,7 +74,7 @@ struct CheckConversionSimdCtorTraits {
void operator()() {
constexpr std::size_t array_size = ex::simd_size_v<T, SimdAbi>;
- types::for_each(arithmetic_no_bool_types(), CheckConversionSimdCtorTraitsHelper<T, SimdAbi, array_size>());
+ types::for_each(simd_test_types(), CheckConversionSimdCtorTraitsHelper<T, SimdAbi, array_size>());
}
};
diff --git a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_load.pass.cpp b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_load.pass.cpp
index 3992f3e450cb2a..3f663d9c97355d 100644
--- a/libcxx/test/std/experimental/simd/simd.class/simd_ctor_load.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.class/simd_ctor_load.pass.cpp
@@ -59,9 +59,9 @@ struct CheckSimdLoadCtor {
void operator()() {
constexpr std::size_t array_size = ex::simd_size_v<T, SimdAbi>;
- types::for_each(arithmetic_no_bool_types(), ElementAlignedLoadCtorHelper<T, SimdAbi, array_size>());
- types::for_each(arithmetic_no_bool_types(), VectorAlignedLoadCtorHelper<T, SimdAbi, array_size>());
- types::for_each(arithmetic_no_bool_types(), OveralignedLoadCtorHelper<T, SimdAbi, array_size>());
+ types::for_each(simd_test_types(), ElementAlignedLoadCtorHelper<T, SimdAbi, array_size>());
+ types::for_each(simd_test_types(), VectorAlignedLoadCtorHelper<T, SimdAbi, array_size>());
+ types::for_each(simd_test_types(), OveralignedLoadCtorHelper<T, SimdAbi, array_size>());
}
};
diff --git a/libcxx/test/std/experimental/simd/simd.mask.class/simd_mask_ctor_conversion.pass.cpp b/libcxx/test/std/experimental/simd/simd.mask.class/simd_mask_ctor_conversion.pass.cpp
index dc0764f937fc04..7910b2cc252204 100644
--- a/libcxx/test/std/experimental/simd/simd.mask.class/simd_mask_ctor_conversion.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.mask.class/simd_mask_ctor_conversion.pass.cpp
@@ -42,7 +42,7 @@ struct CheckConversionMaskCtor {
constexpr std::size_t array_size = ex::simd_size_v<T, SimdAbi>;
std::array<bool, array_size> expected_value{};
- types::for_each(arithmetic_no_bool_types(), ConversionHelper<T, SimdAbi, array_size>(expected_value));
+ types::for_each(simd_test_types(), ConversionHelper<T, SimdAbi, array_size>(expected_value));
}
};
@@ -65,7 +65,7 @@ struct CheckConversionMaskCtorTraits {
void operator()() {
constexpr std::size_t array_size = ex::simd_size_v<T, SimdAbi>;
- types::for_each(arithmetic_no_bool_types(), CheckConversionMaskCtorTraitsHelper<T, SimdAbi, array_size>());
+ types::for_each(simd_test_types(), CheckConversionMaskCtorTraitsHelper<T, SimdAbi, array_size>());
}
};
diff --git a/libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp b/libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp
index cfef55a868ba01..013adb36859352 100644
--- a/libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp
+++ b/libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp
@@ -72,10 +72,10 @@ template <class T, std::size_t>
struct CheckReferenceAssignment {
template <class SimdAbi>
void operator()() {
- types::for_each(arithmetic_no_bool_types(), CheckSimdReferenceAssignmentHelper<T, SimdAbi>());
- types::for_each(arithmetic_no_bool_types(), CheckMaskReferenceAssignmentHelper<T, SimdAbi>());
+ types::for_each(simd_test_types(), CheckSimdReferenceAssignmentHelper<T, SimdAbi>());
+ types::for_each(simd_test_types(), CheckMaskReferenceAssignmentHelper<T, SimdAbi>());
- types::for_each(arithmetic_no_bool_types(), CheckReferenceAssignmentTraitsHelper<T, SimdAbi>());
+ types::for_each(simd_test_types(), CheckReferenceAssignmentTraitsHelper<T, SimdAbi>());
}
};
diff --git a/libcxx/test/std/experimental/simd/test_utils.h b/libcxx/test/std/experimental/simd/test_utils.h
index b3679b51e50b50..9b441608575138 100644
--- a/libcxx/test/std/experimental/simd/test_utils.h
+++ b/libcxx/test/std/experimental/simd/test_utils.h
@@ -48,6 +48,18 @@ using arithmetic_no_bool_types = types::concatenate_t<types::integer_types, type
using arithmetic_no_bool_types = types::concatenate_t<types::integer_types, types::floating_point_types>;
#endif
+// For interfaces with vectorizable type template parameters, we only use some common or boundary types
+// as template parameters for testing to ensure that the compilation time of a single test does not exceed.
+using simd_test_types =
+ types::type_list<char,
+ unsigned,
+ int,
+#ifndef TEST_HAS_NO_INT128
+ __int128_t,
+#endif
+ float,
+ double>;
+
template <template <class T, std::size_t N> class Func>
void test_all_simd_abi() {
types::for_each(arithmetic_no_bool_types(), TestAllSimdAbiFunctor<Func>());
More information about the libcxx-commits
mailing list