-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc++] Reduce the compilation time required by SIMD tests #72602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesTesting all the SIMD widths exhaustively is nice in theory, however in practice it leads to extremely slow tests. Given that
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. Full diff: https://github.com/llvm/llvm-project/pull/72602.diff 1 Files Affected:
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>{});
}
};
|
CC @EricWF @philnik777 @joy2myself FWIW I get the following times after:
And before:
|
LGTM. I will try to improve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with comments addressed and green CI. (And great branch name BTW)
libcxx/test/std/experimental/simd/simd.reference/reference_assignment.pass.cpp
Show resolved
Hide resolved
No worries, thanks for working on SIMD! We love having a lot of test coverage, it's just that we sometimes lose track of how costly some tests can be :-) |
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
BTW. There is outdated (~1 year)
https://github.com/llvm/llvm-zorg/blob/ff329ad2df7a5f20d3d250ea52766036b6b748e8/zorg/buildbot/builders/sanitizers/buildbot_functions.sh#L356
I will try them again and let you know if they still slow.
Absolutely. I didn't realize how long the tests take until @vitalybuka pointed it out. It's really easy to miss the amount of instantiations with the generator tools we have now (they are way too nice to remove them over this little inconvenience though). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this.
This is a comment for the room, but there's a bigger problem with tests like this (than compile time).
That problem is complexity. Tests need to be correct upon inspection. There are no tests for our tests.
We need to be more discerning when writing tests.
We may have to disagree on that point. But like any tool, it's how they're used that matters. That said, testing types are one of the trickier things we have to do here. |
Testing all the SIMD widths exhaustively is nice in theory, however in practice it leads to extremely slow tests. Given that
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.