[libcxx-commits] [libcxx] [libc++] Reduce the compilation time required by SIMD tests (PR #72602)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Nov 17 14:30:44 PST 2023
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/72602
>From ecb8baef66e76e0e55a7a7cb44416a03198ea32d Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 16 Nov 2023 21:40:56 -0500
Subject: [PATCH 1/5] [libc++] Reduce the compilation time required by SIMD
tests
Testing all the SIMD widths exhaustively is nice in theory, however in
practice it leads to extremely slow tests. Given that
1. our testing resources are finite and actually pretty costly
2. we have thousands of other tests we also need to run
3. the value of executing these SIMD tests for absolutely all supported
SIMD widths is fairly small compared to cherry-picking a few relevant
widths
I think it makes a lot of sense to reduce the exhaustiveness of these
tests. I'm getting a ~4x speedup for the worst offender (reference_assignment.pass.cpp)
after this patch.
I'd also like to make this a reminder to anyone seeing this PR that
tests impact everyone's productivity. Slow unit tests contribute to
making the CI slower as a whole, and that has a direct impact on
everyone's ability to iterate quickly during PRs. Even though we have
a pretty robust CI setup in place, we should remember that it doesn't
come for free and should strive to keep our tests at a good bang for
the buck ratio.
---
libcxx/test/std/experimental/simd/test_utils.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/std/experimental/simd/test_utils.h b/libcxx/test/std/experimental/simd/test_utils.h
index a478a43a87271cf..6954689d0876da7 100644
--- a/libcxx/test/std/experimental/simd/test_utils.h
+++ b/libcxx/test/std/experimental/simd/test_utils.h
@@ -28,7 +28,7 @@ struct TestAllSimdAbiFunctor {
template <class T, std::size_t... Ns>
void instantiate_with_n(std::index_sequence<Ns...>) {
- (types::for_each(sized_abis<T, Ns + 1>{}, F<T, Ns + 1>{}), ...);
+ (types::for_each(sized_abis<T, Ns>{}, F<T, Ns>{}), ...);
}
template <class T>
@@ -36,7 +36,7 @@ struct TestAllSimdAbiFunctor {
using abis = types::type_list<ex::simd_abi::scalar, ex::simd_abi::native<T>, ex::simd_abi::compatible<T>>;
types::for_each(abis{}, F<T, 1>());
- instantiate_with_n<T>(std::make_index_sequence<max_simd_size - 1>{});
+ instantiate_with_n<T>(std::index_sequence<1, 2, 8, 16, max_simd_size - 2, max_simd_size - 1, max_simd_size>{});
}
};
>From c72b11dbc8ac65d731210d038118a0a39fd2f3de Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 16 Nov 2023 22:02:33 -0500
Subject: [PATCH 2/5] Remove UNSUPPORTED annotation due to slow test
---
.../simd/simd.reference/reference_assignment.pass.cpp | 3 ---
1 file changed, 3 deletions(-)
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 bf84cc4b04e3d84..4b943689c6fdefb 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
@@ -8,9 +8,6 @@
// UNSUPPORTED: c++03, c++11, c++14
-// FIXME: Timeouts.
-// UNSUPPORTED: sanitizer-new-delete
-
// <experimental/simd>
//
// [simd.reference]
>From afa227c64986f192753bad7b1e54b8697607b56f Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 17 Nov 2023 16:24:44 -0500
Subject: [PATCH 3/5] Add coverage for SIMD widths 3 and 4
---
libcxx/test/std/experimental/simd/test_utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/std/experimental/simd/test_utils.h b/libcxx/test/std/experimental/simd/test_utils.h
index 6954689d0876da7..7d607a301bf7080 100644
--- a/libcxx/test/std/experimental/simd/test_utils.h
+++ b/libcxx/test/std/experimental/simd/test_utils.h
@@ -36,7 +36,7 @@ struct TestAllSimdAbiFunctor {
using abis = types::type_list<ex::simd_abi::scalar, ex::simd_abi::native<T>, ex::simd_abi::compatible<T>>;
types::for_each(abis{}, F<T, 1>());
- instantiate_with_n<T>(std::index_sequence<1, 2, 8, 16, max_simd_size - 2, max_simd_size - 1, max_simd_size>{});
+ instantiate_with_n<T>(std::index_sequence<1, 2, 3, 4, 8, 16, max_simd_size - 2, max_simd_size - 1, max_simd_size>{});
}
};
>From 9a366a4c32c3cea4f66a7b72d62d3fb58b627f12 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 17 Nov 2023 16:25:34 -0500
Subject: [PATCH 4/5] Remove unnecessary AIX XFAIL
---
.../simd/simd.reference/reference_assignment.pass.cpp | 2 --
1 file changed, 2 deletions(-)
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 4b943689c6fdefb..04862507535362d 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
@@ -12,8 +12,6 @@
//
// [simd.reference]
// template<class U> reference=(U&& x) && noexcept;
-//
-// XFAIL: LIBCXX-AIX-FIXME
#include "../test_utils.h"
#include <experimental/simd>
>From 7ef5a3f38c9130712a5d89d9ac56f458f401105f Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Fri, 17 Nov 2023 17:30:30 -0500
Subject: [PATCH 5/5] Fix formatting
---
libcxx/test/std/experimental/simd/test_utils.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libcxx/test/std/experimental/simd/test_utils.h b/libcxx/test/std/experimental/simd/test_utils.h
index 7d607a301bf7080..e60c7bb79d580c8 100644
--- a/libcxx/test/std/experimental/simd/test_utils.h
+++ b/libcxx/test/std/experimental/simd/test_utils.h
@@ -36,7 +36,8 @@ struct TestAllSimdAbiFunctor {
using abis = types::type_list<ex::simd_abi::scalar, ex::simd_abi::native<T>, ex::simd_abi::compatible<T>>;
types::for_each(abis{}, F<T, 1>());
- instantiate_with_n<T>(std::index_sequence<1, 2, 3, 4, 8, 16, max_simd_size - 2, max_simd_size - 1, max_simd_size>{});
+ instantiate_with_n<T>(
+ std::index_sequence<1, 2, 3, 4, 8, 16, max_simd_size - 2, max_simd_size - 1, max_simd_size>{});
}
};
More information about the libcxx-commits
mailing list