Skip to content

Commit 66200cd

Browse files
committed
Replace Vc with std::simd
1 parent f2755e7 commit 66200cd

File tree

18 files changed

+52
-331
lines changed

18 files changed

+52
-331
lines changed

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

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

math/genvector/inc/Math/GenVector/DisplacementVector3D.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ namespace ROOT {
660660
{
661661
if (os) {
662662
os << "{ ";
663-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
663+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
664664
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
665665
}
666666
os << "}";

math/genvector/inc/Math/GenVector/PositionVector3D.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ namespace ROOT {
616616
{
617617
if (os) {
618618
os << "{ ";
619-
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::Size; ++i) {
619+
for (std::size_t i = 0; i < PositionVector3D<T, U>::Scalar::size(); ++i) {
620620
os << "(" << v.x()[i] << "," << v.y()[i] << "," << v.z()[i] << ") ";
621621
}
622622
os << "}";

math/mathcore/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@ if(runtime_cxxmodules)
104104
# 'abs' shadow declaration (from stl math.h) is broken.
105105
# FIXME: Revise after a llvm upgrade or reproduce it outside rootcling.
106106
list(REMOVE_ITEM HEADERS "Math/Math.h")
107-
108-
if(vc)
109-
# We do not link against libVc.a thus it makes no sense to check for
110-
# version compatibility between libraries and header files. This fixes
111-
# ROOT-11002 where upon building the modules.idx we run the static ctor
112-
# runLibraryAbiCheck which fails to find the corresponding symbol.
113-
set(dictoptions "-m" "Vc" "-mByproduct" "Vc" "-D" "Vc_NO_VERSION_CHECK")
114-
endif(vc)
115107
endif()
116108

117109
ROOT_ADD_C_FLAG(_flags -Wno-strict-overflow) # Avoid what it seems a compiler false positive warning

math/mathcore/inc/Fit/FitUtil.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,4 @@ namespace FitUtil {
14871487

14881488
} // end namespace ROOT
14891489

1490-
#if defined (R__HAS_VECCORE) && defined(R__HAS_VC)
1491-
//Fixes alignment for structures of SIMD structures
1492-
Vc_DECLARE_ALLOCATOR(ROOT::Fit::FitUtil::LikelihoodAux<ROOT::Double_v>);
1493-
#endif
1494-
14951490
#endif /* ROOT_Fit_FitUtil */

math/mathcore/inc/Math/Types.h

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,16 @@
55

66
#ifdef R__HAS_VECCORE
77

8-
#if defined(R__HAS_VC)
9-
10-
#pragma GCC diagnostic push
11-
#pragma GCC diagnostic ignored "-Wall"
12-
#pragma GCC diagnostic ignored "-Wunused-parameter"
13-
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
14-
#if (__cplusplus >= 202002L) // only for C++20
15-
#pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
16-
#endif
17-
18-
#ifdef __clang__
19-
#pragma clang diagnostic ignored "-Wconditional-uninitialized"
20-
#pragma clang diagnostic ignored "-Wdeprecated-copy"
21-
#endif
22-
23-
#include <Vc/Vc>
24-
#pragma GCC diagnostic pop
8+
// We're using vectorization via std::simd if available.
9+
// It's available generally for newer GCC and Clang, but we have to explicilty
10+
// check for GCC >= 9 because we're still supporting AlmaLinux 8 with GCC 8.5.
11+
// For Apple, we don't even make an attempt to use it, because the Vc library
12+
// that was used before std::simd didn't even support Apple silicon.
13+
// So we always disable std::simd usage on Apple for simplicity, as this
14+
// doesn't support any regression in vectorization platform support.
15+
// TODO: remove the __GNUC__ < 9 check once the minimum supported gcc version is GCC 9.
16+
#if !defined(__APPLE__) || __GNUC__ < 9
17+
#define VECCORE_ENABLE_STD_SIMD
2518
#endif
2619

2720
#include <VecCore/VecCore>
@@ -30,12 +23,14 @@ namespace ROOT {
3023

3124
namespace Internal {
3225
using ScalarBackend = vecCore::backend::Scalar;
33-
#ifdef VECCORE_ENABLE_VC
34-
using VectorBackend = vecCore::backend::VcVector;
26+
#ifdef VECCORE_ENABLE_STD_SIMD
27+
using VectorBackend = vecCore::backend::SIMDNative;
3528
#else
3629
using VectorBackend = vecCore::backend::Scalar;
3730
#endif
3831
}
32+
#undef VECCORE_ENABLE_STD_SIMD
33+
3934
using Float_v = typename Internal::VectorBackend::Float_v;
4035
using Double_v = typename Internal::VectorBackend::Double_v;
4136
using Int_v = typename Internal::VectorBackend::Int_v;

0 commit comments

Comments
 (0)