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

Update for raft logger changes #540

Merged
merged 11 commits into from
Dec 31, 2024
11 changes: 6 additions & 5 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,14 @@ if(BUILD_SHARED_LIBS)
"$<$<COMPILE_LANGUAGE:CUDA>:${CUVS_CUDA_FLAGS}>"
)
target_link_libraries(
cuvs_objs PUBLIC raft::raft rmm::rmm rmm::rmm_logger ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
PRIVATE rmm::rmm_logger_impl
cuvs_objs
PUBLIC raft::raft rmm::rmm rmm::rmm_logger ${CUVS_CTK_MATH_DEPENDENCIES}
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
PRIVATE rmm::rmm_logger_impl raft::raft_logger_impl
)

add_library(cuvs SHARED $<FILTER:$<TARGET_OBJECTS:cuvs_objs>,EXCLUDE,rmm.*logger>)
add_library(cuvs_static STATIC $<FILTER:$<TARGET_OBJECTS:cuvs_objs>,EXCLUDE,rmm.*logger>)
add_library(cuvs_static STATIC $<FILTER:$<TARGET_OBJECTS:cuvs_objs>,EXCLUDE,rmm.*logger>)

target_compile_options(
cuvs INTERFACE $<$<COMPILE_LANG_AND_ID:CUDA,NVIDIA>:--expt-extended-lambda
Expand Down Expand Up @@ -704,7 +705,7 @@ target_compile_definitions(cuvs::cuvs INTERFACE $<$<BOOL:${CUVS_NVTX}>:NVTX_ENAB
target_link_libraries(
cuvs_c
PUBLIC cuvs::cuvs ${CUVS_CTK_MATH_DEPENDENCIES}
PRIVATE raft::raft rmm::rmm_logger_impl
PRIVATE raft::raft rmm::rmm_logger_impl raft::raft_logger_impl
)

# ensure CUDA symbols aren't relocated to the middle of the debug build binaries
Expand Down
21 changes: 15 additions & 6 deletions cpp/bench/ann/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,11 @@ function(ConfigureAnnBench)
PRIVATE ${ConfigureAnnBench_LINKS}
nlohmann_json::nlohmann_json
Threads::Threads
$<TARGET_NAME_IF_EXISTS:raft::raft_logger>
$<$<BOOL:${GPU_BUILD}>:CUDA::cudart_static>
$<TARGET_NAME_IF_EXISTS:OpenMP::OpenMP_CXX>
$<TARGET_NAME_IF_EXISTS:conda_env>
$<TARGET_NAME_IF_EXISTS:cuvs_bench_rmm_logger>
$<TARGET_NAME_IF_EXISTS:cuvs_bench_logger>
)

set_target_properties(
Expand Down Expand Up @@ -175,9 +176,11 @@ function(ConfigureAnnBench)
add_dependencies(CUVS_ANN_BENCH_ALL ${BENCH_NAME})
endfunction()

if(CUVS_FAISS_ENABLE_GPU)
add_library(cuvs_bench_rmm_logger OBJECT)
target_link_libraries(cuvs_bench_rmm_logger PRIVATE rmm::rmm_logger_impl)
if(CUVS_FAISS_ENABLE_GPU OR CUVS_ANN_BENCH_SINGLE_EXE)
add_library(cuvs_bench_logger OBJECT)
target_link_libraries(
cuvs_bench_logger PRIVATE rmm::rmm_logger_impl $<TARGET_NAME_IF_EXISTS:raft::raft_logger>
)
endif()

# ##################################################################################################
Expand Down Expand Up @@ -303,8 +306,14 @@ if(CUVS_ANN_BENCH_SINGLE_EXE)

target_link_libraries(
ANN_BENCH
PRIVATE raft::raft nlohmann_json::nlohmann_json benchmark::benchmark dl fmt::fmt-header-only
spdlog::spdlog_header_only $<$<TARGET_EXISTS:CUDA::nvtx3>:CUDA::nvtx3> rmm::rmm_logger_impl
PRIVATE raft::raft
nlohmann_json::nlohmann_json
benchmark::benchmark
dl
fmt::fmt-header-only
spdlog::spdlog_header_only
$<$<TARGET_EXISTS:CUDA::nvtx3>:CUDA::nvtx3>
cuvs_bench_logger
)
set_target_properties(
ANN_BENCH
Expand Down
31 changes: 11 additions & 20 deletions cpp/bench/ann/src/common/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,16 @@ inline auto parse_string_flag(const char* arg, const char* pat, std::string& res

inline auto run_main(int argc, char** argv) -> int
{
bool force_overwrite = false;
bool build_mode = false;
bool search_mode = false;
bool no_lap_sync = false;
std::string data_prefix = "data";
std::string index_prefix = "index";
std::string new_override_kv = "";
std::string mode = "latency";
std::string threads_arg_txt = "";
std::vector<int> threads = {1, -1}; // min_thread, max_thread
std::string log_level_str = "";
[[maybe_unused]] int raft_log_level = 0; // raft::logger::get(RAFT_NAME).get_level();
bool force_overwrite = false;
bool build_mode = false;
bool search_mode = false;
bool no_lap_sync = false;
std::string data_prefix = "data";
std::string index_prefix = "index";
std::string new_override_kv = "";
std::string mode = "latency";
std::string threads_arg_txt = "";
std::vector<int> threads = {1, -1}; // min_thread, max_thread
kv_series override_kv{};

char arg0_default[] = "benchmark"; // NOLINT
Expand Down Expand Up @@ -639,12 +637,7 @@ inline auto run_main(int argc, char** argv) -> int
parse_string_flag(argv[i], "--index_prefix", index_prefix) ||
parse_string_flag(argv[i], "--mode", mode) ||
parse_string_flag(argv[i], "--override_kv", new_override_kv) ||
parse_string_flag(argv[i], "--threads", threads_arg_txt) ||
parse_string_flag(argv[i], "--raft_log_level", log_level_str)) {
if (!log_level_str.empty()) {
raft_log_level = std::stoi(log_level_str);
log_level_str = "";
}
parse_string_flag(argv[i], "--threads", threads_arg_txt)) {
if (!threads_arg_txt.empty()) {
auto threads_arg = split(threads_arg_txt, ':');
threads[0] = std::stoi(threads_arg[0]);
Expand Down Expand Up @@ -673,8 +666,6 @@ inline auto run_main(int argc, char** argv) -> int
}
}

// raft::logger::get(RAFT_NAME).set_level(raft_log_level);

Mode metric_objective = Mode::kLatency;
if (mode == "throughput") { metric_objective = Mode::kThroughput; }

Expand Down
3 changes: 2 additions & 1 deletion cpp/include/cuvs/cluster/kmeans.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cuvs/distance/distance.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/host_mdspan.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resources.hpp>
#include <raft/random/rng_state.hpp>

Expand Down Expand Up @@ -85,7 +86,7 @@ struct params : base_params {
/**
* verbosity level.
*/
int verbosity = RAFT_LEVEL_INFO;
raft::level_enum verbosity = raft::level_enum::info;

/**
* Seed to the random number generator.
Expand Down
12 changes: 5 additions & 7 deletions cpp/src/cluster/detail/kmeans.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <raft/core/device_mdarray.hpp>
#include <raft/core/host_mdarray.hpp>
#include <raft/core/kvp.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdarray.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand Down Expand Up @@ -56,8 +56,6 @@

namespace cuvs::cluster::kmeans::detail {

// TODO(cjnolet): RAFT_NAME needs to be removed and the raft::logger fixed to not require it
static const std::string RAFT_NAME = "raft";
static const std::string CUVS_NAME = "cuvs";

// =========================================================
Expand Down Expand Up @@ -373,7 +371,7 @@ void kmeans_fit_main(raft::resources const& handle,
rmm::device_uvector<char>& workspace)
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope("kmeans_fit_main");
raft::logger::get(RAFT_NAME).set_level(params.verbosity);
raft::default_logger().set_level(params.verbosity);
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
Expand Down Expand Up @@ -879,7 +877,7 @@ void kmeans_fit(raft::resources const& handle,
pams.n_clusters);
}

raft::logger::get(RAFT_NAME).set_level(pams.verbosity);
raft::default_logger().set_level(pams.verbosity);

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

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

// Allocate memory
Expand Down Expand Up @@ -1218,7 +1216,7 @@ void kmeans_transform(raft::resources const& handle,
raft::device_matrix_view<DataT> X_new)
{
raft::common::nvtx::range<cuvs::common::nvtx::domain::cuvs> fun_scope("kmeans_transform");
raft::logger::get(RAFT_NAME).set_level(pams.verbosity);
raft::default_logger().set_level(pams.verbosity);
cudaStream_t stream = raft::resource::get_cuda_stream(handle);
auto n_samples = X.extent(0);
auto n_features = X.extent(1);
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/cluster/detail/kmeans_auto_find_k.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <raft/core/device_mdspan.hpp>
#include <raft/core/error.hpp>
#include <raft/core/host_mdarray.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resources.hpp>
#include <raft/stats/dispersion.cuh>
Expand Down Expand Up @@ -230,4 +230,4 @@ void find_k(raft::resources const& handle,
n_iter);
}
}
} // namespace cuvs::cluster::kmeans::detail
} // namespace cuvs::cluster::kmeans::detail
4 changes: 2 additions & 2 deletions cpp/src/cluster/detail/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

#include <cuvs/distance/distance.hpp>
#include <raft/core/cudart_utils.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/device_memory_resource.hpp>
Expand Down Expand Up @@ -59,7 +60,6 @@

namespace cuvs::cluster::kmeans::detail {

static const std::string RAFT_NAME = "raft";
constexpr static inline float kAdjustCentersWeight = 7.0f;

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/cluster/detail/kmeans_common.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <raft/core/device_mdarray.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/kvp.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdarray.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand Down
2 changes: 2 additions & 0 deletions cpp/src/distance/detail/sparse/coo_spmv_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#pragma once

#include <raft/core/detail/macros.hpp>

#include <cub/block/block_load.cuh>
#include <cub/block/block_radix_sort.cuh>
#include <cub/block/block_store.cuh>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/ann_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <cuvs/distance/distance.hpp>
#include <raft/common/nvtx.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/util/cuda_utils.cuh>
#include <raft/util/cudart_utils.hpp>
#include <raft/util/integer_utils.hpp>
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/neighbors/detail/cagra/add_nodes.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

namespace cuvs::neighbors::cagra {

static const std::string RAFT_NAME = "raft";

template <class T, class IdxT, class Accessor>
void add_node_core(
raft::resources const& handle,
Expand Down
4 changes: 1 addition & 3 deletions cpp/src/neighbors/detail/cagra/cagra_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <raft/core/host_device_accessor.hpp>
#include <raft/core/host_mdarray.hpp>
#include <raft/core/host_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>

#include <cuvs/distance/distance.hpp>
Expand All @@ -46,8 +46,6 @@

namespace cuvs::neighbors::cagra::detail {

static const std::string RAFT_NAME = "raft";

template <typename IdxT>
void write_to_graph(raft::host_matrix_view<IdxT, int64_t, raft::row_major> knn_graph,
raft::host_matrix_view<int64_t, int64_t, raft::row_major> neighbors_host_view,
Expand Down
4 changes: 1 addition & 3 deletions cpp/src/neighbors/detail/cagra/cagra_serialize.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include <cuvs/neighbors/cagra.hpp>
#include <raft/core/host_mdarray.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdarray.hpp>
#include <raft/core/mdspan_types.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand All @@ -34,8 +34,6 @@

namespace cuvs::neighbors::cagra::detail {

static const std::string RAFT_NAME = "raft";

constexpr int serialization_version = 4;

/**
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/cagra/compute_distance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <cuvs/distance/distance.hpp>
#include <cuvs/neighbors/cagra.hpp>
#include <cuvs/neighbors/common.hpp>
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>

// TODO: This shouldn't be invoking spatial/knn
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/cagra/search_multi_cta.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <raft/core/detail/macros.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/device_properties.hpp>
#include <raft/core/resources.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "utils.hpp"

#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/device_properties.hpp>
#include <raft/core/resources.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/cagra/search_multi_kernel.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "utils.hpp"

#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resources.hpp>

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/cagra/search_single_cta.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "utils.hpp"

#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/device_properties.hpp>
#include <raft/core/resources.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#include <cuvs/distance/distance.hpp>
#include <raft/core/device_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/device_properties.hpp>
#include <raft/core/resources.hpp>
Expand Down Expand Up @@ -64,7 +64,6 @@

namespace cuvs::neighbors::cagra::detail {
namespace single_cta_search {
using raft::RAFT_NAME; // TODO: this is required for RAFT_LOG_XXX messages.

// #define _CLK_BREAKDOWN

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/dataset_serialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <raft/core/resources.hpp>
#include <raft/core/serialize.hpp>

#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>

#include <cuda_fp16.h>

Expand Down
2 changes: 0 additions & 2 deletions cpp/src/neighbors/detail/dynamic_batching.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@

namespace cuvs::neighbors::dynamic_batching::detail {

using raft::RAFT_NAME; // TODO: a workaround for RAFT_LOG_XXX macros

/**
* A helper to make the requester threads more cooperative when busy-spinning.
* It is used in the wait loops across this file to reduce the CPU usage.
Expand Down
4 changes: 1 addition & 3 deletions cpp/src/neighbors/detail/vamana/vamana_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <raft/core/host_device_accessor.hpp>
#include <raft/core/host_mdarray.hpp>
#include <raft/core/host_mdspan.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/matrix/copy.cuh>
#include <raft/matrix/init.cuh>
Expand All @@ -52,8 +52,6 @@ namespace cuvs::neighbors::experimental::vamana::detail {
* @{
*/

static const std::string RAFT_NAME = "raft";

static const int blockD = 32;
static const int maxBlocks = 10000;

Expand Down
Loading
Loading