Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ builtin_lzma=ON
builtin_nlohmann=ON
builtin_pcre=ON
builtin_png=ON
builtin_tbb=ON
builtin_tiff=ON
builtin_vdt=ON
builtin_xxhash=ON
Expand Down
81 changes: 81 additions & 0 deletions builtins/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
set(ROOT_TBB_URL ${lcgpackages}/oneTBB-2021.9.0.tar.gz)
set(ROOT_TBB_HASH 1ce48f34dada7837f510735ff1172f6e2c261b09460e3bf773b49791d247d24e)

if(MSVC)
if(CMAKE_GENERATOR MATCHES Ninja)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(tbbsuffix "_debug")
endif()
else()
set(tbb_build Release)
if(winrtdebug)
set(tbb_build Debug)
set(tbbsuffix "_debug")
endif()
endif()
set(ROOT_TBB_LIBRARY ${CMAKE_BINARY_DIR}/lib/tbb12${tbbsuffix}.lib)
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries FILES_MATCHING PATTERN "tbb*.dll")
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "tbb*.lib")
else()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(tbbsuffix "_debug")
endif()
set(ROOT_TBB_LIBRARY ${CMAKE_BINARY_DIR}/lib/libtbb${tbbsuffix}${CMAKE_SHARED_LIBRARY_SUFFIX})
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "libtbb*")
endif()
if(tbb_build)
set(TBB_EXTRA_BUILD_ARGS --config ${tbb_build})
endif()

ExternalProject_Add(
BUILTIN_TBB
URL ${ROOT_TBB_URL}
URL_HASH SHA256=${ROOT_TBB_HASH}
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR}
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_BINARY_DIR}/include
-DCMAKE_INSTALL_BINDIR=${CMAKE_BINARY_DIR}/bin
-DCMAKE_INSTALL_LIBDIR=${CMAKE_BINARY_DIR}/lib
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DTBBMALLOC_BUILD=OFF
-DTBBMALLOC_PROXY_BUILD=OFF
-DTBB_ENABLE_IPO=OFF
-DTBB_STRICT=OFF
-DTBB_TEST=OFF
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${TBB_EXTRA_BUILD_ARGS}
INSTALL_COMMAND ${CMAKE_COMMAND} --install . ${TBB_EXTRA_BUILD_ARGS}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_BYPRODUCTS ${ROOT_TBB_LIBRARY}
TIMEOUT 600
)

set(ROOT_TBB_INCLUDE_DIR ${CMAKE_BINARY_DIR}/ginclude)

ExternalProject_Add_Step(
BUILTIN_TBB tbb2externals
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/tbb ${ROOT_TBB_INCLUDE_DIR}/tbb
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/oneapi ${ROOT_TBB_INCLUDE_DIR}/oneapi
DEPENDEES install
)

file(MAKE_DIRECTORY ${ROOT_TBB_INCLUDE_DIR})
add_library(TBB::tbb IMPORTED STATIC GLOBAL)
add_dependencies(TBB::tbb BUILTIN_TBB)
set_target_properties(TBB::tbb PROPERTIES
IMPORTED_LOCATION ${ROOT_TBB_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${ROOT_TBB_INCLUDE_DIR})
target_compile_definitions(TBB::tbb INTERFACE TBB_SUPPRESS_DEPRECATED_MESSAGES=1)
if(MSVC)
target_compile_definitions(TBB::tbb INTERFACE __TBB_NO_IMPLICIT_LINKAGE=1)
endif()

set(TBB_FOUND ON PARENT_SCOPE)
set(TBB_VERSION ${ROOT_TBB_VERSION} PARENT_SCOPE)
set(TBB_INCLUDE_DIRS ${ROOT_TBB_INCLUDE_DIR} PARENT_SCOPE)
set(TBB_LIBRARIES ${ROOT_TBB_LIBRARY} PARENT_SCOPE)
11 changes: 11 additions & 0 deletions cmake/modules/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,14 @@ ENDIF (CMAKE_VERSION VERSION_GREATER 2.8.2)
FIND_PACKAGE_HANDLE_STANDARD_ARGS (TBB REQUIRED_VARS TBB_ROOT_DIR
TBB_INCLUDE_DIR TBB_LIBRARY ${_TBB_MISSING_LIBRARIES}
${_TBB_FPHSA_ADDITIONAL_ARGS})

if(TBB_FOUND)
add_library(TBB::tbb IMPORTED STATIC GLOBAL)
set_target_properties(TBB::tbb PROPERTIES
IMPORTED_LOCATION ${TBB_LIBRARY}
INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIR})
target_compile_definitions(TBB::tbb INTERFACE TBB_SUPPRESS_DEPRECATED_MESSAGES=1)
if(MSVC)
target_compile_definitions(TBB::tbb INTERFACE __TBB_NO_IMPLICIT_LINKAGE=1)
endif()
endif()
70 changes: 2 additions & 68 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -935,74 +935,8 @@ if(builtin_tbb)
endif()

if(builtin_tbb)
set(tbb_url ${lcgpackages}/oneTBB-2021.9.0.tar.gz)
set(tbb_sha256 1ce48f34dada7837f510735ff1172f6e2c261b09460e3bf773b49791d247d24e)

if(MSVC)
if(CMAKE_GENERATOR MATCHES Ninja)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(tbbsuffix "_debug")
endif()
else()
set(tbb_build Release)
if(winrtdebug)
set(tbb_build Debug)
set(tbbsuffix "_debug")
endif()
endif()
set(TBB_LIBRARIES ${CMAKE_BINARY_DIR}/lib/tbb12${tbbsuffix}.lib)
set(TBB_CXXFLAGS "-D__TBB_NO_IMPLICIT_LINKAGE=1")
install(DIRECTORY ${CMAKE_BINARY_DIR}/bin/ DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT libraries FILES_MATCHING PATTERN "tbb*.dll")
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "tbb*.lib")
else()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(tbbsuffix "_debug")
endif()
set(TBB_LIBRARIES ${CMAKE_BINARY_DIR}/lib/libtbb${tbbsuffix}${CMAKE_SHARED_LIBRARY_SUFFIX})
install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries FILES_MATCHING PATTERN "libtbb*")
endif()
if(tbb_build)
set(TBB_EXTRA_BUILD_ARGS --config ${tbb_build})
endif()

ExternalProject_Add(
TBB
URL ${tbb_url}
URL_HASH SHA256=${tbb_sha256}
INSTALL_DIR ${CMAKE_BINARY_DIR}
CMAKE_ARGS -G ${CMAKE_GENERATOR}
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${ROOT_EXTERNAL_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_BINARY_DIR}/include
-DCMAKE_INSTALL_LIBDIR=${CMAKE_BINARY_DIR}/lib
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
-DTBBMALLOC_BUILD=OFF
-DTBBMALLOC_PROXY_BUILD=OFF
-DTBB_ENABLE_IPO=OFF
-DTBB_STRICT=OFF
-DTBB_TEST=OFF
BUILD_COMMAND ${CMAKE_COMMAND} --build . ${TBB_EXTRA_BUILD_ARGS}
INSTALL_COMMAND ${CMAKE_COMMAND} --install . ${TBB_EXTRA_BUILD_ARGS}
LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 LOG_INSTALL 1 LOG_OUTPUT_ON_FAILURE 1
BUILD_BYPRODUCTS ${TBB_LIBRARIES}
TIMEOUT 600
)

ExternalProject_Add_Step(
TBB tbb2externals
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/tbb ${CMAKE_BINARY_DIR}/ginclude/tbb
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/include/oneapi ${CMAKE_BINARY_DIR}/ginclude/oneapi
DEPENDEES install
)
set(TBB_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/ginclude)
set(TBB_CXXFLAGS "-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1")
# The following line is needed to generate the proper dependency with: BUILTINS TBB (in Imt)
# and generated with this syntax: add_dependencies(${library} ${${arg1}_TARGET})
set(TBB_TARGET TBB)
list(APPEND ROOT_BUILTINS BUILTIN_TBB)
add_subdirectory(builtins/tbb)
endif()

if(builtin_vdt)
Expand Down
11 changes: 3 additions & 8 deletions core/imt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ ROOT_LINKER_LIBRARY(Imt
src/TTaskGroup.cxx
DEPENDENCIES
${MULTIPROC_LIB}
BUILTINS
TBB
)

target_link_libraries(Imt PRIVATE Thread INTERFACE Core)

if(imt)
target_link_libraries(Imt PRIVATE TBB::tbb)

ROOT_GENERATE_DICTIONARY(G__Imt STAGE1
ROOT/TTaskGroup.hxx
ROOT/RTaskArena.hxx
Expand All @@ -40,8 +40,7 @@ if(imt)
Core
Thread
${MULTIPROC_LIB}
BUILTINS
TBB
TBB::tbb
)

# G__Imt.cxx is automatically added by ROOT_GENERATE_DICTIONARY()
Expand All @@ -51,10 +50,6 @@ if(imt)
src/TThreadExecutor.cxx
)

target_include_directories(Imt SYSTEM PRIVATE ${TBB_INCLUDE_DIRS})
target_link_libraries(Imt PRIVATE ${TBB_LIBRARIES})
set_target_properties(Imt PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")

ROOT_ADD_TEST_SUBDIRECTORY(test)
else()
ROOT_GENERATE_DICTIONARY(G__Imt STAGE1
Expand Down
4 changes: 0 additions & 4 deletions core/imt/src/RTaskArena.cxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Require TBB without captured exceptions
#define TBB_USE_CAPTURED_EXCEPTION 0

#include "ROOT/RTaskArena.hxx"
#include "ROpaqueTaskArena.hxx"
#include "TError.h"
Expand All @@ -13,7 +10,6 @@
#include <thread>
#include <cmath>
#include "tbb/task_arena.h"
#define TBB_PREVIEW_GLOBAL_CONTROL 1 // required for TBB versions preceding 2019_U4
#include "tbb/global_control.h"

//////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions core/imt/src/TThreadExecutor.cxx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// Require TBB without captured exceptions
#define TBB_USE_CAPTURED_EXCEPTION 0

#include "ROOT/TThreadExecutor.hxx"
#include "ROpaqueTaskArena.hxx"
#if !defined(_MSC_VER)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#endif
#include "tbb/tbb.h"
#define TBB_PREVIEW_GLOBAL_CONTROL 1 // required for TBB versions preceding 2019_U4
#include "tbb/global_control.h"
#if !defined(_MSC_VER)
#pragma GCC diagnostic pop
Expand Down
9 changes: 3 additions & 6 deletions core/imt/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

ROOT_ADD_GTEST(testTaskArena testRTaskArena.cxx LIBRARIES Imt ${TBB_LIBRARIES} FAILREGEX "" INCLUDE_DIRS ${TBB_INCLUDE_DIRS})
set_target_properties(testTaskArena PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx LIBRARIES Imt ${TBB_LIBRARIES} INCLUDE_DIRS ${TBB_INCLUDE_DIRS})
set_target_properties(testTBBGlobalControl PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
ROOT_ADD_GTEST(testEnableImt testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES} INCLUDE_DIRS ${TBB_INCLUDE_DIRS})
set_target_properties(testEnableImt PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
ROOT_ADD_GTEST(testTaskArena testRTaskArena.cxx LIBRARIES Imt TBB::tbb FAILREGEX "")
ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx LIBRARIES Imt TBB::tbb)
ROOT_ADD_GTEST(testEnableImt testEnableImt.cxx LIBRARIES Imt TBB::tbb)
1 change: 0 additions & 1 deletion core/imt/test/testTBBGlobalControl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "ROOT/TThreadExecutor.hxx"
#include "ROOT/TestSupport.hxx"
#include "gtest/gtest.h"
#define TBB_PREVIEW_GLOBAL_CONTROL 1 // required for TBB versions preceding 2019_U4
#include "tbb/global_control.h"

#ifdef R__USE_IMT
Expand Down
8 changes: 2 additions & 6 deletions core/thread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Thread
-writeEmptyRootPCM
DEPENDENCIES
Core
BUILTINS
TBB
INSTALL_OPTIONS ${installoptions}
)

Expand All @@ -77,10 +75,8 @@ target_include_directories(Thread PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
)

if((TBB_FOUND OR builtin_tbb) AND NOT MSVC)
target_include_directories(Thread PRIVATE ${TBB_INCLUDE_DIRS})
target_link_libraries(Thread PRIVATE ${TBB_LIBRARIES})
set_target_properties(Thread PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
if(TARGET TBB::tbb)
target_link_libraries(Thread PRIVATE TBB::tbb)
target_compile_definitions(Thread PUBLIC ROOT_CORE_THREAD_TBB)
endif()

Expand Down
6 changes: 4 additions & 2 deletions core/thread/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
# For the licensing terms see $ROOTSYS/LICENSE.
# For the list of contributors see $ROOTSYS/README/CREDITS.

ROOT_ADD_GTEST(testRWLock testRWLock.cxx LIBRARIES Core Thread Hist ${TBB_LIBRARIES} INCLUDE_DIRS ${TBB_INCLUDE_DIRS})
set_target_properties(testRWLock PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
ROOT_ADD_GTEST(testRWLock testRWLock.cxx LIBRARIES Core Thread Hist)
if(imt)
target_link_libraries(testRWLock PRIVATE TBB::tbb)
endif()

ROOT_ADD_GTEST(testTThreadedObject testTThreadedObject.cxx LIBRARIES Hist)

Expand Down
3 changes: 1 addition & 2 deletions roottest/root/multicore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ if(NOT MSVC AND NOT dev)
endif()

if(imt)
include_directories(${TBB_INCLUDE_DIRS})
ROOTTEST_GENERATE_EXECUTABLE(threadExecutor
tThreadExecutor.cpp
LIBRARIES Core Imt Hist MathCore
LIBRARIES Core Imt Hist MathCore TBB::tbb
FIXTURES_SETUP root-multicore-threadExecutor-fixture)

ROOTTEST_ADD_TEST(threadExecutor
Expand Down
5 changes: 1 addition & 4 deletions tmva/tmva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,7 @@ if(vdt OR builtin_vdt)
endif()

if(tmva-cpu)
target_include_directories(TMVA PRIVATE ${TBB_INCLUDE_DIRS})
target_link_libraries(TMVA PRIVATE ${TBB_LIBRARIES})
set_target_properties(TMVA PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
target_link_libraries(TMVA PRIVATE ROOT::BLAS)
target_link_libraries(TMVA PRIVATE TBB::tbb ROOT::BLAS)
endif()

if(tmva-gpu)
Expand Down
Loading