Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add VecCore as external project
  • Loading branch information
amadio committed Apr 11, 2017
commit c3187bbad27f8aa18d1b0f6104a9b14d6e62c0af
98 changes: 97 additions & 1 deletion cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ elseif(vc)
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")
Expand Down Expand Up @@ -1316,6 +1316,102 @@ if(Vc_FOUND)
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--------------------------------------------------------------------
if(vdt OR builtin_vdt)
if(NOT builtin_vdt)
Expand Down