Skip to content

Commit

Permalink
Add RMM_USE_NVTX cmake option to provide localized control of NVTX fo…
Browse files Browse the repository at this point in the history
…r RMM (#1602)

Adds a new RMM_USE_NVTX cmake option that defaults to the prior USE_NVTX setting if not set.  If RMM_USE_NVTX is OFF, it stubs out the RMM_FUNC_RANGE macro which is used for RMM's NVTX ranges, effectively disabling NVTX within RMM yet leaving it enabled for the rest of the project using RMM.

Closes #1595

Authors:
  - Jason Lowe (https://github.com/jlowe)

Approvers:
  - Robert Maynard (https://github.com/robertmaynard)
  - Bradley Dice (https://github.com/bdice)

URL: #1602
  • Loading branch information
jlowe authored Jul 19, 2024
1 parent 33598c7 commit 5f786ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ rapids_cmake_build_type(Release)
# ##################################################################################################
# * build options ----------------------------------------------------------------------------------

option(USE_NVTX "Build with NVTX support" ON)
option(RMM_NVTX "Build RMM with NVTX support" OFF)
option(BUILD_TESTS "Configure CMake to build tests" ON)
option(BUILD_BENCHMARKS "Configure CMake to build (google) benchmarks" OFF)
set(RMM_LOGGING_LEVEL
Expand All @@ -47,7 +47,7 @@ set(RMM_LOGGING_LEVEL
set_property(CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR"
"CRITICAL" "OFF")

message(VERBOSE "RMM: Build with NVTX support: ${USE_NVTX}")
message(VERBOSE "RMM: Build with NVTX support: ${RMM_NVTX}")
# Set logging level. Must go before including gtests and benchmarks. Set the possible values of
# build type for cmake-gui.
message(STATUS "RMM: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'")
Expand Down Expand Up @@ -100,9 +100,9 @@ target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp)
target_compile_features(rmm INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)

# Disable NVTX if necessary
if(NOT USE_NVTX)
target_compile_definitions(rmm INTERFACE NVTX_DISABLE)
# Enable NVTX if necessary
if(RMM_NVTX)
target_compile_definitions(rmm INTERFACE RMM_NVTX)
endif()

# ##################################################################################################
Expand Down
4 changes: 4 additions & 0 deletions include/rmm/detail/nvtx/ranges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ using scoped_range = ::nvtx3::scoped_range_in<librmm_domain>;
* }
* ```
*/
#if defined(RMM_NVTX)
#define RMM_FUNC_RANGE() NVTX3_FUNC_RANGE_IN(rmm::librmm_domain)
#else
#define RMM_FUNC_RANGE()
#endif

0 comments on commit 5f786ba

Please sign in to comment.