gpu.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
9 
10 #include <rmm/cuda_device.hpp>
11 
12 namespace raft_proto {
13 namespace detail {
14 template <>
16  using value_type = typename rmm::cuda_device_id::value_type;
17  device_id() noexcept(false)
18  : id_{[]() {
19  auto raw_id = value_type{};
20  raft_proto::cuda_check(cudaGetDevice(&raw_id));
21  return raw_id;
22  }()} {};
23  device_id(value_type dev_id) noexcept : id_{dev_id} {};
24 
25  auto value() const noexcept { return id_.value(); }
26 
27  private:
28  rmm::cuda_device_id id_;
29 };
30 } // namespace detail
31 } // namespace raft_proto
Definition: buffer.hpp:24
void cuda_check(error_t const &err) noexcept(!GPU_ENABLED)
Definition: cuda_check.hpp:15
device_type
Definition: device_type.hpp:7
device_id(value_type dev_id) noexcept
Definition: gpu.hpp:23
device_id() noexcept(false)
Definition: gpu.hpp:17
auto value() const noexcept
Definition: gpu.hpp:25
typename rmm::cuda_device_id::value_type value_type
Definition: gpu.hpp:16
Definition: base.hpp:11