Skip to content

Commit f3a6307

Browse files
committed
[Math] Migrate from VecCore and Vc to std::experimental::simd
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.
1 parent 6c95cd0 commit f3a6307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+749
-1143
lines changed

.ci/copy_headers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set -ex
66
mkdir ../build
77
cd ../build
88
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -Dall=On -Dtesting=On -Dx11=Off -Dalien=Off \
9-
-Dcuda=Off -Dtmva-gpu=Off -Dveccore=Off ../root
9+
-Dcuda=Off -Dtmva-gpu=Off ../root
1010
# We need to prebuild a minimal set of targets which are responsible for header copy
1111
# or generation.
1212
make -j4 move_headers intrinsics_gen clang-tablegen-targets ClangDriverOptions \

.github/workflows/root-ci-config/buildconfig/global.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ builtin_openui5=ON
2424
builtin_pcre=OFF
2525
builtin_tbb=OFF
2626
builtin_unuran=OFF
27-
builtin_vc=OFF
2827
builtin_vdt=OFF
29-
builtin_veccore=OFF
3028
builtin_xrootd=OFF
3129
builtin_xxhash=OFF
3230
builtin_zeromq=ON
@@ -97,9 +95,7 @@ tmva=ON
9795
unfold=ON
9896
unuran=ON
9997
uring=OFF
100-
vc=OFF
10198
vdt=ON
102-
veccore=OFF
10399
vecgeom=OFF
104100
webgui=ON
105101
win_broken_tests=OFF

.github/workflows/root-ci-config/buildconfig/mac-beta.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ builtin_pcre=ON
1717
builtin_tbb=ON
1818
builtin_unuran=ON
1919
builtin_vdt=ON
20-
builtin_veccore=ON
2120
builtin_xrootd=ON
2221
builtin_xxhash=ON
2322
builtin_zeromq=ON

.github/workflows/root-ci-config/buildconfig/mac14.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ builtin_openssl=ON
1818
builtin_pcre=ON
1919
builtin_tbb=ON
2020
builtin_unuran=ON
21-
builtin_vc=ON
2221
builtin_vdt=ON
23-
builtin_veccore=ON
2422
builtin_xrootd=ON
2523
builtin_xxhash=ON
2624
builtin_zeromq=ON

.github/workflows/root-ci-config/buildconfig/mac15.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ builtin_pcre=ON
1616
builtin_tbb=ON
1717
builtin_unuran=ON
1818
builtin_vdt=ON
19-
builtin_veccore=ON
2019
builtin_xrootd=ON
2120
builtin_xxhash=ON
2221
builtin_zeromq=ON

.github/workflows/root-ci-config/buildconfig/mac26.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ builtin_pcre=ON
1717
builtin_tbb=ON
1818
builtin_unuran=ON
1919
builtin_vdt=ON
20-
builtin_veccore=ON
2120
builtin_xrootd=ON
2221
builtin_xxhash=ON
2322
builtin_zeromq=ON

README/ReleaseNotes/v640/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,33 @@ This change affects the following classes: `TFile`, `TMapFile`, `TMemFile`, `TD
7171

7272
## Math
7373

74+
### Migration from VecCore/Vc to `std::experimental::simd` for Vectorization
75+
76+
We have migrated the vectorized backends of **TMath** and **TFormula** from **VecCore/Vc** to `std::experimental::simd`, where available.
77+
78+
On Linux, `std::experimental::simd` is assumed to be available when ROOT is compiled with C++20 or later, which in practice corresponds to sufficiently recent GCC and Clang compilers. To keep the build system simple and robust, ROOT does not explicitly check compiler versions: users opting into C++20 are expected to use modern toolchains.
79+
80+
**Impact on Linux users**
81+
82+
ROOT builds with C++17 on Linux no longer provide vectorized TMath and TFormula.
83+
This is an intentional and accepted trade-off of the migration. These vectorized features were rarely used, while maintaining them significantly complicated the codebase and build configuration.
84+
85+
Users who rely on vectorized **TMath** or the vectorized **TFormula** backend are encouraged to build ROOT with C++20.
86+
Doing so restores vectorization through `std::experimental::simd`, providing a more robust and future-proof implementation.
87+
88+
**Windows and Apple silicon users are unaffected**
89+
90+
VecCore/Vc did not work on Windows previously, and Vc never provided production-ready support for ARM/Neon, so Apple silicon did not benefit from vectorization before this change.
91+
92+
**Build system changes**
93+
94+
As part of this migration, the following build options are deprecated. From ROOT 6.42, setting them will result in configuration errors.
95+
96+
* `vc`
97+
* `veccore`
98+
* `builtin_vc`
99+
* `builtin_veccore`
100+
74101
## RooFit
75102

76103
## RDataFrame

cmake/modules/RootBuildOptions.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ ROOT_BUILD_OPTION(builtin_pcre OFF "Build bundled copy of PCRE")
107107
ROOT_BUILD_OPTION(builtin_png OFF "Build bundled copy of libpng")
108108
ROOT_BUILD_OPTION(builtin_tbb OFF "Build TBB internally (requires network)")
109109
ROOT_BUILD_OPTION(builtin_unuran OFF "Build bundled copy of unuran")
110-
ROOT_BUILD_OPTION(builtin_vc OFF "Build Vc internally (requires network)")
111110
ROOT_BUILD_OPTION(builtin_vdt OFF "Build VDT internally (requires network)")
112-
ROOT_BUILD_OPTION(builtin_veccore OFF "Build VecCore internally (requires network)")
113111
ROOT_BUILD_OPTION(builtin_xrootd OFF "Build XRootD internally (requires network)")
114112
ROOT_BUILD_OPTION(builtin_xxhash OFF "Build bundled copy of xxHash")
115113
ROOT_BUILD_OPTION(builtin_zeromq OFF "Build ZeroMQ internally (requires network)")
@@ -180,9 +178,7 @@ ROOT_BUILD_OPTION(unfold OFF "Enable the unfold package [GPL]")
180178
ROOT_BUILD_OPTION(unuran OFF "Enable support for UNURAN (package for generating non-uniform random numbers) [GPL]")
181179
ROOT_BUILD_OPTION(uring OFF "Enable support for io_uring (requires liburing and Linux kernel >= 5.1)")
182180
ROOT_BUILD_OPTION(use_gsl_cblas ON "Use the CBLAS library from GSL instead of finding a more optimized BLAS library automatically with FindBLAS (the GSL CBLAS is less performant but more portable)")
183-
ROOT_BUILD_OPTION(vc OFF "Enable support for Vc (SIMD Vector Classes for C++)")
184181
ROOT_BUILD_OPTION(vdt ON "Enable support for VDT (fast and vectorisable mathematical functions)")
185-
ROOT_BUILD_OPTION(veccore OFF "Enable support for VecCore SIMD abstraction library")
186182
ROOT_BUILD_OPTION(vecgeom OFF "Enable support for VecGeom vectorized geometry library")
187183
ROOT_BUILD_OPTION(webgui ON "Build Web-based UI components of ROOT")
188184
ROOT_BUILD_OPTION(win_broken_tests OFF "Enable broken tests on Windows")
@@ -253,9 +249,7 @@ if(all)
253249
set(tmva-pymva_defvalue ON)
254250
set(tmva-rmva_defvalue ON)
255251
set(unuran_defvalue ON)
256-
set(vc_defvalue ON)
257252
set(vdt_defvalue ON)
258-
set(veccore_defvalue ON)
259253
set(vecgeom_defvalue ON)
260254
set(x11_defvalue ON)
261255
set(xml_defvalue ON)
@@ -295,9 +289,7 @@ if(builtin_all)
295289
set(builtin_png_defvalue ON)
296290
set(builtin_tbb_defvalue ON)
297291
# set(builtin_unuran_defvalue ON) (GPL)
298-
set(builtin_vc_defvalue ON)
299292
set(builtin_vdt_defvalue ON)
300-
set(builtin_veccore_defvalue ON)
301293
set(builtin_xrootd_defvalue ON)
302294
set(builtin_xxhash_defvalue ON)
303295
set(builtin_zeromq_defvalue ON)
@@ -415,6 +407,14 @@ if(DEFINED rpath)
415407
"") # empty line at the end to make the deprecation message more visible
416408
endif()
417409

410+
foreach(opt vc builtin_vc veccore builtin_veccore)
411+
if(${opt})
412+
message(DEPRECATION ">>> Option '${opt}' is deprecated and ignored."
413+
"ROOT now uses std::experimental::simd for the vectorized TFormula and TMath classes when available (on Linux when compiling with C++20 or higher)."
414+
"Using this option will result in configuration errors in ROOT 6.42.")
415+
endif()
416+
endforeach()
417+
418418
foreach(opt minuit2_mpi)
419419
if(${opt})
420420
message(WARNING "The option '${opt}' can only be used to minimise thread-safe functions in Minuit2. It cannot be used for Histogram/Graph fitting and for RooFit. If you want to use Minuit2 with MPI support, it is better to build Minuit2 as a standalone library.")

cmake/modules/RootConfiguration.cmake

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,15 @@ if(cocoa)
365365
else()
366366
set(hascocoa undef)
367367
endif()
368-
if(vc)
369-
set(hasvc define)
370-
else()
371-
set(hasvc undef)
372-
endif()
373368
if(vdt)
374369
set(hasvdt define)
375370
else()
376371
set(hasvdt undef)
377372
endif()
378-
if(veccore)
379-
set(hasveccore define)
373+
if(ROOT_HAVE_EXPERIMENTAL_SIMD)
374+
set(hasstdexperimentalsimd define)
380375
else()
381-
set(hasveccore undef)
376+
set(hasstdexperimentalsimd undef)
382377
endif()
383378
if(dataframe)
384379
set(hasdataframe define)

0 commit comments

Comments
 (0)