cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
Classes | Typedefs | Enumerations | Functions
cuda::device Namespace Reference

Definitions and functionality related to CUDA devices (not including the device wrapper type device_t itself) More...

Classes

struct  compute_architecture_t
 A numeric designator of an architectural generation of CUDA devices. More...
 
struct  compute_capability_t
 A numeric designator of the computational capabilities of a CUDA device. More...
 
struct  pci_location_t
 Location "coordinates" for a CUDA device on a PCIe bus. More...
 
struct  properties_t
 A structure holding a collection various properties of a device. More...
 
struct  stream_priority_range_t
 A range of priorities supported by a CUDA device; ranges from the higher numeric value to the lower. More...
 

Typedefs

using id_t = int
 Numeric ID of a CUDA device used by the CUDA Runtime API.
 
using attribute_t = cudaDeviceAttr
 CUDA devices have both "attributes" and "properties". More...
 
using attribute_value_t = int
 All CUDA device attributes (cuda::device::attribute_t) have a value of this type.
 
using pair_attribute_t = cudaDeviceP2PAttr
 While Individual CUDA devices have individual "attributes" (attribute_t), there are also attributes characterizing pairs; this type is used for identifying/indexing them, aliasing cudaDeviceP2PAttr.
 

Enumerations

enum  : device::id_t { default_device_id = 0 }
 

Functions

device_t get (id_t device_id) noexcept
 Returns a proxy for the CUDA device with a given id. More...
 
device_t get (pci_location_t pci_id)
 Obtain a proxy to a device using its PCI bus location. More...
 
device_t get (const ::std::string &pci_id_str)
 Obtain a proxy to a device using a string with its PCI bus location. More...
 
constexpr compute_capability_t make_compute_capability (unsigned combined) noexcept
 A named constructor idiom for {compute_capability_t}. More...
 
constexpr compute_capability_t make_compute_capability (unsigned major, unsigned minor) noexcept
 A named constructor idiom for {compute_capability_t}.
 
device::id_t count ()
 Get the number of CUDA devices usable on the system (with the current CUDA library and kernel driver) More...
 

Detailed Description

Definitions and functionality related to CUDA devices (not including the device wrapper type device_t itself)

Typedef Documentation

◆ attribute_t

using cuda::device::attribute_t = typedef cudaDeviceAttr

CUDA devices have both "attributes" and "properties".

This is the type for attribute identifiers/indices, aliasing cudaDeviceAttr.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum : device::id_t
Enumerator
default_device_id 

If the CUDA runtime has not been set to a specific device, this is the ID of the device it defaults to.

Function Documentation

◆ count()

device::id_t cuda::device::count ( )
inline

Get the number of CUDA devices usable on the system (with the current CUDA library and kernel driver)

Note
This should be returning an unsigned value; unfortunately, device::id_t is signed in CUDA for some reason and we maintain compatibility (although this might change in the future). So... the returned type is the same as in cudaGetDeviceCount, a signed integer.
Returns
the number of CUDA devices on this system
Exceptions
cuda::errorif the device count could not be obtained

◆ get() [1/3]

device_t cuda::device::get ( id_t  device_id)
inlinenoexcept

Returns a proxy for the CUDA device with a given id.

Parameters
device_idthe ID for which to obtain the device proxy
Note
direct constructor access is blocked so that you don't get the idea you're actually creating devices

◆ get() [2/3]

device_t cuda::device::get ( pci_location_t  pci_id)
inline

Obtain a proxy to a device using its PCI bus location.

Parameters
pci_idThe domain-bus-device triplet locating the GPU on the PCI bus
Returns
a device_t proxy object for the device at the specified location

◆ get() [3/3]

device_t cuda::device::get ( const ::std::string &  pci_id_str)
inline

Obtain a proxy to a device using a string with its PCI bus location.

Parameters
pci_id_strA string listing of the GPU's location on the PCI bus
Returns
a device_t proxy object for the device at the specified location
Note
I'm not very happy about the assumption that get-device-by-string means get-device-by-pci-location; that's not such a great assumption to make IMHO. But - it's convenient for now and there's no immediate risk from some other obvious source of CUDA-device-identifying strings.

◆ make_compute_capability()

constexpr compute_capability_t cuda::device::make_compute_capability ( unsigned  combined)
noexcept

A named constructor idiom for {compute_capability_t}.

Parameters
combinedA combination of the major and minor version number, e.g. 91 for major 9, minor 1