From 995b2441087722b52ef2081747b63a86938508bb Mon Sep 17 00:00:00 2001 From: tsuki <12711693+enp1s0@users.noreply.github.com> Date: Sun, 2 Feb 2025 02:57:48 +0900 Subject: [PATCH] Fix std::lock_guard use for gcc 14 support (#639) The constructor of `std::lock_guard` in gcc 14 , which is supported by CUDA 12.8, has the `nodiscard` attribute. This PR fixes the error occurring with gcc 14. Authors: - tsuki (https://github.com/enp1s0) Approvers: - Corey J. Nolet (https://github.com/cjnolet) - Artem M. Chirkin (https://github.com/achirkin) URL: https://github.com/rapidsai/cuvs/pull/639 --- cpp/bench/ann/src/common/thread_pool.hpp | 2 +- cpp/src/neighbors/iface/iface.hpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cpp/bench/ann/src/common/thread_pool.hpp b/cpp/bench/ann/src/common/thread_pool.hpp index 9d0218606..e2192daea 100644 --- a/cpp/bench/ann/src/common/thread_pool.hpp +++ b/cpp/bench/ann/src/common/thread_pool.hpp @@ -61,7 +61,7 @@ class fixed_thread_pool { finished_.store(true, std::memory_order_relaxed); for (unsigned i = 0; i < threads_.size(); ++i) { auto& task = tasks_[i]; - std::lock_guard(task.mtx); + std::lock_guard lock(task.mtx); task.cv.notify_one(); threads_[i].join(); diff --git a/cpp/src/neighbors/iface/iface.hpp b/cpp/src/neighbors/iface/iface.hpp index 98ef3fdd3..59d3e12d0 100644 --- a/cpp/src/neighbors/iface/iface.hpp +++ b/cpp/src/neighbors/iface/iface.hpp @@ -36,7 +36,7 @@ void build(const raft::device_resources& handle, const cuvs::neighbors::index_params* index_params, raft::mdspan, row_major, Accessor> index_dataset) { - std::lock_guard(*interface.mutex_); + std::lock_guard lock(*interface.mutex_); if constexpr (std::is_same>::value) { auto idx = cuvs::neighbors::ivf_flat::build( @@ -62,7 +62,7 @@ void extend( std::optional, layout_c_contiguous, Accessor2>> new_indices) { - std::lock_guard(*interface.mutex_); + std::lock_guard lock(*interface.mutex_); if constexpr (std::is_same>::value) { auto idx = @@ -141,7 +141,7 @@ void serialize(const raft::device_resources& handle, const cuvs::neighbors::iface& interface, std::ostream& os) { - std::lock_guard(*interface.mutex_); + std::lock_guard lock(*interface.mutex_); if constexpr (std::is_same>::value) { ivf_flat::serialize(handle, os, interface.index_.value()); @@ -157,7 +157,7 @@ void deserialize(const raft::device_resources& handle, cuvs::neighbors::iface& interface, std::istream& is) { - std::lock_guard(*interface.mutex_); + std::lock_guard lock(*interface.mutex_); if constexpr (std::is_same>::value) { ivf_flat::index idx(handle); @@ -179,7 +179,7 @@ void deserialize(const raft::device_resources& handle, cuvs::neighbors::iface& interface, const std::string& filename) { - std::lock_guard(*interface.mutex_); + std::lock_guard lock(*interface.mutex_); std::ifstream is(filename, std::ios::in | std::ios::binary); if (!is) { RAFT_FAIL("Cannot open file %s", filename.c_str()); }