Skip to content

Commit

Permalink
Remove pool_size() calls from debug printouts (#1484)
Browse files Browse the repository at this point in the history
The return type of `get_pool_memory_resource` was changed in #1469 from `pool_memory_resource` to `device_memory_resource`. There are debug logs in the code ([example](https://github.com/rapidsai/raft/blob/a44ca96c5cddec7ca67b510f3c21163d3958bc7e/cpp/include/raft/neighbors/detail/ivf_pq_build.cuh#L1328-L1329)), which query the pool size, that would fail when debug logging is enabled. This PR removes the `pool_size() ` calls, so that the code can be compiled with debug mode on.

Authors:
  - Tamas Bela Feher (https://github.com/tfeher)
  - Corey J. Nolet (https://github.com/cjnolet)

Approvers:
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1484
  • Loading branch information
tfeher authored May 4, 2023
1 parent 212cfe9 commit 641f164
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion cpp/include/raft/cluster/detail/kmeans_balanced.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ void build_hierarchical(const raft::device_resources& handle,
raft::get_pool_memory_resource(device_memory, mem_per_row * size_t(max_minibatch_size));
if (pool_guard) {
RAFT_LOG_DEBUG("build_hierarchical: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
mem_per_row * size_t(max_minibatch_size));
}

// Precompute the L2 norm of the dataset if relevant.
Expand Down
7 changes: 2 additions & 5 deletions cpp/include/raft/matrix/detail/select_radix.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ void radix_topk(const T* in,
auto pool_guard = raft::get_pool_memory_resource(mr, mem_req);
if (pool_guard) {
RAFT_LOG_DEBUG("radix::select_k: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
mem_req);
}

rmm::device_uvector<Counter<T, IdxT>> counters(max_chunk_size, stream, mr);
Expand Down Expand Up @@ -1031,10 +1031,7 @@ void radix_topk_one_block(const T* in,
max_chunk_size * len * 2 * (sizeof(T) + sizeof(IdxT)) +
256 * 4 // might need extra memory for alignment
);
if (pool_guard) {
RAFT_LOG_DEBUG("radix::select_k: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
}
if (pool_guard) { RAFT_LOG_DEBUG("radix::select_k: using pool memory resource"); }

rmm::device_uvector<T> buf1(len * max_chunk_size, stream, mr);
rmm::device_uvector<IdxT> idx_buf1(len * max_chunk_size, stream, mr);
Expand Down
5 changes: 1 addition & 4 deletions cpp/include/raft/matrix/detail/select_warpsort.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -990,10 +990,7 @@ void select_k_(int num_of_block,
{
auto pool_guard = raft::get_pool_memory_resource(
mr, num_of_block * k * batch_size * 2 * std::max(sizeof(T), sizeof(IdxT)));
if (pool_guard) {
RAFT_LOG_DEBUG("warpsort::select_k: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
}
if (pool_guard) { RAFT_LOG_DEBUG("warpsort::select_k: using pool memory resource"); }

rmm::device_uvector<T> tmp_val(num_of_block * k * batch_size, stream, mr);
rmm::device_uvector<IdxT> tmp_idx(num_of_block * k * batch_size, stream, mr);
Expand Down
5 changes: 1 addition & 4 deletions cpp/include/raft/neighbors/detail/cagra/cagra_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ void build_knn_graph(raft::device_resources const& res,

rmm::mr::device_memory_resource* device_memory = nullptr;
auto pool_guard = raft::get_pool_memory_resource(device_memory, 1024 * 1024);
if (pool_guard) {
RAFT_LOG_DEBUG("ivf_pq using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
}
if (pool_guard) { RAFT_LOG_DEBUG("ivf_pq using pool memory resource"); }

raft::spatial::knn::detail::utils::batch_load_iterator<DataT> vec_batches(dataset.data_handle(),
dataset.extent(0),
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/neighbors/detail/ivf_flat_search-inl.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ inline void search(raft::device_resources const& handle,
auto pool_guard = raft::get_pool_memory_resource(mr, n_queries * n_probes * k * 16);
if (pool_guard) {
RAFT_LOG_DEBUG("ivf_flat::search: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
n_queries * n_probes * k * 16ull);
}

return search_impl<T, float, IdxT>(handle,
Expand Down
10 changes: 2 additions & 8 deletions cpp/include/raft/neighbors/detail/ivf_pq_build.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,7 @@ void extend(raft::device_resources const& handle,

rmm::mr::device_memory_resource* device_memory = nullptr;
auto pool_guard = raft::get_pool_memory_resource(device_memory, 1024 * 1024);
if (pool_guard) {
RAFT_LOG_DEBUG("ivf_pq::extend: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
}
if (pool_guard) { RAFT_LOG_DEBUG("ivf_pq::extend: using pool memory resource"); }

rmm::mr::managed_memory_resource managed_memory_upstream;
rmm::mr::pool_memory_resource<rmm::mr::managed_memory_resource> managed_memory(
Expand Down Expand Up @@ -1536,10 +1533,7 @@ auto build(raft::device_resources const& handle,

rmm::mr::device_memory_resource* device_memory = nullptr;
auto pool_guard = raft::get_pool_memory_resource(device_memory, 1024 * 1024);
if (pool_guard) {
RAFT_LOG_DEBUG("ivf_pq::build: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
}
if (pool_guard) { RAFT_LOG_DEBUG("ivf_pq::build: using pool memory resource"); }

rmm::mr::managed_memory_resource managed_memory_upstream;
rmm::mr::pool_memory_resource<rmm::mr::managed_memory_resource> managed_memory(
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/neighbors/detail/ivf_pq_search.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ inline void search(raft::device_resources const& handle,
auto pool_guard = raft::get_pool_memory_resource(mr, n_queries * n_probes * k * 16);
if (pool_guard) {
RAFT_LOG_DEBUG("ivf_pq::search: using pool memory resource with initial size %zu bytes",
pool_guard->pool_size());
n_queries * n_probes * k * 16ull);
}

// Maximum number of query vectors to search at the same time.
Expand Down
2 changes: 1 addition & 1 deletion cpp/include/raft/util/memory_pool-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace raft {
* void my_func(..., size_t n, rmm::mr::device_memory_resource* mr = nullptr) {
* auto pool_guard = raft::get_pool_memory_resource(mr, 2 * n * sizeof(float));
* if (pool_guard){
* RAFT_LOG_INFO("Created a pool %zu bytes", pool_guard->pool_size());
* RAFT_LOG_INFO("Created a pool");
* } else {
* RAFT_LOG_INFO("Using the current default or explicitly passed device memory resource");
* }
Expand Down

0 comments on commit 641f164

Please sign in to comment.