Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
21 changes: 20 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# cuvs build scripts
Expand Down Expand Up @@ -62,6 +62,8 @@ HELP="$0 [<target> ...] [<flag> ...] [--cmake-args=\"<args>\"] [--cache-tool=<to
to speedup the build process.
--time - Enable nvcc compilation time logging into cpp/build/nvcc_compile_log.csv.
Results can be interpreted with cpp/scripts/analyze_nvcc_log.py
--logging-level=<level> - overwrite the macro "RAFT_LOG_ACTIVE_LEVEL" to RAPIDS_LOGGER_LOG_LEVEL_{given_value}.
Valid values are (TRACE, DEBUG, INFO, WARN, ERROR, CRITICAL, OFF)
-h - print this text

default action (no args) is to build libcuvs, tests and cuvs targets
Expand Down Expand Up @@ -95,6 +97,7 @@ CLEAN=0
DISABLE_DEPRECATION_WARNINGS=ON
CMAKE_TARGET=()
EXTRA_CMAKE_ARGS=""
LIBRAFT_LOGGING_LEVEL=INFO

# Set defaults for vars that may not have been defined externally
INSTALL_PREFIX=${INSTALL_PREFIX:=${PREFIX:=${CONDA_PREFIX:=$LIBCUVS_BUILD_DIR/install}}}
Expand Down Expand Up @@ -236,6 +239,20 @@ function gpuArch {
fi
}

function loggingLevel {
if [[ -n $(echo "$ARGS" | { grep -E "\-\-logging\-level" || true; } ) ]]; then
LIBRAFT_LOGGING_LEVEL=$(echo "$ARGS" | sed -e 's/.*--logging-level[= ]//' -e 's/ .*//')
if [[ -n ${LIBRAFT_LOGGING_LEVEL} ]]; then
ARGS=$(echo "$ARGS" | sed -e "s/--logging-level[= ]${LIBRAFT_LOGGING_LEVEL}//")
VALID_LEVELS="TRACE DEBUG INFO WARN ERROR CRITICAL OFF"
if [[ ! " ${VALID_LEVELS} " =~ " ${LIBRAFT_LOGGING_LEVEL} " ]]; then
echo "Invalid --logging-level value: '${LIBRAFT_LOGGING_LEVEL}'. Valid values are: ${VALID_LEVELS}"
exit 1
fi
fi
fi
}

if hasArg -h || hasArg --help; then
echo "${HELP}"
exit 0
Expand All @@ -249,6 +266,7 @@ if (( NUMARGS != 0 )); then
limitAnnBench
buildMetrics
gpuArch
loggingLevel
for a in ${ARGS}; do
if ! (echo " ${VALIDARGS} " | grep -q " ${a} "); then
echo "Invalid option: ${a}"
Expand Down Expand Up @@ -415,6 +433,7 @@ if (( NUMARGS == 0 )) || hasArg libcuvs || hasArg tests || hasArg bench-prims ||
-DBUILD_MG_ALGOS=${BUILD_MG_ALGOS} \
-DCMAKE_MESSAGE_LOG_LEVEL=${CMAKE_LOG_LEVEL} \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
-DLIBRAFT_LOGGING_LEVEL=${LIBRAFT_LOGGING_LEVEL} \
"${CACHE_ARGS[@]}" \
"${EXTRA_CMAKE_ARGS[@]}"

Expand Down
12 changes: 1 addition & 11 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# =============================================================================
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2020-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on
cmake_minimum_required(VERSION 4.0 FATAL_ERROR)
Expand Down Expand Up @@ -118,16 +118,6 @@ message(VERBOSE "cuVS: Enable nvtx markers: ${CUVS_NVTX}")
message(VERBOSE "cuVS: Statically link the CUDA math libraries: ${CUDA_STATIC_MATH_LIBRARIES}")
message(VERBOSE "cuVS: Build and statically link RAPIDS libraries: ${CUVS_STATIC_RAPIDS_LIBRARIES}")

# Set RMM logging level
set(RMM_LOGGING_LEVEL
"INFO"
CACHE STRING "Choose the logging level."
)
set_property(
CACHE RMM_LOGGING_LEVEL PROPERTY STRINGS "TRACE" "DEBUG" "INFO" "WARN" "ERROR" "CRITICAL" "OFF"
)
message(VERBOSE "cuVS: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")

# ##################################################################################################
# * Conda environment detection ----------------------------------------------

Expand Down
25 changes: 24 additions & 1 deletion cpp/cmake/thirdparty/get_raft.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# =============================================================================
# cmake-format: off
# SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# cmake-format: on

# Use RAPIDS_VERSION_MAJOR_MINOR from rapids_config.cmake
set(RAFT_VERSION "${RAPIDS_VERSION_MAJOR_MINOR}")
set(RAFT_FORK "rapidsai")
set(RAFT_PINNED_TAG "${rapids-cmake-checkout-tag}")
set(LIBRAFT_LOGGING_LEVEL "INFO"
CACHE STRING "Choose the RAFT logging level compiled into cuVS."
)

function(find_and_configure_raft)
set(oneValueArgs VERSION FORK PINNED_TAG BUILD_STATIC_DEPS ENABLE_NVTX ENABLE_MNMG_DEPENDENCIES CLONE_ON_PIN)
Expand Down Expand Up @@ -55,6 +58,24 @@ function(find_and_configure_raft)
)
endfunction()

# RAFT target is shipped together with the RAFT_LOG_ACTIVE_LEVEL macro. Simply redefining the macro
# would yield a redefine error. We instead query and modify the definition list of the RAFT target manually.
function(overwrite_raft_log_active_level)
set(oneValueArgs LEVEL)
cmake_parse_arguments(PKG "" "${oneValueArgs}" "" ${ARGN})
if(TARGET raft::raft)
get_target_property(_defs raft::raft INTERFACE_COMPILE_DEFINITIONS)
if(_defs)
# Get definitions without previous logging level
list(FILTER _defs EXCLUDE REGEX "^RAFT_LOG_ACTIVE_LEVEL=")
# Append the new logging level
list(APPEND _defs "RAFT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${PKG_LEVEL}")
# Set the modified definitions back to the raft target
set_target_properties(raft::raft PROPERTIES INTERFACE_COMPILE_DEFINITIONS "${_defs}")
message(STATUS "cuVS: set RAFT_LOG_ACTIVE_LEVEL=RAPIDS_LOGGER_LOG_LEVEL_${PKG_LEVEL}")
endif()
endif()
endfunction()

# Change pinned tag here to test a commit in CI
# To use a different RAFT locally, set the CMake variable
Expand All @@ -71,3 +92,5 @@ find_and_configure_raft(VERSION ${RAFT_VERSION}.00
CLONE_ON_PIN ${CUVS_RAFT_CLONE_ON_PIN}

)

overwrite_raft_log_active_level(LEVEL ${LIBRAFT_LOGGING_LEVEL})
Loading