Skip to content

Commit

Permalink
Switch over to rapids-logger
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Dec 16, 2024
1 parent 3720d8e commit dfa6231
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 620 deletions.
28 changes: 24 additions & 4 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ set_property(
)
message(VERBOSE "RAFT: RMM_LOGGING_LEVEL = '${RMM_LOGGING_LEVEL}'.")

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

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

Expand Down Expand Up @@ -152,6 +163,13 @@ include(cmake/modules/ConfigureCUDA.cmake)
# add third party dependencies using CPM
rapids_cpm_init()

# Not using rapids-cmake since we never want to find, always download.
CPMAddPackage(
NAME rapids_logger GITHUB_REPOSITORY vyasr/rapids-logger GIT_SHALLOW FALSE GIT_TAG feat/cuml
VERSION feat/cuml
)
rapids_make_logger(raft LOGGER_HEADER_DIR include/raft/core EXPORT_SET raft-exports)

# CCCL before rmm/cuco so we get the right version of CCCL
include(cmake/thirdparty/get_cccl.cmake)
include(cmake/thirdparty/get_rmm.cmake)
Expand Down Expand Up @@ -182,14 +200,17 @@ target_include_directories(
# Keep RAFT as lightweight as possible. Only CUDA libs and rmm should be used in global target.
target_link_libraries(
raft INTERFACE rmm::rmm rmm::rmm_logger spdlog::spdlog_header_only cuco::cuco
nvidia::cutlass::cutlass CCCL::CCCL
nvidia::cutlass::cutlass CCCL::CCCL raft_logger
)

target_compile_features(raft INTERFACE cxx_std_17 $<BUILD_INTERFACE:cuda_std_17>)
target_compile_options(
raft INTERFACE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--expt-extended-lambda
--expt-relaxed-constexpr>
)
target_compile_definitions(
raft INTERFACE "RAFT_LOG_ACTIVE_LEVEL=RAFT_LOG_LEVEL_${LIBRAFT_LOGGING_LEVEL}"
)

set(RAFT_CUSOLVER_DEPENDENCY CUDA::cusolver${_ctk_static_suffix})
set(RAFT_CUBLAS_DEPENDENCY CUDA::cublas${_ctk_static_suffix})
Expand Down Expand Up @@ -265,7 +286,6 @@ set_target_properties(raft_compiled PROPERTIES EXPORT_NAME compiled)
if(RAFT_COMPILE_LIBRARY)
add_library(
raft_objs OBJECT
src/core/logger.cpp
src/linalg/detail/coalesced_reduction.cu
src/raft_runtime/random/rmat_rectangular_generator_int64_double.cu
src/raft_runtime/random/rmat_rectangular_generator_int64_float.cu
Expand Down Expand Up @@ -318,8 +338,8 @@ if(RAFT_COMPILE_LIBRARY)
# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
target_link_options(${target} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/fatbin.ld")
endforeach()
target_link_libraries(raft_lib PRIVATE rmm::rmm_logger_impl)
target_link_libraries(raft_lib_static PRIVATE rmm::rmm_logger_impl)
target_link_libraries(raft_lib PRIVATE rmm::rmm_logger_impl raft_logger_impl)
target_link_libraries(raft_lib_static PRIVATE rmm::rmm_logger_impl raft_logger_impl)
endif()

if(TARGET raft_lib AND (NOT TARGET raft::raft_lib))
Expand Down
8 changes: 4 additions & 4 deletions cpp/include/raft/cluster/detail/kmeans.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ void kmeans_fit_main(raft::resources const& handle,
rmm::device_uvector<char>& workspace)
{
common::nvtx::range<common::nvtx::domain::raft> fun_scope("kmeans_fit_main");
logger::get(RAFT_NAME).set_level(params.verbosity);
default_logger().set_level(params.verbosity);
cudaStream_t stream = resource::get_cuda_stream(handle);
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
Expand Down Expand Up @@ -865,7 +865,7 @@ void kmeans_fit(raft::resources const& handle,
params.n_clusters);
}

logger::get(RAFT_NAME).set_level(params.verbosity);
default_logger().set_level(params.verbosity);

// Allocate memory
rmm::device_uvector<char> workspace(0, stream);
Expand Down Expand Up @@ -1010,7 +1010,7 @@ void kmeans_predict(raft::resources const& handle,
RAFT_EXPECTS(centroids.extent(1) == n_features,
"invalid parameter (centroids.extent(1) != n_features)");

logger::get(RAFT_NAME).set_level(params.verbosity);
default_logger().set_level(params.verbosity);
auto metric = params.metric;

// Allocate memory
Expand Down Expand Up @@ -1201,7 +1201,7 @@ void kmeans_transform(raft::resources const& handle,
raft::device_matrix_view<DataT> X_new)
{
common::nvtx::range<common::nvtx::domain::raft> fun_scope("kmeans_transform");
logger::get(RAFT_NAME).set_level(params.verbosity);
default_logger().set_level(params.verbosity);
cudaStream_t stream = resource::get_cuda_stream(handle);
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/cluster/kmeans_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct KMeansParams : kmeans_base_params {
/**
* verbosity level.
*/
int verbosity = RAFT_LEVEL_INFO;
level_enum verbosity = level_enum::info;

/**
* Seed to the random number generator.
Expand Down
24 changes: 0 additions & 24 deletions cpp/include/raft/common/logger.hpp

This file was deleted.

3 changes: 0 additions & 3 deletions cpp/include/raft/core/cublas_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@

#include <cublas_v2.h>

///@todo: enable this once we have logger enabled
// #include <cuml/common/logger.hpp>

#include <cstdint>

#define _CUBLAS_ERR_TO_STR(err) \
Expand Down
7 changes: 3 additions & 4 deletions cpp/include/raft/core/cusolver_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@

#pragma once

#include <raft/util/cudart_utils.hpp>

#include <cusolverDn.h>
#include <cusolverSp.h>
///@todo: enable this once logging is enabled
// #include <cuml/common/logger.hpp>
#include <raft/util/cudart_utils.hpp>

#include <type_traits>

Expand Down Expand Up @@ -135,4 +134,4 @@ inline const char* cusolver_error_to_string(cusolverStatus_t err)
#define CUSOLVER_CHECK_NO_THROW(call) CUSOLVER_TRY_NO_THROW(call)
#endif

#endif
#endif
2 changes: 0 additions & 2 deletions cpp/include/raft/core/cusparse_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include <raft/core/error.hpp>

#include <cusparse.h>
///@todo: enable this once logging is enabled
// #include <cuml/common/logger.hpp>

#define _CUSPARSE_ERR_TO_STR(err) \
case err: return #err;
Expand Down
71 changes: 0 additions & 71 deletions cpp/include/raft/core/detail/callback_sink.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion cpp/include/raft/core/detail/fail_container_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once
#include <raft/core/error.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resources.hpp>
#include <raft/thirdparty/mdspan/include/experimental/mdspan>

Expand Down
24 changes: 0 additions & 24 deletions cpp/include/raft/core/detail/logger.hpp

This file was deleted.

Loading

0 comments on commit dfa6231

Please sign in to comment.