Skip to content

Commit f64bf1e

Browse files
committed
[Math] Migrate from Vc to std::simd
1 parent 96ca9a7 commit f64bf1e

File tree

27 files changed

+196
-418
lines changed

27 files changed

+196
-418
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ builtin_openui5=ON
2424
builtin_pcre=OFF
2525
builtin_tbb=OFF
2626
builtin_unuran=OFF
27-
builtin_vc=OFF
2827
builtin_vdt=OFF
2928
builtin_veccore=OFF
3029
builtin_xrootd=OFF
@@ -97,7 +96,6 @@ tmva=ON
9796
unfold=ON
9897
unuran=ON
9998
uring=OFF
100-
vc=OFF
10199
vdt=ON
102100
veccore=OFF
103101
vecgeom=OFF

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ builtin_openssl=ON
1818
builtin_pcre=ON
1919
builtin_tbb=ON
2020
builtin_unuran=ON
21-
builtin_vc=ON
2221
builtin_vdt=ON
2322
builtin_veccore=ON
2423
builtin_xrootd=ON

README/ReleaseNotes/v640/index.md

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

7272
## Math
7373

74+
### Migration from Vc to `std::simd`
75+
76+
ROOT has migrated its internal SIMD usage from **Vc** to `std::simd` where applicable.
77+
78+
This change affects:
79+
* The vectorized backend of **TFormula** and **TMath** interfaces that are available via VecCore when building ROOT with `veccore=ON`.
80+
* Users who instantiate the GenVector classes with Vc SIMD types like `Vc::double_v`. If you rely on these types, your code must be update to use `std::simd` instead.
81+
82+
* On **Windows and Apple silicon platforms**, this change has no practical impact: Vc-based SIMD via VecCore was not supported by ROOT on these platforms, and ROOT will also not try to use `std::simd` now on these platforms.
83+
84+
* TFormula and TMath attempt to use `std::simd` when compiled with **Clang** (any supported version) or **GCC ≥ 9**. On other compilers or configurations, SIMD support is disabled. This affects in particular the default compiler on RHEL/AlmaLinux 8 (GCC 8.5).
85+
86+
* As a consequence of this migration, the build options **vc** and **builtin_vc** are now deprecated and ignored. Their usage will cause CMake configuration errors starting from ROOT 6.42.
87+
7488
## RooFit
7589

7690
## RDataFrame

cmake/modules/RootBuildOptions.cmake

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ 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)")
112111
ROOT_BUILD_OPTION(builtin_veccore OFF "Build VecCore internally (requires network)")
113112
ROOT_BUILD_OPTION(builtin_xrootd OFF "Build XRootD internally (requires network)")
@@ -180,7 +179,6 @@ ROOT_BUILD_OPTION(unfold OFF "Enable the unfold package [GPL]")
180179
ROOT_BUILD_OPTION(unuran OFF "Enable support for UNURAN (package for generating non-uniform random numbers) [GPL]")
181180
ROOT_BUILD_OPTION(uring OFF "Enable support for io_uring (requires liburing and Linux kernel >= 5.1)")
182181
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++)")
184182
ROOT_BUILD_OPTION(vdt ON "Enable support for VDT (fast and vectorisable mathematical functions)")
185183
ROOT_BUILD_OPTION(veccore OFF "Enable support for VecCore SIMD abstraction library")
186184
ROOT_BUILD_OPTION(vecgeom OFF "Enable support for VecGeom vectorized geometry library")
@@ -253,7 +251,6 @@ if(all)
253251
set(tmva-pymva_defvalue ON)
254252
set(tmva-rmva_defvalue ON)
255253
set(unuran_defvalue ON)
256-
set(vc_defvalue ON)
257254
set(vdt_defvalue ON)
258255
set(veccore_defvalue ON)
259256
set(vecgeom_defvalue ON)
@@ -295,7 +292,6 @@ if(builtin_all)
295292
set(builtin_png_defvalue ON)
296293
set(builtin_tbb_defvalue ON)
297294
# set(builtin_unuran_defvalue ON) (GPL)
298-
set(builtin_vc_defvalue ON)
299295
set(builtin_vdt_defvalue ON)
300296
set(builtin_veccore_defvalue ON)
301297
set(builtin_xrootd_defvalue ON)
@@ -415,6 +411,35 @@ if(DEFINED rpath)
415411
"") # empty line at the end to make the deprecation message more visible
416412
endif()
417413

414+
foreach(opt vc builtin_vc)
415+
if(${opt})
416+
message(DEPRECATION ">>> Option '${opt}' is deprecated and ignored."
417+
"ROOT now uses std::simd for the vectorized TFormula and TMath classes when available (Clang or GCC >= 9)."
418+
"Using this option will result in configuration errors in ROOT 6.42.")
419+
endif()
420+
endforeach()
421+
422+
foreach(opt veccore builtin_veccore)
423+
# Disable VecCore if we don't support it for a given platform.
424+
# We try to give clear explanations here in all distinct cases.
425+
if(${opt})
426+
if(WIN32)
427+
message(WARNING "ROOT option '${opt}' will be disabled. Using VecCore on Windows is not supported by ROOT.")
428+
set(${opt} OFF CACHE BOOL "Disabled because VecCore is not supported on Windows." FORCE)
429+
elseif(APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
430+
message(WARNING "ROOT option '${opt}' will be disabled. We don't support using VecCore on Apple with Intel hardware anymore.")
431+
set(${opt} OFF CACHE BOOL "Disabled because VecCore is not supported on Apple with Intel hardware." FORCE)
432+
elseif(APPLE)
433+
message(WARNING "ROOT option '${opt}' will be disabled. We don't support using VecCore on Apple silicon, as std::simd is not available for Apple Clang and the old Vc backend also didn't support Apple silicon anyway.")
434+
set(${opt} OFF CACHE BOOL "Disabled because VecCore is not supported on Apple silicon." FORCE)
435+
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
436+
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
437+
message(WARNING "ROOT option '${opt}' will be disabled. GCC versions older than 9 do not provide std::simd, and the Vc backend of VecCore is not supported anymore by ROOT.")
438+
set(${opt} OFF CACHE BOOL "Disabled because VecCore is not supported on GCC < 9." FORCE)
439+
endif()
440+
endif()
441+
endforeach()
442+
418443
foreach(opt minuit2_mpi)
419444
if(${opt})
420445
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: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ 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()

cmake/modules/SearchInstalledSoftware.cmake

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,106 +1365,12 @@ if(builtin_tbb)
13651365
set(TBB_TARGET TBB)
13661366
endif()
13671367

1368-
#---Check for Vc---------------------------------------------------------------------
1369-
if(builtin_vc)
1370-
unset(Vc_FOUND)
1371-
unset(Vc_FOUND CACHE)
1372-
set(vc ON CACHE BOOL "Enabled because builtin_vc requested (${vc_description})" FORCE)
1373-
elseif(vc)
1374-
if(fail-on-missing)
1375-
find_package(Vc 1.4.4 CONFIG QUIET REQUIRED)
1376-
else()
1377-
find_package(Vc 1.4.4 CONFIG QUIET)
1378-
if(NOT Vc_FOUND)
1379-
message(STATUS "Vc library not found, support for it disabled.")
1380-
message(STATUS "Please enable the option 'builtin_vc' to build Vc internally.")
1381-
set(vc OFF CACHE BOOL "Disabled because Vc not found (${vc_description})" FORCE)
1382-
endif()
1383-
endif()
1384-
if(Vc_FOUND)
1385-
set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES ${Vc_INCLUDE_DIR})
1386-
BUILD_ROOT_INCLUDE_PATH("${Vc_INCLUDE_DIR}")
1387-
endif()
1388-
endif()
1389-
1390-
if(vc AND NOT Vc_FOUND)
1391-
ROOT_CHECK_CONNECTION_AND_DISABLE_OPTION("vc")
1392-
endif()
1393-
1394-
if(vc AND NOT Vc_FOUND)
1395-
set(Vc_VERSION "1.4.4")
1396-
set(Vc_PROJECT "Vc-${Vc_VERSION}")
1397-
set(Vc_SRC_URI "${lcgpackages}/${Vc_PROJECT}.tar.gz")
1398-
set(Vc_DESTDIR "${CMAKE_BINARY_DIR}/externals")
1399-
set(Vc_ROOTDIR "${Vc_DESTDIR}/${CMAKE_INSTALL_PREFIX}")
1400-
set(Vc_LIBNAME "${CMAKE_STATIC_LIBRARY_PREFIX}Vc${CMAKE_STATIC_LIBRARY_SUFFIX}")
1401-
set(Vc_LIBRARY "${Vc_ROOTDIR}/lib/${Vc_LIBNAME}")
1402-
1403-
ExternalProject_Add(VC
1404-
URL ${Vc_SRC_URI}
1405-
URL_HASH SHA256=5933108196be44c41613884cd56305df320263981fe6a49e648aebb3354d57f3
1406-
BUILD_IN_SOURCE 0
1407-
BUILD_BYPRODUCTS ${Vc_LIBRARY}
1408-
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
1409-
CMAKE_ARGS -G ${CMAKE_GENERATOR}
1410-
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
1411-
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
1412-
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
1413-
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
1414-
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
1415-
-DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS}
1416-
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
1417-
INSTALL_COMMAND env DESTDIR=${Vc_DESTDIR} ${CMAKE_COMMAND} --build . --target install
1418-
TIMEOUT 600
1419-
)
1420-
1421-
set(VC_TARGET Vc)
1422-
set(Vc_LIBRARIES Vc)
1423-
set(Vc_INCLUDE_DIR ${Vc_ROOTDIR}/include)
1424-
set(Vc_CMAKE_MODULES_DIR ${Vc_ROOTDIR}/lib/cmake/Vc)
1425-
1426-
add_library(VcExt STATIC IMPORTED)
1427-
set_property(TARGET VcExt PROPERTY IMPORTED_LOCATION ${Vc_LIBRARY})
1428-
add_dependencies(VcExt VC)
1429-
1430-
add_library(Vc INTERFACE)
1431-
target_include_directories(Vc SYSTEM BEFORE INTERFACE $<BUILD_INTERFACE:${Vc_INCLUDE_DIR}>)
1432-
target_link_libraries(Vc INTERFACE VcExt)
1433-
1434-
find_package_handle_standard_args(Vc
1435-
FOUND_VAR Vc_FOUND
1436-
REQUIRED_VARS Vc_INCLUDE_DIR Vc_LIBRARIES Vc_CMAKE_MODULES_DIR
1437-
VERSION_VAR Vc_VERSION)
1438-
1439-
# FIXME: This is a workaround to let ROOT find the headers at runtime if
1440-
# they are in the build directory. This is necessary until we decide how to
1441-
# treat externals with headers used by ROOT
1442-
if(NOT EXISTS ${CMAKE_BINARY_DIR}/include/Vc)
1443-
if (NOT EXISTS ${CMAKE_BINARY_DIR}/include)
1444-
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/include)
1445-
endif()
1446-
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
1447-
${Vc_INCLUDE_DIR}/Vc ${CMAKE_BINARY_DIR}/include/Vc)
1448-
endif()
1449-
# end of workaround
1450-
1451-
install(DIRECTORY ${Vc_ROOTDIR}/ DESTINATION ".")
1452-
endif()
1453-
1454-
if(Vc_FOUND)
1455-
# Missing from VcConfig.cmake
1456-
set(Vc_INCLUDE_DIRS ${Vc_INCLUDE_DIR})
1457-
endif()
1458-
14591368
#---Check for VecCore--------------------------------------------------------------------
14601369
if(builtin_veccore)
14611370
unset(VecCore_FOUND)
14621371
unset(VecCore_FOUND CACHE)
14631372
set(veccore ON CACHE BOOL "Enabled because builtin_veccore requested (${veccore_description})" FORCE)
14641373
elseif(veccore)
1465-
if(vc)
1466-
set(VecCore_COMPONENTS Vc)
1467-
endif()
14681374
if(fail-on-missing)
14691375
find_package(VecCore 0.4.2 CONFIG QUIET REQUIRED COMPONENTS ${VecCore_COMPONENTS})
14701376
else()
@@ -1521,18 +1427,6 @@ if(builtin_veccore)
15211427
target_include_directories(VecCore SYSTEM INTERFACE $<BUILD_INTERFACE:${VecCore_ROOTDIR}/include>)
15221428
add_dependencies(VecCore VECCORE)
15231429

1524-
if (Vc_FOUND)
1525-
set(VecCore_Vc_FOUND True)
1526-
set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC)
1527-
set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR})
1528-
set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES})
1529-
1530-
set(VecCore_DEFINITIONS ${VecCore_Vc_DEFINITIONS})
1531-
list(APPEND VecCore_INCLUDE_DIRS ${VecCore_Vc_INCLUDE_DIR})
1532-
set(VecCore_LIBRARIES ${VecCore_LIBRARIES} ${Vc_LIBRARIES})
1533-
target_link_libraries(VecCore INTERFACE ${Vc_LIBRARIES})
1534-
endif()
1535-
15361430
find_package_handle_standard_args(VecCore
15371431
FOUND_VAR VecCore_FOUND
15381432
REQUIRED_VARS VecCore_INCLUDE_DIRS VecCore_LIBRARIES

config/RConfigure.in

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#@hasxft@ R__HAS_XFT /**/
3838
#@hasclad@ R__HAS_CLAD /**/
3939
#@hascocoa@ R__HAS_COCOA /**/
40-
#@hasvc@ R__HAS_VC /**/
4140
#@hasvdt@ R__HAS_VDT /**/
4241
#@hasveccore@ R__HAS_VECCORE /**/
4342
#@usecxxmodules@ R__USE_CXXMODULES /**/
@@ -54,12 +53,6 @@
5453
#@use_less_includes@ R__LESS_INCLUDES /**/
5554
#define R__HARDWARE_INTERFERENCE_SIZE @hardwareinterferencesize@ /*Determined at CMake configure to be stable across all TUs*/
5655

57-
#if defined(R__HAS_VECCORE) && defined(R__HAS_VC)
58-
#ifndef VECCORE_ENABLE_VC
59-
#define VECCORE_ENABLE_VC
60-
#endif
61-
#endif
62-
6356
#@uselz4@ R__HAS_DEFAULT_LZ4 /**/
6457
#@usezlib@ R__HAS_DEFAULT_ZLIB /**/
6558
#@uselzma@ R__HAS_DEFAULT_LZMA /**/

core/clingutils/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ set(clinginclude ${CMAKE_SOURCE_DIR}/interpreter/cling/include)
116116
set(custom_modulemaps)
117117
if (runtime_cxxmodules)
118118
set(custom_modulemaps boost.modulemap tinyxml2.modulemap cuda.modulemap module.modulemap.build)
119-
if(vc)
120-
set(custom_modulemaps ${custom_modulemaps} vc.modulemap)
121-
endif()
122119

123120
# We need to override the default modulemap because instead of producing a
124121
# single std.pcm, produces hundreds of pcms. This changed with MacOSX14.4.sdk

geom/vecgeom/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
############################################################################
1111

1212
include_directories(AFTER SYSTEM ${VECGEOM_INCLUDE_DIRS})
13-
if ( Vc_FOUND )
14-
include_directories( AFTER SYSTEM ${Vc_INCLUDE_DIRS})
15-
endif()
1613

1714
ROOT_STANDARD_LIBRARY_PACKAGE(ConverterVG
1815
HEADERS

interpreter/cling/lib/Interpreter/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ set(LLVM_LINK_COMPONENTS
5858
${LLVM_TARGETS_TO_BUILD}
5959
)
6060

61-
if (vc)
62-
set(cling_vc_support ON)
63-
endif()
64-
6561
# clingInterpreter depends on Options.inc to be tablegen-ed
6662
# (target ClangDriverOptions) from in-tree builds.
6763
set(CLING_DEPENDS ClingDriverOptions)
@@ -375,10 +371,6 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h
375371
set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp
376372
APPEND PROPERTY OBJECT_DEPENDS
377373
${CMAKE_CURRENT_BINARY_DIR}/cling-compiledata.h)
378-
if(cling_vc_support)
379-
set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/CIFactory.cpp
380-
APPEND PROPERTY COMPILE_DEFINITIONS "CLING_SUPPORT_VC")
381-
endif()
382374

383375
# If LLVM is external, but Clang is builtin, we must use some files
384376
# from patched (builtin) version of LLVM

0 commit comments

Comments
 (0)