diff --git a/CHANGELOG.md b/CHANGELOG.md index ce49cfafd..f46503a8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ Documentation for rocThrust available at ### Added +* Added a section to install Thread Building Block (TBB) inside `cmake/Dependencies.cmake` if TBB is not already available. +* Made Thread Building Block (TBB) an optional dependency with the new `BUILD_HIPSTDPAR_TEST_WITH_TBB` flag, default is `OFF`. When the flag is `OFF` and TBB is not already on the machine it will compile without TBB. Otherwise is will compile it with TBB. * Added extended tests to `rtest.py`. These tests are extra tests that did not fit the criteria of smoke and regression tests. These tests will take much longer to run relative to smoke and regression tests. Use `python rtest.py [--emulation|-e|--test|-t]=extended` to run these tests. * Added regression tests to `rtest.py`. These tests recreate scenarios that have caused hardware problems in past emulation environments. Use `python rtest.py [--emulation|-e|--test|-t]=regression` to run these tests. * Added smoke test options, which runs a subset of the unit tests and ensures that less than 2gb of VRAM will be used. Use `python rtest.py [--emulation|-e|--test|-t]=smoke` to run these tests. diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c65c82cb..887c1e544 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,9 +35,11 @@ include(CMakeDependentOption) option(DISABLE_WERROR "Disable building with Werror" ON) option(BUILD_TEST "Build tests" OFF) option(BUILD_HIPSTDPAR_TEST "Build hipstdpar tests" OFF) +option(BUILD_HIPSTDPAR_TEST_WITH_TBB "Build hipstdpar tests with TBB" OFF) option(BUILD_EXAMPLES "Build examples" OFF) option(BUILD_BENCHMARKS "Build benchmarks" OFF) option(DOWNLOAD_ROCPRIM "Download rocPRIM and do not search for rocPRIM package" OFF) +option(DOWNLOAD_ROCRAND "Download rocRAND and do not search for rocRAND package" OFF) option(BUILD_ADDRESS_SANITIZER "Build with address sanitizer enabled" OFF) cmake_dependent_option(ENABLE_UPSTREAM_TESTS "Enable upstream (thrust) tests" ON BUILD_TEST OFF) #Set the header wrapper OFF by default. @@ -162,7 +164,7 @@ print_configuration_summary() # Thrust (with HIP backend) add_subdirectory(thrust) -if(BUILD_TEST OR BUILD_BENCHMARKS) +if(BUILD_TEST OR BUILD_BENCHMARKS OR BUILD_HIPSTDPAR_TEST) rocm_package_setup_component(clients) endif() diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index 54225eed3..b0bd252f2 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -35,10 +35,11 @@ if(NOT rocprim_FOUND) endif() # Test dependencies -if(BUILD_TEST) +if(BUILD_TEST OR BUILD_HIPSTDPAR_TEST) if(NOT DEPENDENCIES_FORCE_DOWNLOAD) # Google Test (https://github.com/google/googletest) find_package(GTest QUIET) + find_package(TBB QUIET) else() message(STATUS "Force installing GTest.") endif() @@ -63,6 +64,27 @@ if(BUILD_TEST) find_package(GTest REQUIRED CONFIG PATHS ${GTEST_ROOT}) endif() + if (NOT TARGET TBB::tbb AND NOT TARGET tbb AND BUILD_HIPSTDPAR_TEST_WITH_TBB) + message(STATUS "TBB not found or force download TBB on. Downloading and building TBB.") + set(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/deps/tbb CACHE PATH "" FORCE) + + download_project( + PROJ TBB + GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git + GIT_TAG 1c4c93fc5398c4a1acb3492c02db4699f3048dea # v2021.13.0 + INSTALL_DIR ${TBB_ROOT} + CMAKE_ARGS -DCMAKE_CXX_COMPILER=g++ -DTBB_TEST=OFF -DTBB_BUILD=ON -DTBB_INSTALL=ON -DTBBMALLOC_PROXY_BUILD=OFF -DCMAKE_INSTALL_PREFIX= + LOG_DOWNLOAD TRUE + LOG_CONFIGURE TRUE + LOG_BUILD TRUE + LOG_INSTALL TRUE + BUILD_PROJECT TRUE + UPDATE_DISCONNECTED TRUE + ) + find_package(TBB REQUIRED CONFIG PATHS ${TBB_ROOT}) + + endif() + # SQlite (for run-to-run bitwise-reproducibility tests) # Note: SQLite 3.36.0 enabled the backup API by default, which we need # for cache serialization. We also want to use a static SQLite, diff --git a/cmake/DownloadProject.CMakeLists.cmake.in b/cmake/DownloadProject.CMakeLists.cmake.in index 5546c03a3..8a90d2ab1 100644 --- a/cmake/DownloadProject.CMakeLists.cmake.in +++ b/cmake/DownloadProject.CMakeLists.cmake.in @@ -10,14 +10,12 @@ if(${DL_ARGS_BUILD_PROJECT}) ExternalProject_Add(${DL_ARGS_PROJ}-download ${DL_ARGS_UNPARSED_ARGUMENTS} SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" - BUILD_IN_SOURCE TRUE TEST_COMMAND "" ) else() ExternalProject_Add(${DL_ARGS_PROJ}-download ${DL_ARGS_UNPARSED_ARGUMENTS} SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" - BUILD_IN_SOURCE TRUE TEST_COMMAND "" UPDATE_COMMAND "" CONFIGURE_COMMAND "" diff --git a/cmake/Summary.cmake b/cmake/Summary.cmake index 6c68f49da..6c061238e 100644 --- a/cmake/Summary.cmake +++ b/cmake/Summary.cmake @@ -47,12 +47,13 @@ else() endif() endif() message(STATUS "") - message(STATUS " DISABLE_WERROR : ${DISABLE_WERROR}") - message(STATUS " DOWNLOAD_ROCPRIM : ${DOWNLOAD_ROCPRIM}") - message(STATUS " DOWNLOAD_ROCRAND : ${DOWNLOAD_ROCRAND}") - message(STATUS " BUILD_TEST : ${BUILD_TEST}") - message(STATUS " BUILD_HIPSTDPAR_TEST : ${BUILD_HIPSTDPAR_TEST}") - message(STATUS " BUILD_EXAMPLES : ${BUILD_EXAMPLES}") - message(STATUS " BUILD_BENCHMARKS : ${BUILD_BENCHMARKS}") - message(STATUS " BUILD_ADDRESS_SANITIZER : ${BUILD_ADDRESS_SANITIZER}") + message(STATUS " DISABLE_WERROR : ${DISABLE_WERROR}") + message(STATUS " DOWNLOAD_ROCPRIM : ${DOWNLOAD_ROCPRIM}") + message(STATUS " DOWNLOAD_ROCRAND : ${DOWNLOAD_ROCRAND}") + message(STATUS " BUILD_TEST : ${BUILD_TEST}") + message(STATUS " BUILD_HIPSTDPAR_TEST : ${BUILD_HIPSTDPAR_TEST}") + message(STATUS " BUILD_HIPSTDPAR_TEST_WITH_TBB : ${BUILD_HIPSTDPAR_TEST_WITH_TBB}") + message(STATUS " BUILD_EXAMPLES : ${BUILD_EXAMPLES}") + message(STATUS " BUILD_BENCHMARKS : ${BUILD_BENCHMARKS}") + message(STATUS " BUILD_ADDRESS_SANITIZER : ${BUILD_ADDRESS_SANITIZER}") endfunction() diff --git a/test/hipstdpar/CMakeLists.txt b/test/hipstdpar/CMakeLists.txt index faf301837..fa9479f0f 100644 --- a/test/hipstdpar/CMakeLists.txt +++ b/test/hipstdpar/CMakeLists.txt @@ -14,7 +14,8 @@ function(add_hipstdpar_test TEST TEST_TYPE INTERPOSE_ALLOC) PRIVATE --hipstdpar --hipstdpar-path=${HIPSTDPAR_LOCATION} - --hipstdpar-thrust-path=${THRUST_LOCATION}) + --hipstdpar-thrust-path=${THRUST_LOCATION} + --hipstdpar-prim-path=${ROCPRIM_LOCATION}) if(INTERPOSE_ALLOC) target_compile_options(${TEST_TARGET} PRIVATE @@ -24,9 +25,15 @@ function(add_hipstdpar_test TEST TEST_TYPE INTERPOSE_ALLOC) target_link_libraries(${TEST_TARGET} PRIVATE --hipstdpar - TBB::tbb Threads::Threads ) + + if(TARGET TBB::tbb OR TARGET tbb) + target_link_libraries(${TEST_TARGET} + PRIVATE + TBB::tbb + ) + endif() if (NOT WIN32) foreach(gpu_target ${GPU_TARGETS}) @@ -79,26 +86,12 @@ set(ROCTHRUST_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) set(CMAKE_CXX_STANDARD 17) # Dependencies -find_package(TBB QUIET) -if(NOT TARGET TBB::tbb AND NOT TARGET tbb) - message(STATUS "Thread Building Blocks not found. Fetching...") - FetchContent_Declare( - thread-building-blocks - GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git - GIT_TAG 1c4c93fc5398c4a1acb3492c02db4699f3048dea # v2021.13.0 - ) - # Disable tests for TBB - set(TBB_TEST OFF CACHE BOOL "Disable TBB tests" FORCE) - - FetchContent_MakeAvailable(thread-building-blocks) -else() - find_package(TBB REQUIRED) -endif() find_package(Threads REQUIRED) -# Define where to find rocThrust and hipstdpar headers +# Define where to find rocThrust, hipstdpar and rocPRIM headers set(THRUST_LOCATION ${PROJECT_SOURCE_DIR}) set(HIPSTDPAR_LOCATION ${THRUST_LOCATION}/thrust/system/hip/hipstdpar) +set(ROCPRIM_LOCATION ${ROCPRIM_INCLUDE_DIR}) # Add tests add_hipstdpar_test("algorithms" "compile" OFF)