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
Show file tree
Hide file tree
Changes from 4 commits
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
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ARGS=$*
# script, and that this script resides in the repo dir!
REPODIR=$(cd $(dirname $0); pwd)

VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --nvtx --show_depr_warn -h --buildfaiss --minimal-deps"
VALIDARGS="clean libraft pyraft pylibraft docs tests bench clean -v -g --install --compile-libs --compile-nn --compile-dist --allgpuarch --no-force-nvtx --show_depr_warn -h --buildfaiss --minimal-deps"
HELP="$0 [<target> ...] [<flag> ...]
where <target> is:
clean - remove all existing build artifacts and configuration (start over)
Expand All @@ -41,7 +41,7 @@ HELP="$0 [<target> ...] [<flag> ...]
--allgpuarch - build for all supported GPU architectures
--buildfaiss - build faiss statically into raft
--install - install cmake targets
--nvtx - enable nvtx for profiling support
--no-force-nvtx - disable nvtx (profiling markers), but allow enabling it in downstream projects
achirkin marked this conversation as resolved.
Show resolved Hide resolved
--show_depr_warn - show cmake deprecation warnings
-h - print this text

Expand Down Expand Up @@ -70,7 +70,7 @@ ENABLE_thrust_DEPENDENCY=ON
ENABLE_ucx_DEPENDENCY=OFF
ENABLE_nccl_DEPENDENCY=OFF

NVTX=OFF
NVTX=ON
CLEAN=0
UNINSTALL=0
DISABLE_DEPRECATION_WARNINGS=ON
Expand Down Expand Up @@ -157,8 +157,8 @@ fi
if hasArg --buildfaiss; then
BUILD_STATIC_FAISS=ON
fi
if hasArg --nvtx; then
NVTX=ON
if hasArg --no-force-nvtx; then
NVTX=OFF
fi
if hasArg --show_depr_warn; then
DISABLE_DEPRECATION_WARNINGS=OFF
Expand Down Expand Up @@ -219,7 +219,7 @@ if (( ${NUMARGS} == 0 )) || hasArg libraft || hasArg docs || hasArg tests || has
-DCMAKE_CUDA_ARCHITECTURES=${RAFT_CMAKE_CUDA_ARCHITECTURES} \
-DRAFT_COMPILE_LIBRARIES=${COMPILE_LIBRARIES} \
-DRAFT_ENABLE_NN_DEPENDENCIES=${ENABLE_NN_DEPENDENCIES} \
-DNVTX=${NVTX} \
-DRAFT_NVTX=${NVTX} \
-DDISABLE_DEPRECATION_WARNINGS=${DISABLE_DEPRECATION_WARNINGS} \
-DBUILD_TESTS=${BUILD_TESTS} \
-DBUILD_BENCH=${BUILD_BENCH} \
Expand Down
2 changes: 1 addition & 1 deletion conda/recipes/libraft_distance/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Copyright (c) 2022, NVIDIA CORPORATION.

./build.sh libraft --install -v --allgpuarch --compile-dist
./build.sh libraft --install -v --allgpuarch --compile-dist --no-force-nvtx
2 changes: 1 addition & 1 deletion conda/recipes/libraft_headers/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Copyright (c) 2022, NVIDIA CORPORATION.

./build.sh libraft --install -v --allgpuarch
./build.sh libraft --install -v --allgpuarch --no-force-nvtx
2 changes: 1 addition & 1 deletion conda/recipes/libraft_nn/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
# Copyright (c) 2022, NVIDIA CORPORATION.

./build.sh libraft --install -v --allgpuarch --compile-nn
./build.sh libraft --install -v --allgpuarch --compile-nn --no-force-nvtx
2 changes: 1 addition & 1 deletion conda/recipes/pylibraft/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#!/usr/bin/env bash

# This assumes the script is executed from the root of the repo directory
./build.sh pylibraft --install
./build.sh pylibraft --install --no-force-nvtx
2 changes: 1 addition & 1 deletion conda/recipes/pyraft/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Copyright (c) 2022, NVIDIA CORPORATION.

# This assumes the script is executed from the root of the repo directory
./build.sh pyraft --install
./build.sh pyraft --install --no-force-nvtx
31 changes: 26 additions & 5 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ option(CUDA_STATIC_RUNTIME "Statically link the CUDA runtime" OFF)
option(DETECT_CONDA_ENV "Enable detection of conda environment for dependencies" ON)
option(DISABLE_DEPRECATION_WARNINGS "Disable deprecaction warnings " ON)
option(DISABLE_OPENMP "Disable OpenMP" OFF)
option(NVTX "Enable nvtx markers" OFF)
option(RAFT_NVTX "Enable nvtx markers" OFF)

option(RAFT_COMPILE_LIBRARIES "Enable building raft shared library instantiations" ${BUILD_TESTS})
option(RAFT_COMPILE_NN_LIBRARY "Enable building raft nearest neighbors shared library instantiations" OFF)
Expand Down Expand Up @@ -91,7 +91,7 @@ message(VERBOSE "RAFT: Disable depreaction warnings " ${DISABLE_DEPRECATION_WARN
message(VERBOSE "RAFT: Disable OpenMP: ${DISABLE_OPENMP}")
message(VERBOSE "RAFT: Enable kernel resource usage info: ${CUDA_ENABLE_KERNELINFO}")
message(VERBOSE "RAFT: Enable lineinfo in nvcc: ${CUDA_ENABLE_LINEINFO}")
message(VERBOSE "RAFT: Enable nvtx markers: ${NVTX}")
message(VERBOSE "RAFT: Enable nvtx markers: ${RAFT_NVTX}")
message(VERBOSE "RAFT: Statically link the CUDA runtime: ${CUDA_STATIC_RUNTIME}")

# Set RMM logging level
Expand Down Expand Up @@ -167,7 +167,6 @@ target_include_directories(raft INTERFACE
# Only CUDA libs, rmm, and mdspan should
# be used in global target.
target_link_libraries(raft INTERFACE
$<$<BOOL:${NVTX}>:CUDA::nvToolsExt>
CUDA::cublas
CUDA::curand
CUDA::cusolver
Expand All @@ -178,7 +177,6 @@ target_link_libraries(raft INTERFACE
$<$<BOOL:${RAFT_ENABLE_mdspan_DEPENDENCY}>: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 @@ -192,6 +190,28 @@ SECTIONS
]=])
endif()

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

if (RAFT_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)
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 RAFT_NVTX PROPERTY HELPSTRING)
string(CONCAT nvtx_export_string
"option(RAFT_NVTX \"" ${nvtx_option_help_string} "\" OFF)"
[=[

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

]=])
endif()

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

]=])

set(code_string )
set(code_string ${nvtx_export_string})

if(RAFT_ENABLE_thrust_DEPENDENCY)
string(APPEND code_string
[=[
Expand Down