From 641f164e9442c28694eec23391905680585ab7a9 Mon Sep 17 00:00:00 2001 From: Tamas Bela Feher Date: Fri, 5 May 2023 01:11:41 +0200 Subject: [PATCH] Remove pool_size() calls from debug printouts (#1484) 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: https://github.com/rapidsai/raft/pull/1484 --- cpp/include/raft/cluster/detail/kmeans_balanced.cuh | 2 +- cpp/include/raft/matrix/detail/select_radix.cuh | 7 ++----- cpp/include/raft/matrix/detail/select_warpsort.cuh | 5 +---- .../raft/neighbors/detail/cagra/cagra_build.cuh | 5 +---- .../raft/neighbors/detail/ivf_flat_search-inl.cuh | 2 +- cpp/include/raft/neighbors/detail/ivf_pq_build.cuh | 10 ++-------- cpp/include/raft/neighbors/detail/ivf_pq_search.cuh | 2 +- cpp/include/raft/util/memory_pool-inl.hpp | 2 +- 8 files changed, 10 insertions(+), 25 deletions(-) diff --git a/cpp/include/raft/cluster/detail/kmeans_balanced.cuh b/cpp/include/raft/cluster/detail/kmeans_balanced.cuh index 4f7cae1ad9..eb89ebe402 100644 --- a/cpp/include/raft/cluster/detail/kmeans_balanced.cuh +++ b/cpp/include/raft/cluster/detail/kmeans_balanced.cuh @@ -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. diff --git a/cpp/include/raft/matrix/detail/select_radix.cuh b/cpp/include/raft/matrix/detail/select_radix.cuh index 7ac40ac0eb..b7d02d6b52 100644 --- a/cpp/include/raft/matrix/detail/select_radix.cuh +++ b/cpp/include/raft/matrix/detail/select_radix.cuh @@ -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> counters(max_chunk_size, stream, mr); @@ -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 buf1(len * max_chunk_size, stream, mr); rmm::device_uvector idx_buf1(len * max_chunk_size, stream, mr); diff --git a/cpp/include/raft/matrix/detail/select_warpsort.cuh b/cpp/include/raft/matrix/detail/select_warpsort.cuh index c19e9391ce..dc86a04733 100644 --- a/cpp/include/raft/matrix/detail/select_warpsort.cuh +++ b/cpp/include/raft/matrix/detail/select_warpsort.cuh @@ -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 tmp_val(num_of_block * k * batch_size, stream, mr); rmm::device_uvector tmp_idx(num_of_block * k * batch_size, stream, mr); diff --git a/cpp/include/raft/neighbors/detail/cagra/cagra_build.cuh b/cpp/include/raft/neighbors/detail/cagra/cagra_build.cuh index 4d63fb7999..54c806ba13 100644 --- a/cpp/include/raft/neighbors/detail/cagra/cagra_build.cuh +++ b/cpp/include/raft/neighbors/detail/cagra/cagra_build.cuh @@ -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 vec_batches(dataset.data_handle(), dataset.extent(0), diff --git a/cpp/include/raft/neighbors/detail/ivf_flat_search-inl.cuh b/cpp/include/raft/neighbors/detail/ivf_flat_search-inl.cuh index 89a4597acf..c364118fdd 100644 --- a/cpp/include/raft/neighbors/detail/ivf_flat_search-inl.cuh +++ b/cpp/include/raft/neighbors/detail/ivf_flat_search-inl.cuh @@ -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(handle, diff --git a/cpp/include/raft/neighbors/detail/ivf_pq_build.cuh b/cpp/include/raft/neighbors/detail/ivf_pq_build.cuh index 208f7fd875..b17b3a3559 100644 --- a/cpp/include/raft/neighbors/detail/ivf_pq_build.cuh +++ b/cpp/include/raft/neighbors/detail/ivf_pq_build.cuh @@ -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 managed_memory( @@ -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 managed_memory( diff --git a/cpp/include/raft/neighbors/detail/ivf_pq_search.cuh b/cpp/include/raft/neighbors/detail/ivf_pq_search.cuh index 0aa2862cf4..c1c15d3424 100644 --- a/cpp/include/raft/neighbors/detail/ivf_pq_search.cuh +++ b/cpp/include/raft/neighbors/detail/ivf_pq_search.cuh @@ -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. diff --git a/cpp/include/raft/util/memory_pool-inl.hpp b/cpp/include/raft/util/memory_pool-inl.hpp index a227b6e53f..070c8f4e30 100644 --- a/cpp/include/raft/util/memory_pool-inl.hpp +++ b/cpp/include/raft/util/memory_pool-inl.hpp @@ -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"); * }