Skip to content

Add VecCore external #497

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

Merged
merged 7 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions cmake/modules/RootBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,25 @@ ROOT_BUILD_OPTION(asimage ON "Image processing support, requires libAfterImage")
ROOT_BUILD_OPTION(astiff ON "Include tiff support in image processing")
ROOT_BUILD_OPTION(bonjour ON "Bonjour support, requires libdns_sd and/or Avahi")
ROOT_BUILD_OPTION(builtin_afterimage ON "Build included libAfterImage, or use system libAfterImage")
ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build the FITSIO library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_davix OFF "Build the Davix library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_fftw3 OFF "Build the FFTW3 library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_ftgl ON "Build included libFTGL, or use system libftgl")
ROOT_BUILD_OPTION(builtin_freetype OFF "Build included libfreetype, or use system libfreetype")
ROOT_BUILD_OPTION(builtin_ftgl ON "Build included libFTGL, or use system libftgl")
ROOT_BUILD_OPTION(builtin_gl2ps OFF "Build included libgl2ps, or use system libgl2ps")
ROOT_BUILD_OPTION(builtin_glew ON "Build included libGLEW, or use system libGLEW")
ROOT_BUILD_OPTION(builtin_openssl OFF "Build OpenSSL internally, or use system OpenSSL")
ROOT_BUILD_OPTION(builtin_pcre OFF "Build included libpcre, or use system libpcre")
ROOT_BUILD_OPTION(builtin_unuran OFF "Build included libunuran, or use system libunuran")
ROOT_BUILD_OPTION(builtin_zlib OFF "Build included libz, or use system libz")
ROOT_BUILD_OPTION(builtin_lzma OFF "Build included liblzma, or use system liblzma")
ROOT_BUILD_OPTION(builtin_davix OFF "Build the Davix library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_gsl OFF "Build the GSL library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build the FITSIO library internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_xrootd OFF "Build the XROOTD internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_llvm ON "Build the LLVM internally")
ROOT_BUILD_OPTION(builtin_lzma OFF "Build included liblzma, or use system liblzma")
ROOT_BUILD_OPTION(builtin_openssl OFF "Build OpenSSL internally, or use system OpenSSL")
ROOT_BUILD_OPTION(builtin_pcre OFF "Build included libpcre, or use system libpcre")
ROOT_BUILD_OPTION(builtin_tbb OFF "Build the TBB internally")
ROOT_BUILD_OPTION(builtin_vdt OFF "Build the VDT package internally")
ROOT_BUILD_OPTION(builtin_unuran OFF "Build included libunuran, or use system libunuran")
ROOT_BUILD_OPTION(builtin_vc OFF "Build the Vc package internally")
ROOT_BUILD_OPTION(cxx11 ON "Build using C++11 compatible mode, requires gcc > 4.7.x or clang")
ROOT_BUILD_OPTION(cxx14 OFF "Build using C++14 compatible mode, requires gcc > 4.9.x or clang")
ROOT_BUILD_OPTION(libcxx OFF "Build using libc++, requires cxx11 option (MacOS X only, for the time being)")
ROOT_BUILD_OPTION(cxxmodules "Compile with C++ modules enabled." OFF)
ROOT_BUILD_OPTION(builtin_vdt OFF "Build the VDT package internally")
ROOT_BUILD_OPTION(builtin_veccore OFF "Build VecCore internally")
ROOT_BUILD_OPTION(builtin_xrootd OFF "Build the XROOTD internally (downloading tarfile from the Web)")
ROOT_BUILD_OPTION(builtin_zlib OFF "Build included libz, or use system libz")
ROOT_BUILD_OPTION(castor ON "CASTOR support, requires libshift from CASTOR >= 1.5.2")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
ROOT_BUILD_OPTION(ccache ON "Enable ccache usage for speeding up builds")
Expand All @@ -99,6 +96,9 @@ ROOT_BUILD_OPTION(chirp ON "Chirp support (Condor remote I/O), requires libchirp
ROOT_BUILD_OPTION(cling ON "Enable new CLING C++ interpreter")
ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)")
ROOT_BUILD_OPTION(cuda OFF "Use CUDA if it is found in the system")
ROOT_BUILD_OPTION(cxx11 ON "Build using C++11 compatible mode, requires gcc > 4.7.x or clang")
ROOT_BUILD_OPTION(cxx14 OFF "Build using C++14 compatible mode, requires gcc > 4.9.x or clang")
ROOT_BUILD_OPTION(cxxmodules "Compile with C++ modules enabled." OFF)
ROOT_BUILD_OPTION(davix ON "DavIx library for HTTP/WEBDAV access")
ROOT_BUILD_OPTION(dcache ON "dCache support, requires libdcap from DESY")
ROOT_BUILD_OPTION(exceptions ON "Turn on compiler exception handling capability")
Expand All @@ -107,21 +107,22 @@ ROOT_BUILD_OPTION(fftw3 ON "Fast Fourier Transform support, requires libfftw3")
ROOT_BUILD_OPTION(fitsio ON "Read images and data from FITS files, requires cfitsio")
ROOT_BUILD_OPTION(fortran ON "Enable the Fortran components of ROOT")
set(gcctoolchain "" CACHE PATH "Path for the gcctoolchain in case not the system gcc is used to build clang/LLVM")
ROOT_BUILD_OPTION(gviz ON "Graphs visualization support, requires graphviz")
ROOT_BUILD_OPTION(gdml OFF "GDML writer and reader")
ROOT_BUILD_OPTION(geocad OFF "ROOT-CAD Interface")
ROOT_BUILD_OPTION(genvector ON "Build the new libGenVector library")
ROOT_BUILD_OPTION(geocad OFF "ROOT-CAD Interface")
ROOT_BUILD_OPTION(gfal ON "GFAL support, requires libgfal")
ROOT_BUILD_OPTION(glite ON "gLite support, requires libglite-api-wrapper v.3 from GSI (https://subversion.gsi.de/trac/dgrid/wiki)")
ROOT_BUILD_OPTION(globus OFF "Globus authentication support, requires Globus toolkit")
ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines")
ROOT_BUILD_OPTION(gsl_shared OFF "Enable linking against shared libraries for GSL (default no)")
ROOT_BUILD_OPTION(gviz ON "Graphs visualization support, requires graphviz")
ROOT_BUILD_OPTION(hdfs ON "HDFS support; requires libhdfs from HDFS >= 0.19.1")
ROOT_BUILD_OPTION(http OFF "HTTP Server support")
ROOT_BUILD_OPTION(imt ON "Implicit multi-threading support")
ROOT_BUILD_OPTION(jemalloc OFF "Using the jemalloc allocator")
ROOT_BUILD_OPTION(krb5 ON "Kerberos5 support, requires Kerberos libs")
ROOT_BUILD_OPTION(ldap ON "LDAP support, requires (Open)LDAP libs")
ROOT_BUILD_OPTION(libcxx OFF "Build using libc++, requires cxx11 option (MacOS X only, for the time being)")
ROOT_BUILD_OPTION(macos_native OFF "Disable looking for libraries, includes and binaries in locations other than a native installation (MacOS only)")
ROOT_BUILD_OPTION(mathmore ON "Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)")
ROOT_BUILD_OPTION(memstat ON "A memory statistics utility, helps to detect memory leaks")
Expand All @@ -140,12 +141,12 @@ ROOT_BUILD_OPTION(python ON "Python ROOT bindings, requires python >= 2.2")
ROOT_BUILD_OPTION(python3 OFF "Python 3 ROOT bindings, requires python >= 3.1")
ROOT_BUILD_OPTION(qt OFF "Qt graphics backend, requires libqt >= 4.8")
ROOT_BUILD_OPTION(qtgsi OFF "GSI's Qt integration, requires libqt >= 4.8")
ROOT_BUILD_OPTION(roofit OFF "Build the libRooFit advanced fitting package")
ROOT_BUILD_OPTION(root7 OFF "Build the ROOT 7 interface prototype, requires cxx14")
ROOT_BUILD_OPTION(ruby OFF "Ruby ROOT bindings, requires ruby >= 1.8")
ROOT_BUILD_OPTION(r OFF "R ROOT bindings, requires R, Rcpp and RInside")
ROOT_BUILD_OPTION(rfio ON "RFIO support, requires libshift from CASTOR >= 1.5.2")
ROOT_BUILD_OPTION(roofit OFF "Build the libRooFit advanced fitting package")
ROOT_BUILD_OPTION(root7 OFF "Build the ROOT 7 interface prototype, requires cxx14")
ROOT_BUILD_OPTION(rpath OFF "Set run-time library load path on executables and shared libraries (at installation area)")
ROOT_BUILD_OPTION(ruby OFF "Ruby ROOT bindings, requires ruby >= 1.8")
ROOT_BUILD_OPTION(sapdb ON "MaxDB/SapDB support, requires libsqlod and libsqlrte")
ROOT_BUILD_OPTION(shadowpw ON "Shadow password support")
ROOT_BUILD_OPTION(shared ON "Use shared 3rd party libraries if possible")
Expand All @@ -158,13 +159,14 @@ ROOT_BUILD_OPTION(tcmalloc OFF "Using the tcmalloc allocator")
ROOT_BUILD_OPTION(thread ON "Using thread library (cannot be disabled)")
ROOT_BUILD_OPTION(tmva ON "Build TMVA multi variate analysis library")
ROOT_BUILD_OPTION(unuran OFF "UNURAN - package for generating non-uniform random numbers")
ROOT_BUILD_OPTION(vecgeom OFF "VecGeom is a vectorized geometry library enhancing the performance of geometry navigation.")
ROOT_BUILD_OPTION(vc OFF "Vc adds a few new types for portable and intuitive SIMD programming")
ROOT_BUILD_OPTION(vdt OFF "VDT adds a set of fast and vectorisable mathematical functions")
ROOT_BUILD_OPTION(veccore OFF "VecCore SIMD abstraction library")
ROOT_BUILD_OPTION(vecgeom OFF "VecGeom is a vectorized geometry library enhancing the performance of geometry navigation.")
ROOT_BUILD_OPTION(winrtdebug OFF "Link against the Windows debug runtime library")
ROOT_BUILD_OPTION(x11 ON "X11 support")
ROOT_BUILD_OPTION(xft ON "Xft support (X11 antialiased fonts)")
ROOT_BUILD_OPTION(xml ON "XML parser interface")
ROOT_BUILD_OPTION(x11 ON "X11 support")
ROOT_BUILD_OPTION(xrootd ON "Build xrootd file server and its client (if supported)")
ROOT_BUILD_OPTION(coverage OFF "Test coverage")

Expand Down Expand Up @@ -220,8 +222,9 @@ if(builtin_all)
set(builtin_xrootd_defvalue ON)
set(builtin_llvm_defvalue ON)
set(builtin_tbb_defvalue ON)
set(builtin_vdt_defvalue ON)
set(builtin_vc_defvalue ON)
set(builtin_vdt_defvalue ON)
set(builtin_veccore_defvalue ON)
endif()

#---VC does not support yet Arm and PPC processors----------------------------------------------
Expand Down
115 changes: 106 additions & 9 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1261,29 +1261,29 @@ elseif(vc)
else()
find_package(Vc 1.3.0 CONFIG QUIET)
if(NOT Vc_FOUND)
message(STATUS "Vc library not found, support for it disabled.")
message(STATUS "Please enable the option 'builtin_vc' to build Vc internally.")
message(STATUS "Vc library not found, support for it disabled.")
message(STATUS "Please enable the option 'builtin_vc' to build Vc internally.")
set(vc OFF CACHE BOOL "" FORCE)
endif()
endif()
endif()

if(vc AND NOT Vc_FOUND)
if(vc AND NOT Vc_FOUND AND NOT (veccore OR builtin_veccore))
set(Vc_VERSION "1.3.0")
set(Vc_PROJECT "Vc-${Vc_VERSION}")
set(Vc_SRC_URI "${lcgpackages}/${Vc_PROJECT}.tar.gz")
set(Vc_SRC_MD5 "a248e904f0b1a330ad8f37ec50cbad30")
set(Vc_DESTDIR "${CMAKE_BINARY_DIR}/externals/install/${Vc_PROJECT}")
set(Vc_DESTDIR "${CMAKE_BINARY_DIR}/VC-prefix/install")
set(Vc_ROOTDIR "${Vc_DESTDIR}/${CMAKE_INSTALL_PREFIX}")
set(Vc_LIBNAME "${CMAKE_STATIC_LIBRARY_PREFIX}Vc${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(Vc_LIBRARY "${Vc_ROOTDIR}/${_LIBDIR_DEFAULT}/${Vc_LIBNAME}")

ExternalProject_Add(${Vc_PROJECT}
PREFIX externals
ExternalProject_Add(VC
URL ${Vc_SRC_URI}
URL_MD5 ${Vc_SRC_MD5}
BUILD_IN_SOURCE 0
BUILD_BYPRODUCTS ${Vc_LIBRARY}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
CMAKE_ARGS -G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
Expand All @@ -1294,9 +1294,10 @@ if(vc AND NOT Vc_FOUND)
INSTALL_COMMAND env DESTDIR=${Vc_DESTDIR} ${CMAKE_COMMAND} --build . --target install
)

set(VC_TARGET VC)
add_library(Vc STATIC IMPORTED)
set_property(TARGET Vc PROPERTY IMPORTED_LOCATION ${Vc_LIBRARY})
add_dependencies(Vc ${Vc_PROJECT})
add_dependencies(Vc VC)

set(Vc_LIBRARIES Vc)
set(Vc_INCLUDE_DIR "${Vc_ROOTDIR}/include")
Expand All @@ -1311,8 +1312,104 @@ if(vc AND NOT Vc_FOUND)
endif()

if(Vc_FOUND)
# Missing from VcConfig.cmake
set(Vc_INCLUDE_DIRS ${Vc_INCLUDE_DIR})
# Missing from VcConfig.cmake
set(Vc_INCLUDE_DIRS ${Vc_INCLUDE_DIR})
endif()

#---Check for VecCore--------------------------------------------------------------------
if(veccore AND builtin_vc)
message(WARNING "Vc is not relocatable, so 'builtin_vc' requires 'builtin_veccore' to set up Vc properly.")
set(builtin_veccore ON CACHE BOOL "" FORCE)
endif()

if(builtin_veccore)
unset(VecCore_FOUND)
unset(VecCore_FOUND CACHE)
set(veccore ON CACHE BOOL "" FORCE)
elseif(veccore)
if(vc)
set(VecCore_COMPONENTS Vc)
endif()
if(fail-on-missing)
find_package(VecCore 0.4.0 CONFIG QUIET REQUIRED COMPONENTS ${VecCore_COMPONENTS})
else()
find_package(VecCore 0.4.0 CONFIG QUIET COMPONENTS ${VecCore_COMPONENTS})
if(NOT VecCore_FOUND)
message(STATUS "VecCore not found, support for it disabled.")
message(STATUS "Please enable the option 'builtin_veccore' to build VecCore internally.")
set(veccore OFF CACHE BOOL "" FORCE)
endif()
endif()
endif()

if(veccore AND NOT VecCore_FOUND)
set(VecCore_VERSION "0.4.0")
set(VecCore_PROJECT "VecCore-${VecCore_VERSION}")
set(VecCore_SRC_URI "${lcgpackages}/${VecCore_PROJECT}.tar.gz")
set(VecCore_SRC_MD5 "c719909eaffbcc1d7a7680b25b6e5019")
set(VecCore_DESTDIR "${CMAKE_BINARY_DIR}/VECCORE-prefix/install")
set(VecCore_ROOTDIR "${VecCore_DESTDIR}/${CMAKE_INSTALL_PREFIX}")

if(builtin_vc)
set(Vc_VERSION "1.3.1") # version built by VecCore
set(Vc_LIBNAME "${CMAKE_STATIC_LIBRARY_PREFIX}Vc${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(Vc_LIBRARY "${VecCore_ROOTDIR}/lib/${Vc_LIBNAME}")
endif()

ExternalProject_Add(VECCORE
URL ${VecCore_SRC_URI}
URL_MD5 ${VecCore_SRC_MD5}
BUILD_IN_SOURCE 0
BUILD_BYPRODUCTS ${Vc_LIBRARY}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1
CMAKE_ARGS -G ${CMAKE_GENERATOR}
-DBUILD_TESTING=OFF -DBUILD_VC=${builtin_vc}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
INSTALL_COMMAND env DESTDIR=${VecCore_DESTDIR} ${CMAKE_COMMAND} --build . --target install
)

set(VECCORE_TARGET VECCORE)

if(builtin_vc)
add_library(Vc STATIC IMPORTED)
set_property(TARGET Vc PROPERTY IMPORTED_LOCATION ${Vc_LIBRARY})
add_dependencies(Vc VECCORE)

set(Vc_LIBRARIES Vc)
set(Vc_INCLUDE_DIR ${VecCore_ROOTDIR}/include)
set(Vc_INCLUDE_DIRS ${VecCore_ROOTDIR}/include)
set(Vc_CMAKE_MODULES_DIR "${VecCore_ROOTDIR}/lib/cmake/Vc")

find_package_handle_standard_args(Vc
FOUND_VAR Vc_FOUND
REQUIRED_VARS Vc_INCLUDE_DIR Vc_LIBRARIES Vc_CMAKE_MODULES_DIR
VERSION_VAR Vc_VERSION)
endif()

if (vc OR builtin_vc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amadio, it seems that if I configure with -Dbuiltin_veccore we don't get builtin_vc on, thus VECCORE_ENABLE_VC macro doesn't expanded. In turn, this leads in not being able to compile Math_vectypes.hxx.

@xvallspl and I were discussing and we can diagnose this either in the cxx file or here. Alternatively, we should just enable builtin_vc, saving time and efforts :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it such that builtin_veccore forces builtin_vc to be ON if vc is ON. However, it should be possible to use VecCore without Vc (that's the whole point of having VecCore), so I'm against forcing Vc and VecCore to be locked to be the same, or we will never be able to change the backend later to be either Scalar or UME::SIMD. The macro VECCORE_ENABLE_VC is in ${VecCore_DEFINITIONS} when the Vc backend is enabled, so targets should rely on that rather than turning it on by hand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerning ${VecCore_DEFINITIONS} I just committed a change to hide this inside Math_vectypes.h otherwise is unworkable. It means that enybody including a ROOT Math header will need to define VECCORE_ENABLE_VC of ROOT was built with Vc and VecCore enabled.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @peremato, I saw the commit and agree with you that everybody having to define it is not optimal, but the current solution is not great either, because it only works when both VecCore and Vc are enabled. We will need to fix it later to be able to use at least the UME::SIMD backend, which works much better on KNL. At some point, we should require that new developments work with both UME::SIMD and Vc, otherwise there is no point in not just using Vc directly. I think that using ${VecCore_DEFINITIONS} in combination with #cmakedefine to create a configuration header is the way to go in this case.

set(VecCore_Vc_FOUND True)
set(VecCore_Vc_DEFINITIONS -DVECCORE_ENABLE_VC)
set(VecCore_Vc_INCLUDE_DIR ${Vc_INCLUDE_DIR})
set(VecCore_Vc_LIBRARIES ${Vc_LIBRARIES})

set(VecCore_DEFINITIONS -DVECCORE_ENABLE_VC)
set(VecCore_INCLUDE_DIRS ${Vc_INCLUDE_DIR})
set(VecCore_LIBRARIES ${Vc_LIBRARIES})
endif()

set(VecCore_INCLUDE_DIRS ${VecCore_INCLUDE_DIRS} ${VecCore_ROOTDIR}/include)

find_package_handle_standard_args(VecCore
FOUND_VAR VecCore_FOUND
REQUIRED_VARS VecCore_INCLUDE_DIRS
VERSION_VAR VecCore_VERSION)

install(DIRECTORY ${VecCore_ROOTDIR}/ DESTINATION ".")
endif()

#---Check for Vdt--------------------------------------------------------------------
Expand Down
12 changes: 12 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ if(ROOT_vc_FOUND)
ROOT_ADD_TEST(test-Vc COMMAND testVc FAILREGEX "FAILED|Error in")
endif()

#--VecCore basic test------------------------------------------------------------------------------
if(ROOT_veccore_FOUND)
ROOT_EXECUTABLE(test-veccore test-veccore.cxx LIBRARIES ${VecCore_LIBRARIES} BUILTINS VECCORE)
target_compile_definitions(test-veccore PRIVATE ${VecCore_DEFINITIONS})
target_include_directories(test-veccore PRIVATE ${VecCore_INCLUDE_DIRS})
if(VecCore_Vc_FOUND)
ROOT_ADD_TEST(VecCore COMMAND test-veccore REGEX "Vc")
else()
ROOT_ADD_TEST(VecCore COMMAND test-veccore REGEX "Scalar")
endif()
endif()

#--Vc GenVector test-----------------------------------------------------------------------------------
if(ROOT_vc_FOUND)
include_directories(${Vc_INCLUDE_DIRS})
Expand Down
15 changes: 15 additions & 0 deletions test/test-veccore.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <cstdio>
#include <VecCore/VecCore>

int main(int, char **)
{
printf("VecCore available backends: Scalar ");
#ifdef VECCORE_ENABLE_UMESIMD
printf("UME::SIMD ");
#endif
#ifdef VECCORE_ENABLE_VC
printf("Vc");
#endif
printf("\n");
return 0;
}