Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
device.hpp
Go to the documentation of this file.
1#pragma once
2
9#include <array>
10#include <cstddef>
11#include <cstdint>
12#include <string>
13#include <vector>
14
15namespace uni20::cuda
16{
17
23{
25 std::string name{};
26
28 std::array<std::uint8_t, 16> uuid{};
29
31 std::size_t total_global_memory = 0;
32
35
38
41
43 int warp_size = 0;
44
47
50
52 std::size_t shared_memory_per_block = 0;
53
56
59
61 int pci_domain = 0;
62
64 int pci_bus = 0;
65
67 int pci_device = 0;
68
70 bool concurrent_kernels = false;
71
73 bool unified_addressing = false;
74
76 bool can_map_host_memory = false;
77
79 bool managed_memory = false;
80
83
86
89
92
94 bool cooperative_launch = false;
95
97 bool ecc_enabled = false;
98};
99
105class Device {
106 public:
110 [[nodiscard]] static Device get(int ordinal);
111
113 [[nodiscard]] static int count();
114
117 [[nodiscard]] static std::vector<Device> enumerate();
118
120 [[nodiscard]] static Device current();
121
123 [[nodiscard]] constexpr int ordinal() const noexcept { return ordinal_; }
124
126 [[nodiscard]] DeviceCapabilities const& capabilities() const;
127
128 friend constexpr bool operator==(Device const&, Device const&) = default;
129
130 private:
131 explicit constexpr Device(int ordinal) noexcept : ordinal_(ordinal) {}
132
133 int ordinal_;
134};
135
136} // namespace uni20::cuda
Validated CUDA device identity with cached immutable capabilities.
Definition device.hpp:105
static std::vector< Device > enumerate()
Discover every visible CUDA device in ordinal order.
Definition device.cpp:111
friend constexpr bool operator==(Device const &, Device const &)=default
static Device get(int ordinal)
Validate and return one CUDA device.
Definition device.cpp:103
static int count()
Return the number of CUDA devices visible to this process.
Definition device.cpp:109
DeviceCapabilities const & capabilities() const
Return this device's cached immutable hardware capabilities.
Definition device.cpp:130
static Device current()
Return the CUDA device currently selected on the calling thread.
Definition device.cpp:123
constexpr int ordinal() const noexcept
Return this device's CUDA runtime ordinal.
Definition device.hpp:123
Definition cublas/execution.hpp:18
Immutable hardware properties cached for one CUDA device ordinal.
Definition device.hpp:23
int max_threads_per_block
Maximum threads in one thread block.
Definition device.hpp:46
int pci_device
PCI device identifier.
Definition device.hpp:67
int max_threads_per_multiprocessor
Maximum resident threads per streaming multiprocessor.
Definition device.hpp:49
int async_engine_count
Number of asynchronous copy engines.
Definition device.hpp:58
bool pageable_memory_access
Whether the device can directly access pageable host memory.
Definition device.hpp:85
bool cooperative_launch
Whether cooperative kernel launch is supported.
Definition device.hpp:94
std::string name
CUDA runtime device name.
Definition device.hpp:25
int warp_size
Hardware warp size in threads.
Definition device.hpp:43
std::size_t shared_memory_per_multiprocessor
Maximum shared memory per streaming multiprocessor in bytes.
Definition device.hpp:55
std::size_t shared_memory_per_block
Maximum shared memory per thread block in bytes.
Definition device.hpp:52
bool ecc_enabled
Whether ECC is enabled on the device.
Definition device.hpp:97
bool memory_pools_supported
Whether stream-ordered CUDA memory pools are supported.
Definition device.hpp:88
bool concurrent_kernels
Whether the device supports concurrent kernel execution.
Definition device.hpp:70
bool can_map_host_memory
Whether the device can map page-locked host memory.
Definition device.hpp:76
std::array< std::uint8_t, 16 > uuid
Stable 16-byte CUDA device UUID.
Definition device.hpp:28
bool stream_priorities_supported
Whether CUDA stream priorities are supported.
Definition device.hpp:91
int compute_capability_minor
CUDA compute-capability minor version.
Definition device.hpp:37
int multiprocessor_count
Number of streaming multiprocessors.
Definition device.hpp:40
bool concurrent_managed_access
Whether CPU and device may concurrently access managed memory.
Definition device.hpp:82
bool managed_memory
Whether the device supports managed-memory allocation.
Definition device.hpp:79
std::size_t total_global_memory
Total device global memory in bytes.
Definition device.hpp:31
int compute_capability_major
CUDA compute-capability major version.
Definition device.hpp:34
int pci_bus
PCI bus identifier.
Definition device.hpp:64
bool unified_addressing
Whether the device uses unified virtual addressing.
Definition device.hpp:73
int pci_domain
PCI domain identifier.
Definition device.hpp:61