Skip to content

Commit

Permalink
Unify [CCCL|CUB|THRUST]_ENABLE_BENCHMARKS (NVIDIA#2827)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardmgruber authored Nov 15, 2024
1 parent 21639f2 commit 918ce6d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ option(CCCL_ENABLE_CUB "Enable the CUB developer build." ${CCCL_TOPLEVEL_PROJECT
option(CCCL_ENABLE_THRUST "Enable the Thrust developer build." ${CCCL_TOPLEVEL_PROJECT})
option(CCCL_ENABLE_TESTING "Enable CUDA C++ Core Library tests." ${CCCL_TOPLEVEL_PROJECT})
option(CCCL_ENABLE_EXAMPLES "Enable CUDA C++ Core Library examples." ${CCCL_TOPLEVEL_PROJECT})
option(CCCL_ENABLE_BENCHMARKS "Enable CUDA C++ Core Library benchmarks." OFF)
option(CCCL_ENABLE_C "Enable CUDA C Core Library." OFF)

option(CCCL_ENABLE_UNSTABLE "Enable targets and developer build options for unstable projects." OFF)
option(CCCL_ENABLE_BENCHMARKS "Enable CUDA C++ Core Library benchmarks." OFF)
if ("NVHPC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(CCCL_ENABLE_BENCHMARKS OFF)
endif()

option(CCCL_ENABLE_UNSTABLE "Enable targets and developer build options for unstable projects." OFF)
if (CCCL_ENABLE_UNSTABLE)
option(CCCL_ENABLE_CUDAX "Enable the CUDA Experimental developer build." ${CCCL_TOPLEVEL_PROJECT})
else()
Expand Down
8 changes: 4 additions & 4 deletions ci/build_cub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version_compare() {
fi
}

ENABLE_CUB_BENCHMARKS="false"
ENABLE_CCCL_BENCHMARKS="false"
ENABLE_CUB_RDC="false"

if [[ "$CUDA_COMPILER" == *nvcc* ]]; then
Expand All @@ -25,7 +25,7 @@ if [[ "$CUDA_COMPILER" == *nvcc* ]]; then
if [[ -n "${DISABLE_CUB_BENCHMARKS}" ]]; then
echo "Benchmarks have been forcefully disabled."
elif [[ $(version_compare $NVCC_VERSION 11.5) == "true" ]]; then
ENABLE_CUB_BENCHMARKS="true"
ENABLE_CCCL_BENCHMARKS="true"
echo "nvcc version is $NVCC_VERSION. Building CUB benchmarks."
else
echo "nvcc version is $NVCC_VERSION. Not building CUB benchmarks because nvcc version is less than 11.5."
Expand All @@ -35,13 +35,13 @@ else
fi

if [[ "$HOST_COMPILER" == *icpc* || "$HOST_COMPILER" == *nvhpc* ]]; then
ENABLE_CUB_BENCHMARKS="false"
ENABLE_CCCL_BENCHMARKS="false"
fi

PRESET="cub-cpp$CXX_STANDARD"

CMAKE_OPTIONS="
-DCUB_ENABLE_BENCHMARKS="$ENABLE_CUB_BENCHMARKS"\
-DCCCL_ENABLE_BENCHMARKS="$ENABLE_CCCL_BENCHMARKS"\
-DCUB_ENABLE_RDC_TESTS="$ENABLE_CUB_RDC" \
"

Expand Down
14 changes: 6 additions & 8 deletions cub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ endif()

option(CUB_ENABLE_HEADER_TESTING "Test that all public headers compile." ON)
option(CUB_ENABLE_TESTING "Build CUB testing suite." ON)
option(CUB_ENABLE_BENCHMARKS "Build CUB benchmarking suite." "${CCCL_ENABLE_BENCHMARKS}")
option(CUB_ENABLE_TUNING "Build CUB tuning suite." OFF)
option(CUB_ENABLE_EXAMPLES "Build CUB examples." ON)

option(CUB_ENABLE_TUNING "Build CUB tuning suite." OFF)
if ("NVHPC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(CUB_ENABLE_TUNING OFF)
endif()

# This is needed for NVCXX QA, which requires a static set of executable names.
# Only a single dialect may be enabled when this is off.
option(CUB_ENABLE_CPP_DIALECT_IN_NAMES
Expand Down Expand Up @@ -56,11 +59,6 @@ include(cmake/CubBuildTargetList.cmake)
include(cmake/CubCudaConfig.cmake)
include(cmake/CubUtilities.cmake)

if ("NVHPC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(CUB_ENABLE_BENCHMARKS OFF)
set(CUB_ENABLE_TUNING OFF)
endif()

if ("" STREQUAL "${CMAKE_BUILD_TYPE}")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE)

Expand Down Expand Up @@ -93,6 +91,6 @@ if (CUB_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

if (CUB_ENABLE_BENCHMARKS OR CUB_ENABLE_TUNING)
if (CCCL_ENABLE_BENCHMARKS OR CUB_ENABLE_TUNING)
add_subdirectory(benchmarks)
endif()
2 changes: 1 addition & 1 deletion docs/cub/benchmarking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ This file contains instructions on how to run all CUB benchmarks using CUB tunin
cmake -B build -DCCCL_ENABLE_THRUST=OFF\
-DCCCL_ENABLE_LIBCUDACXX=OFF\
-DCCCL_ENABLE_CUB=ON\
-DCCCL_ENABLE_BENCHMARKS=YES\
-DCUB_ENABLE_DIALECT_CPP11=OFF\
-DCUB_ENABLE_DIALECT_CPP14=OFF\
-DCUB_ENABLE_DIALECT_CPP17=ON\
-DCUB_ENABLE_DIALECT_CPP20=OFF\
-DCUB_ENABLE_RDC_TESTS=OFF\
-DCUB_ENABLE_BENCHMARKS=YES\
-DCUB_ENABLE_TUNING=YES\
-DCMAKE_BUILD_TYPE=Release\
-DCMAKE_CUDA_ARCHITECTURES="89;90"
Expand Down
4 changes: 2 additions & 2 deletions docs/cub/tuning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Search Process
To get started with tuning / benchmarking, you need to configure CMake. The following options are
available:

* :code:`CUB_ENABLE_BENCHMARKS` - enable bases (default: OFF).
* :code:`CCCL_ENABLE_BENCHMARKS` - enable bases (default: OFF).
* :code:`CUB_ENABLE_TUNING` - enable variants (default: OFF).

Having configured CMake, you can start the search process. Note that the search has to be started
Expand All @@ -188,7 +188,7 @@ from the build directory.
.. code:: bash
$ cd build
$ cmake -DThrust_DIR=path-to-thrust/thrust/cmake -DCUB_ENABLE_TUNING=YES -DCUB_ENABLE_BENCHMARKS=YES -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES="90" ..
$ cmake -DThrust_DIR=path-to-thrust/thrust/cmake -DCUB_ENABLE_TUNING=YES -DCCCL_ENABLE_BENCHMARKS=YES -DCMAKE_BUILD_TYPE=Release -DCMAKE_CUDA_ARCHITECTURES="90" ..
$ ../benchmarks/scripts/search.py -a "T{ct}=[I8,I16]" -R ".*algname.*"
Both :code:`-a` and :code:`-R` options are optional. The first one is used to specify types to tune
Expand Down
9 changes: 2 additions & 7 deletions thrust/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ cmake_minimum_required(VERSION 3.17)
option(THRUST_ENABLE_HEADER_TESTING "Test that all public headers compile." "ON")
option(THRUST_ENABLE_TESTING "Build Thrust testing suite." "ON")
option(THRUST_ENABLE_EXAMPLES "Build Thrust examples." "ON")
option(THRUST_ENABLE_BENCHMARKS "Build Thrust runtime benchmarks." "${CCCL_ENABLE_BENCHMARKS}")

if ("NVHPC" STREQUAL "${CMAKE_CXX_COMPILER_ID}")
set(THRUST_ENABLE_BENCHMARKS OFF)
endif()

# Allow the user to optionally select offset type dispatch to fixed 32 or 64 bit types
set(THRUST_DISPATCH_TYPE "Dynamic" CACHE STRING "Select Thrust offset type dispatch." FORCE)
Expand All @@ -44,7 +39,7 @@ set_property(CACHE THRUST_DISPATCH_TYPE PROPERTY STRINGS "Dynamic" "Force32bit"
if (NOT (THRUST_ENABLE_HEADER_TESTING OR
THRUST_ENABLE_TESTING OR
THRUST_ENABLE_EXAMPLES OR
THRUST_ENABLE_BENCHMARKS))
CCCL_ENABLE_BENCHMARKS))
return()
endif()

Expand Down Expand Up @@ -101,6 +96,6 @@ if (THRUST_ENABLE_EXAMPLES)
add_subdirectory(examples)
endif()

if (THRUST_ENABLE_BENCHMARKS)
if (CCCL_ENABLE_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
4 changes: 0 additions & 4 deletions thrust/benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ if(NOT CCCL_ENABLE_CUB)
message(FATAL_ERROR "Thrust benchmarks depend on CUB: set CCCL_ENABLE_CUB.")
endif()

if(NOT CUB_ENABLE_BENCHMARKS)
message(FATAL_ERROR "Thrust benchmarks depend on CUB benchmarks: set CUB_ENABLE_BENCHMARKS.")
endif()

set(benches_root "${CMAKE_CURRENT_LIST_DIR}")

function(get_recursive_subdirs subdirs)
Expand Down

0 comments on commit 918ce6d

Please sign in to comment.