From 1e1870467ca4adf3e97d2dd99b49d1315d97e701 Mon Sep 17 00:00:00 2001 From: Kaan Olgu Date: Mon, 2 Oct 2023 10:28:08 +0000 Subject: [PATCH 1/2] Changes to CMake file to use TBB --- src/std-data/model.cmake | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/std-data/model.cmake b/src/std-data/model.cmake index ef69f304..b6a82665 100644 --- a/src/std-data/model.cmake +++ b/src/std-data/model.cmake @@ -19,15 +19,41 @@ register_flag_optional(NVHPC_OFFLOAD ccall - Compile for all supported compute capabilities" "") +register_flag_optional(USE_TBB + "No-op if ONE_TBB_DIR is set. Link against an in-tree oneTBB via FetchContent_Declare, see top level CMakeLists.txt for details." + "OFF") + +register_flag_optional(USE_ONEDPL + "Link oneDPL which implements C++17 executor policies (via execution_policy_tag) for different backends. + + Possible values are: + OPENMP - Implements policies using OpenMP. + CMake will handle any flags needed to enable OpenMP if the compiler supports it. + TBB - Implements policies using TBB. + TBB must be linked via USE_TBB or be available in LD_LIBRARY_PATH. + DPCPP - Implements policies through SYCL2020. + This requires the DPC++ compiler (other SYCL compilers are untested), required SYCL flags are added automatically." + "OFF") + macro(setup) set(CMAKE_CXX_STANDARD 17) - if (NVHPC_OFFLOAD) set(NVHPC_FLAGS -stdpar -gpu=${NVHPC_OFFLOAD}) # propagate flags to linker so that it links with the gpu stuff as well register_append_cxx_flags(ANY ${NVHPC_FLAGS}) register_append_link_flags(${NVHPC_FLAGS}) endif () - - -endmacro() + if(ONE_TBB_DIR) + set(TBB_ROOT "${ONE_TBB_DIR}") # see https://github.com/Kitware/VTK/blob/0a31a9a3c1531ae238ac96a372fec4be42282863/CMake/FindTBB.cmake#L34 + # docs on Intel's website refers to TBB_DIR which is not correct + endif() + if (NOT USE_TBB) + # Only find TBB when we're not building in-tree + find_package(TBB REQUIRED) + endif() + register_link_library(TBB::tbb) + if (USE_ONEDPL) + register_definitions(USE_ONEDPL) + register_link_library(oneDPL) + endif () +endmacro() \ No newline at end of file From 7301b1c84737ece071b26f9bde34a5414ca4912e Mon Sep 17 00:00:00 2001 From: Kaan Olgu Date: Mon, 2 Oct 2023 10:32:42 +0000 Subject: [PATCH 2/2] Added the ONE_TBB_DIR flag --- src/std-data/model.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/std-data/model.cmake b/src/std-data/model.cmake index b6a82665..7f1701e1 100644 --- a/src/std-data/model.cmake +++ b/src/std-data/model.cmake @@ -3,6 +3,10 @@ register_flag_optional(CMAKE_CXX_COMPILER "Any CXX compiler that is supported by CMake detection" "c++") +register_flag_optional(ONE_TBB_DIR + "Absolute path to oneTBB (with header `onetbb/tbb.h`) distribution, the directory should contain at least `include/` and `lib/. + If unspecified, the system TBB (with header `tbb/tbb.h`) will be used via CMake's find_package(TBB)." + "") register_flag_optional(NVHPC_OFFLOAD "Enable offloading support (via the non-standard `-stdpar`) for the new NVHPC SDK. The values are Nvidia architectures in ccXY format will be passed in via `-gpu=` (e.g `cc70`) @@ -43,7 +47,7 @@ macro(setup) register_append_cxx_flags(ANY ${NVHPC_FLAGS}) register_append_link_flags(${NVHPC_FLAGS}) endif () - if(ONE_TBB_DIR) + if(ONE_TBB_DIR) set(TBB_ROOT "${ONE_TBB_DIR}") # see https://github.com/Kitware/VTK/blob/0a31a9a3c1531ae238ac96a372fec4be42282863/CMake/FindTBB.cmake#L34 # docs on Intel's website refers to TBB_DIR which is not correct endif()