Skip to content

Commit

Permalink
Use new rapids-logger library (rapidsai#1808)
Browse files Browse the repository at this point in the history
This change helps completely insulate rmm (and transitively) the rest of RAPIDS from fmt and spdlog as dependencies, thereby solving a large number of issues around ABI stability, symbol visibility, package clobbering, and more. See rapidsai/build-planning#104 for more information.

Authors:
  - Vyas Ramasubramani (https://github.com/vyasr)

Approvers:
  - Matthew Murray (https://github.com/Matt711)
  - Bradley Dice (https://github.com/bdice)
  - James Lamb (https://github.com/jameslamb)

URL: rapidsai#1808
  • Loading branch information
vyasr authored and VenkateshJaya committed Feb 11, 2025
1 parent cd58aed commit 1f07b7a
Show file tree
Hide file tree
Showing 31 changed files with 227 additions and 146 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ rapids_find_package(
rapids_cpm_init()

include(${rapids-cmake-dir}/cpm/rapids_logger.cmake)
rapids_cpm_rapids_logger()
rapids_make_logger(rmm EXPORT_SET rmm-exports)
rapids_cpm_rapids_logger(BUILD_EXPORT_SET rmm-exports INSTALL_EXPORT_SET rmm-exports)
create_logger_macros(RMM "rmm::default_logger()" include/rmm)

include(cmake/thirdparty/get_cccl.cmake)
include(cmake/thirdparty/get_nvtx.cmake)
Expand All @@ -86,8 +86,10 @@ include(cmake/thirdparty/get_nvtx.cmake)
add_library(rmm INTERFACE)
add_library(rmm::rmm ALIAS rmm)

target_include_directories(rmm INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_include_directories(
rmm
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>" "$<INSTALL_INTERFACE:include>")

if(CUDA_STATIC_RUNTIME)
message(STATUS "RMM: Enabling static linking of cudart")
Expand All @@ -96,10 +98,10 @@ else()
target_link_libraries(rmm INTERFACE CUDA::cudart)
endif()

target_link_libraries(rmm INTERFACE rmm_logger)
target_link_libraries(rmm INTERFACE CCCL::CCCL)
target_link_libraries(rmm INTERFACE dl)
target_link_libraries(rmm INTERFACE nvtx3::nvtx3-cpp)
target_link_libraries(rmm INTERFACE rapids_logger::rapids_logger)
target_compile_features(rmm INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_definitions(rmm INTERFACE LIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE)

Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,16 @@ set to `True`. The log file name can be set using the `log_file_name` parameter.
### Debug Logging
RMM includes a debug logger which can be enabled to log trace and debug information to a file. This
information can show when errors occur, when additional memory is allocated from upstream resources,
etc. By default output is logged to stderr, but the environment variable
`RMM_DEBUG_LOG_FILE` can be set to specify a path and file name to dump the logs to instead.
RMM leverages [`rapids-logger`](https://github.com/rapidsai/rapids-logger) to log trace and debug
information to a file. This information can show when errors occur, when additional memory is
allocated from upstream resources, etc. By default output is logged to stderr, but the environment
variable `RMM_DEBUG_LOG_FILE` can be set to specify a path and file name to dump the logs to
instead.
There is a CMake configuration variable `RMM_LOGGING_LEVEL`, which can be set to enable compilation
of more detailed logging. The default is `INFO`. Available levels are `TRACE`, `DEBUG`, `INFO`,
`WARN`, `ERROR`, `CRITICAL` and `OFF`.
The log relies on the [spdlog](https://github.com/gabime/spdlog.git) library.
Note that to see logging below the `INFO` level, the application must also set the logging level at
run time. C++ applications must must call `rmm::default_logger().set_level()`, for example to enable all
levels of logging down to `TRACE`, call `rmm::default_logger().set_level(spdlog::level::trace)` (and compile
Expand Down
8 changes: 1 addition & 7 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# =============================================================================
# Copyright (c) 2018-2024, NVIDIA CORPORATION.
# Copyright (c) 2018-2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -45,8 +45,6 @@ function(ConfigureBench BENCH_NAME)
target_compile_options(${BENCH_NAME} PUBLIC $<$<COMPILE_LANG_AND_ID:CXX,GNU,Clang>:-Wall -Werror
-Wno-unknown-pragmas>)

target_link_libraries(${BENCH_NAME} PRIVATE rmm_bench_logger)

if(DISABLE_DEPRECATION_WARNING)
target_compile_options(
${BENCH_NAME} PUBLIC $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-Wno-deprecated-declarations>)
Expand All @@ -61,10 +59,6 @@ function(ConfigureBench BENCH_NAME)
EXCLUDE_FROM_ALL)
endfunction(ConfigureBench)

# Create an object library for the logger so that we don't have to recompile it.
add_library(rmm_bench_logger OBJECT)
target_link_libraries(rmm_bench_logger PRIVATE rmm_logger_impl)

# random allocations benchmark
ConfigureBench(RANDOM_ALLOCATIONS_BENCH random_allocations/random_allocations.cpp)

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/replay/replay.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2024, NVIDIA CORPORATION.
* Copyright (c) 2020-2025, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -403,7 +403,7 @@ int main(int argc, char** argv)
auto const num_threads = per_thread_events.size();

// Uncomment to enable / change default log level
// rmm::logger().set_level(rmm::level_enum::trace);
// rmm::logger().set_level(rapids_logger::level_enum::trace);

if (args.count("resource") > 0) {
std::string mr_name = args["resource"].as<std::string>();
Expand Down
5 changes: 4 additions & 1 deletion ci/build_wheel_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ PIP_CONSTRAINT="${PWD}/build-constraints.txt" \
sccache --show-adv-stats

mkdir -p final_dist
python -m auditwheel repair -w "${wheel_dir}" dist/*
EXCLUDE_ARGS=(
--exclude "librapids_logger.so"
)
python -m auditwheel repair "${EXCLUDE_ARGS[@]}" -w final_dist dist/*

../../ci/validate_wheel.sh "${wheel_dir}"

Expand Down
13 changes: 1 addition & 12 deletions ci/check_symbols.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# Copyright (c) 2024, NVIDIA CORPORATION.
# Copyright (c) 2024-2025, NVIDIA CORPORATION.

set -eEuo pipefail

Expand Down Expand Up @@ -47,17 +47,6 @@ for dso_file in ${dso_files}; do
echo " * WEAK: $(grep --count -E ' WEAK ' < ${symbol_file})"
echo " * LOCAL: $(grep --count -E ' LOCAL ' < ${symbol_file})"

echo "checking for 'fmt::' symbols..."
if grep -E 'fmt\:\:' < "${symbol_file}"; then
raise-symbols-found-error 'fmt::'
fi

echo "checking for 'spdlog::' symbols..."
if grep -E 'spdlog\:\:' < "${symbol_file}" \
| grep -v 'std\:\:_Destroy_aux'
then
raise-symbols-found-error 'spdlog::'
fi
echo "No symbol visibility issues found"
done

Expand Down
1 change: 1 addition & 0 deletions ci/test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rapids-generate-pip-constraints test_python ./constraints.txt
rapids-pip-retry install \
-v \
--constraint ./constraints.txt \
"$(echo "${WHEELHOUSE}"/librmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)" \
"$(echo "${WHEELHOUSE}"/rmm_"${RAPIDS_PY_CUDA_SUFFIX}"*.whl)[test]"

python -m pytest ./python/rmm/rmm/tests
33 changes: 0 additions & 33 deletions cmake/thirdparty/get_spdlog.cmake

This file was deleted.

3 changes: 1 addition & 2 deletions conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- cxx-compiler
- cython>=3.0.0
- doxygen=1.9.1
- fmt>=11.0.2,<12
- gcc_linux-64=11.*
- gcovr>=5.0
- graphviz
Expand All @@ -34,8 +33,8 @@ dependencies:
- pytest-cov
- python>=3.10,<3.13
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-logger==0.1.*,>=0.0.0a0
- scikit-build-core >=0.10.0
- spdlog>=1.14.1,<1.15
- sphinx
- sphinx-copybutton
- sphinx-markdown-tables
Expand Down
3 changes: 1 addition & 2 deletions conda/environments/all_cuda-128_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- cxx-compiler
- cython>=3.0.0
- doxygen=1.9.1
- fmt>=11.0.2,<12
- gcc_linux-64=13.*
- gcovr>=5.0
- graphviz
Expand All @@ -33,8 +32,8 @@ dependencies:
- pytest-cov
- python>=3.10,<3.13
- rapids-build-backend>=0.3.0,<0.4.0.dev0
- rapids-logger==0.1.*,>=0.0.0a0
- scikit-build-core >=0.10.0
- spdlog>=1.14.1,<1.15
- sphinx
- sphinx-copybutton
- sphinx-markdown-tables
Expand Down
6 changes: 0 additions & 6 deletions conda/recipes/librmm/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,3 @@ c_stdlib_version:

cmake_version:
- ">=3.26.4,!=3.30.0"

fmt_version:
- ">=11.0.2,<12"

spdlog_version:
- ">=1.14.1,<1.15"
6 changes: 2 additions & 4 deletions conda/recipes/librmm/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ requirements:
- {{ stdlib("c") }}
host:
- cuda-version ={{ cuda_version }}
- fmt {{ fmt_version }}
- spdlog {{ spdlog_version }}
- rapids-logger =0.1

build:
script_env:
Expand Down Expand Up @@ -68,8 +67,7 @@ outputs:
{% if cuda_major == "11" %}
- cudatoolkit
{% endif %}
- fmt {{ fmt_version }}
- spdlog {{ spdlog_version }}
- rapids-logger =0.1
test:
commands:
- test -d "${PREFIX}/include/rmm"
Expand Down
62 changes: 47 additions & 15 deletions dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ files:
- checks
- cuda
- cuda_version
- depends_on_rapids_logger
- develop
- docs
- py_version
Expand Down Expand Up @@ -54,6 +55,14 @@ files:
key: requires
includes:
- build
- depends_on_rapids_logger
py_cpp_run:
output: pyproject
pyproject_dir: python/librmm
extras:
table: project
includes:
- depends_on_rapids_logger
py_build:
output: pyproject
pyproject_dir: python/rmm
Expand All @@ -70,13 +79,15 @@ files:
includes:
- build
- cython_build
- depends_on_librmm
py_run:
output: pyproject
pyproject_dir: python/rmm
extras:
table: project
includes:
- run
- depends_on_librmm
py_optional_test:
output: pyproject
pyproject_dir: python/rmm
Expand Down Expand Up @@ -111,8 +122,6 @@ dependencies:
packages:
- c-compiler
- cxx-compiler
- fmt>=11.0.2,<12
- spdlog>=1.14.1,<1.15
specific:
- output_types: conda
matrices:
Expand Down Expand Up @@ -171,21 +180,33 @@ dependencies:
- matrix: # All CUDA 11 versions
packages:
- &cuda_python11 cuda-python>=11.8.5,<12.0a0
depends_on_librmm:
common:
- output_types: conda
packages:
- &librmm_unsuffixed librmm==25.4.*,>=0.0.0a0
- output_types: requirements
packages:
# pip recognizes the index as a global option for the requirements.txt file
# This index is needed for librmm-cu{11,12}.
- --extra-index-url=https://pypi.nvidia.com
- --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
specific:
- output_types: [requirements, pyproject]
matrices:
- matrix:
cuda: "12.*"
cuda_suffixed: "true"
packages:
- librmm-cu12==25.4.*,>=0.0.0a0
- matrix:
cuda: "11.*"
cuda_suffixed: "true"
packages:
- librmm-cu11==25.4.*,>=0.0.0a0
- matrix: null
packages:
- librmm==25.4.*,>=0.0.0a0
- matrix:
cuda: "12.*"
cuda_suffixed: "true"
packages:
- librmm-cu12==25.4.*,>=0.0.0a0
- matrix:
cuda: "11.*"
cuda_suffixed: "true"
packages:
- librmm-cu11==25.4.*,>=0.0.0a0
- matrix:
packages:
- *librmm_unsuffixed
checks:
common:
- output_types: [conda, requirements]
Expand Down Expand Up @@ -338,3 +359,14 @@ dependencies:
- numpy==1.23.*
- matrix:
packages:
depends_on_rapids_logger:
common:
- output_types: [conda, requirements, pyproject]
packages:
- rapids-logger==0.1.*,>=0.0.0a0
- output_types: requirements
packages:
# pip recognizes the index as a global option for the requirements.txt file
# This index is needed for rapids_logger
- --extra-index-url=https://pypi.nvidia.com
- --extra-index-url=https://pypi.anaconda.org/rapidsai-wheels-nightly/simple
Loading

0 comments on commit 1f07b7a

Please sign in to comment.