Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enabling NVTX markers by downstream projects after install #610

Merged
Merged
Changes from 1 commit
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
31 changes: 26 additions & 5 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ target_include_directories(raft INTERFACE

target_link_libraries(raft INTERFACE
raft::Thrust
$<$<BOOL:${NVTX}>:CUDA::nvToolsExt>
CUDA::cublas
CUDA::curand
CUDA::cusolver
Expand All @@ -163,7 +162,6 @@ target_link_libraries(raft INTERFACE
$<$<BOOL:${RAFT_ENABLE_cuco_DEPENDENCY}>:cuco::cuco>
std::mdspan)

target_compile_definitions(raft INTERFACE $<$<BOOL:${NVTX}>:NVTX_ENABLED>)
target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)

if(RAFT_COMPILE_LIBRARIES OR RAFT_COMPILE_DIST_LIBRARY OR RAFT_COMPILE_NN_LIBRARY)
Expand All @@ -177,6 +175,29 @@ SECTIONS
]=])
endif()

##############################################################################
# - NVTX support in raft -----------------------------------------------------

if (NVTX)
# This enables NVTX within the project with no option to disable it downstream.
target_link_libraries(raft INTERFACE CUDA::nvToolsExt)
target_compile_definitions(raft INTERFACE NVTX_ENABLED)
set(nvtx_export_string "")
achirkin marked this conversation as resolved.
Show resolved Hide resolved
else()
# Allow enable NVTX downstream if not set here.
# This creates a new option at build/install time, which is set by default to OFF,
# but can be enabled in the dependent project.
get_property(nvtx_option_help_string CACHE NVTX PROPERTY HELPSTRING)
string(CONCAT nvtx_export_string
"option(NVTX \"" ${nvtx_option_help_string} "\" OFF)"
achirkin marked this conversation as resolved.
Show resolved Hide resolved
[=[

target_link_libraries(raft::raft INTERFACE $<$<BOOL:${NVTX}>:CUDA::nvToolsExt>)
target_compile_definitions(raft::raft INTERFACE $<$<BOOL:${NVTX}>:NVTX_ENABLED>)

]=])
endif()

##############################################################################
# - raft_distance ------------------------------------------------------------
add_library(raft_distance INTERFACE)
Expand Down Expand Up @@ -361,7 +382,8 @@ Imported Targets:

]=])

set(code_string
string(CONCAT code_string
${nvtx_export_string}
[=[

if(NOT TARGET raft::Thrust)
Expand All @@ -381,8 +403,7 @@ if(nn IN_LIST raft_FIND_COMPONENTS)
add_library(faiss ALIAS faiss::faiss)
endif()
endif()
]=]
)
]=])

# Use `rapids_export` for 22.04 as it will have COMPONENT support
include(cmake/modules/raft_export.cmake)
Expand Down