-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Math] Migrate from VecCore and Vc to std::experimental::simd
#20746
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
base: master
Are you sure you want to change the base?
Conversation
Test Results 22 files 22 suites 3d 18h 43m 25s ⏱️ Results for commit df58f47. ♻️ This comment has been updated with latest results. |
|
If ROOT is on C++20 and GCC 11 or later in all platforms, you could also consider dropping Vc/VecCore entirely and go straight for std::simd. |
f4ff179 to
b993fb2
Compare
Cool! Yes, that's the plan once we don't have to support |
b993fb2 to
8fa0a2d
Compare
470f198 to
46e5a41
Compare
vc and veccore on march=native buildstd::simd
46e5a41 to
80e05c9
Compare
std::simdstd::simd
80e05c9 to
45c9d2f
Compare
|
Actually, I don't think we should delay this migration to standard C++ features just because of the default compiler on Alma 8. I think we can automatically disable the |
std::simdstd::experimental::simd
|
If you plan to use As for platform support, I don't remember about Windows (although I think it works), but on macOS it works nicely, so I wouldn't disable unless you have specific reasons. It works well to vectorize with ARM Neon. |
|
Thank you very much for keeping this discussion going!
Yes I have to think about that, and it's a good point with the scalar fallback. I don't think we need it actually, but our users might. It depends how much the
You mean |
45c9d2f to
01de1c1
Compare
|
Ok I'm still struggling with the TFormula tests failing on some platforms, because the GCC compiled tests and Cling don't seem to agree what the size of the edit: using the "compatible" tag seems to have worked! And not that this is not a "scalar fallback", as I checked that on my laptop the widths of |
01de1c1 to
12e51c2
Compare
|
@amadio, you have any comments (besides that we can also migrate VecCore, which will happen later)? I would really appreciate your review here! |
12e51c2 to
8c4657a
Compare
|
The fixed width std::simd performs quite poorly relative to the native version, see https://github.com/root-project/veccore/blob/master/doc/backends.md#c20-simd-backend-using-stdexperimentalsimd I will review the commits and give more detailed feedback later. |
8c4657a to
e293465
Compare
|
Getting rid of Vc would be a huge quality of life improvement. It has been pretty hard to maintain and develop the core infrastructure around the current integration that we have. Please get rid of VecCore, too. |
e7c8346 to
6cded2b
Compare
std::experimental::simdstd::experimental::simd
27f02b2 to
698a6d0
Compare
I found a solution for that. I now use the native SIMD version for any compiled code, and only use the fixed-width SIMD when declaring the code generated by TFormula to the interpreter. This width is takes as the width of the native SIMD type selected by the compiled code, to ensure compatibility between compiled and interpreted code. This seems to work! The TFormula test failures that I saw on So at this point I'm done with the PR from my side, except for maybe tweaking a bit the commit history and release notes. What needs to happen next (next year) besides the eventual review by @amadio is to discuss with the ROOT team whether it's fine to do this migration, as it has a price: the vectorized TFormula and TMath features are only available with C++ 20 and with new-enough compilers. |
1a989d5 to
5ac240a
Compare
20ba415 to
a856372
Compare
Use `std::experimental::simd` for the vectorized TMath and vectorized TFormula backend if available. We assume it's available if ROOT is compiled with C++20 or later on Linux. In reality, it is avialble for new-enough Clang and GCC compilers (GCC >= 11), but it is not worth it at this point to check the compiler version explicitly, to keep things simple. People who build with C++20 are also expected to use new compilers. The fact that ROOT C++17 users lose the vectorized TMath and TFormula features is an acceptable collateral damage of this migration, as the features are rarely used and the code/build system simplification is significant. If users really relied on these niche features, they are expected to build with C++20. Windows and Apple silicon users are unaffected by this migration. The VecCore+Vc combination did not compile on Windows before anyway, and Vc does not support Apple silicon as Vc didn't support vectorization on ARM via Neon (it was [in developement](https://github.com/VcDevel/Vc?tab=readme-ov-file#vc-portable-zero-overhead-c-types-for-explicitly-data-parallel-programming) but never finished). As a result of this migration, the `vc`, `veccore`, `builtin_vc`, and `builtin_veccore` build options are deprecated. The migration also fixes this long-standing JIRA issue about failing TFormula vectorization tests, because Vc symbols could not be resolved: https://its.cern.ch/jira/browse/ROOT-10614 This was a fundamental limitation of the statically-linked Vc library, as symbols could not be looked up by the interpreter at runtime. This limitation is gone with the migration to `std::experimental::simd`. The unit test that checks if GenVector works with Vc types was changed to use `std::experimental::simd` types instead.
a856372 to
df58f47
Compare
Use
std::experimental::simdfor the vectorized TMath and vectorized TFormula backend if available. We assume it's available if ROOT is compiled with C++20 or later on Linux. In reality, it is available for new-enough Clang and GCC compilers (GCC >= 11), but it is not worth it at this point to check the compiler version explicitly, to keep things simple. People who build with C++20 are also expected to use new compilers.The fact that ROOT C++17 users lose the vectorized TMath and TFormula features is an acceptable collateral damage of this migration, as the features are rarely used and the code/build system simplification is significant. If users really relied on these niche features, they are expected to build with C++20.
Windows and Apple silicon users are unaffected by this migration. The VecCore+Vc combination did not compile on Windows before anyway, and Vc does not support Apple silicon as Vc didn't support vectorization on ARM via Neon (it was [in developement](https://github.com/VcDevel/Vc?tab=readme-ov-file#vc-portable-zero-overhead-c-types-for-explicitly-data parallel-programming) but never finished).
As a result of this migration, the
vc,veccore,builtin_vc, andbuiltin_veccorebuild options are deprecated.The migration also fixes this long-standing JIRA issue about failing TFormula vectorization tests, because Vc symbols could not be resolved: https://its.cern.ch/jira/browse/ROOT-10614 This was a fundamental limitation of the statically-linked Vc library, as symbols could not be looked up by the interpreter at runtime. This limitation is gone with the migration to
std::experimental::simd.The unit test that checks if GenVector works with Vc types was changed to use
std::experimental::simdtypes instead.