Skip to content

Commit

Permalink
Adapt for raft logger
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Dec 17, 2024
1 parent b859bc5 commit 88341fa
Show file tree
Hide file tree
Showing 34 changed files with 49 additions and 65 deletions.
24 changes: 12 additions & 12 deletions cpp/bench/ann/src/common/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,18 +597,18 @@ 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
std::string log_level_str = "";
[[maybe_unused]] raft::level_enum raft_log_level = raft::level_enum::off;
kv_series override_kv{};

char arg0_default[] = "benchmark"; // NOLINT
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
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/vamana/vamana_serialize.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <cuvs/neighbors/vamana.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/nvtx.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/vamana/vamana_structs.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 <cuvs/distance/distance.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/detail/vpq_dataset.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/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>
#include <raft/linalg/map.cuh>
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/neighbors/ivf_flat/ivf_flat_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "../../cluster/kmeans_balanced.cuh"
#include "../detail/ann_utils.cuh"
#include <cuvs/distance/distance.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger-macros.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: 1 addition & 1 deletion cpp/src/neighbors/ivf_flat/ivf_flat_interleaved_scan.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "../detail/ann_utils.cuh"
#include <cuvs/distance/distance.hpp>
#include <raft/core/logger-ext.hpp> // RAFT_LOG_TRACE
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>
#include <raft/matrix/detail/select_warpsort.cuh>
#include <raft/util/cuda_rt_essentials.hpp> // RAFT_CUDA_TRY
Expand Down
3 changes: 2 additions & 1 deletion cpp/src/neighbors/ivf_flat/ivf_flat_search.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include <cuvs/distance/distance.hpp> // is_min_close, DistanceType
#include <cuvs/selection/select_k.hpp> // cuvs::selection::select_k
#include <raft/core/error.hpp>
#include <raft/core/logger-ext.hpp> // RAFT_LOG_TRACE
#include <raft/core/logger-macros.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resources.hpp> // raft::resources
#include <raft/linalg/gemm.cuh> // raft::linalg::gemm
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/neighbors/ivf_pq/ivf_pq_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "../../cluster/kmeans_balanced.cuh"

#include <raft/core/device_mdarray.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/mdspan.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
Expand Down Expand Up @@ -68,7 +68,6 @@
#include <variant>

namespace cuvs::neighbors::ivf_pq::detail {
using raft::RAFT_NAME; // TODO: this is required for RAFT_LOG_XXX messages.
using namespace cuvs::spatial::knn::detail; // NOLINT

using internal_extents_t = int64_t; // The default mdspan extent type used internally.
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/ivf_pq/ivf_pq_fp_8bit.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <raft/core/cudart_utils.hpp>
#include <raft/core/device_mdarray.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/nvtx.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resources.hpp>
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/neighbors/ivf_pq/ivf_pq_search.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <cuvs/selection/select_k.hpp>
#include <raft/core/cudart_utils.hpp>
#include <raft/core/device_mdarray.hpp>
#include <raft/core/logger-ext.hpp>
#include <raft/core/logger.hpp>
#include <raft/core/operators.hpp>
#include <raft/core/resource/cuda_stream.hpp>
#include <raft/core/resource/custom_resource.hpp>
Expand Down
Loading

0 comments on commit 88341fa

Please sign in to comment.