Home
librmm
libucxx
ucxx
nightly (26.12)
nightly (26.12)
stable (26.10)
legacy (26.08)
Toggle main menu visibility
Loading...
Searching...
No Matches
include
rmm
cuda_device.hpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*/
5
#pragma once
6
7
#include <
rmm/aligned.hpp
>
8
#include <rmm/detail/export.hpp>
9
10
#include <cstddef>
11
#include <utility>
12
13
RMM_NAMESPACE_BEGIN
14
15
struct
cuda_device_id;
16
cuda_device_id
get_current_cuda_device
();
17
27
struct
cuda_device_id
{
28
using
value_type
= int;
29
33
cuda_device_id
() noexcept : id_{
get_current_cuda_device
().
value
()} {}
34
40
explicit
constexpr
cuda_device_id
(
value_type
dev_id) noexcept : id_{dev_id} {}
41
43
[[nodiscard]]
constexpr
value_type
value
() const noexcept {
return
id_; }
44
45
// TODO re-add doxygen comment specifier /** for these hidden friend operators once this Breathe
46
// bug is fixed: https://github.com/breathe-doc/breathe/issues/916
48
55
[[nodiscard]]
constexpr
friend
bool
operator==(
cuda_device_id
const
& lhs,
56
cuda_device_id
const
& rhs)
noexcept
57
{
58
return
lhs.value() == rhs.value();
59
}
60
68
[[nodiscard]]
constexpr
friend
bool
operator!=(cuda_device_id
const
& lhs,
69
cuda_device_id
const
& rhs)
noexcept
70
{
71
return
lhs.value() != rhs.value();
72
}
74
private
:
75
value_type id_;
76
};
77
85
cuda_device_id
get_current_cuda_device
();
86
92
int
get_num_cuda_devices
();
93
99
std::pair<std::size_t, std::size_t>
available_device_memory
();
100
109
std::size_t
percent_of_free_device_memory
(
int
percent);
110
115
struct
cuda_set_device_raii
{
121
explicit
cuda_set_device_raii
(
cuda_device_id
dev_id);
125
~cuda_set_device_raii
() noexcept;
126
127
cuda_set_device_raii
(
cuda_set_device_raii
const&) = delete;
128
cuda_set_device_raii
& operator=(
cuda_set_device_raii
const&) = delete;
129
cuda_set_device_raii
(
cuda_set_device_raii
&&) = delete;
130
cuda_set_device_raii
& operator=(
cuda_set_device_raii
&&) = delete;
131
132
private:
133
cuda_device_id
old_device_;
134
bool
needs_reset_;
135
};
136
// end of group
138
RMM_NAMESPACE_END
aligned.hpp
rmm::available_device_memory
std::pair< std::size_t, std::size_t > available_device_memory()
Returns the available and total device memory in bytes for the current device.
rmm::get_current_cuda_device
cuda_device_id get_current_cuda_device()
Returns a cuda_device_id for the current device.
rmm::get_num_cuda_devices
int get_num_cuda_devices()
Returns the number of CUDA devices in the system.
rmm::percent_of_free_device_memory
std::size_t percent_of_free_device_memory(int percent)
Returns the approximate specified percent of available device memory on the current CUDA device,...
rmm::cuda_device_id
Strong type for a CUDA device identifier.
Definition
cuda_device.hpp:27
rmm::cuda_device_id::cuda_device_id
constexpr cuda_device_id(value_type dev_id) noexcept
Construct a cuda_device_id from the specified integer value.
Definition
cuda_device.hpp:40
rmm::cuda_device_id::cuda_device_id
cuda_device_id() noexcept
Construct a cuda_device_id from the current device.
Definition
cuda_device.hpp:33
rmm::cuda_device_id::value
constexpr value_type value() const noexcept
The wrapped integer value.
Definition
cuda_device.hpp:43
rmm::cuda_device_id::value_type
int value_type
Integer type used for device identifier.
Definition
cuda_device.hpp:28
rmm::cuda_set_device_raii::~cuda_set_device_raii
~cuda_set_device_raii() noexcept
Reactivates the previous CUDA device.
rmm::cuda_set_device_raii::cuda_set_device_raii
cuda_set_device_raii(cuda_device_id dev_id)
Construct a new cuda_set_device_raii object and sets the current CUDA device to dev_id.
Generated by
1.18.0