cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
cuda::device Namespace Reference

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

Namespaces

 peer_to_peer
 API functions and definitions relating to communications among peer CUDA GPU devices on the same system.
 

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...
 
class  primary_context_t
 A class for holding the primary context of a CUDA device. More...
 
struct  properties_t
 A structure holding a collection various properties of a device. More...
 

Typedefs

using limit_t = context::limit_t
 
using limit_value_t = context::limit_value_t
 
using shared_memory_bank_size_t = context::shared_memory_bank_size_t
 
using stream_priority_range_t = context::stream_priority_range_t
 
using multiprocessor_count_t = int
 Type of the number of mutiprocessors within a single GPU.
 
using id_t = CUdevice
 Numeric ID of a CUDA device used by the CUDA Runtime API. More...
 
using attribute_t = CUdevice_attribute
 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 flags_t = context::flags_t
 
using host_thread_sync_scheduling_policy_t = context::host_thread_sync_scheduling_policy_t
 

Enumerations

enum  : device::id_t { default_device_id = 0 }
 

Functions

device_t wrap (id_t id) NOEXCEPT_IF_NDEBUG
 Returns a wrapper for the CUDA device with a given id. More...
 
device_t get (id_t id)
 Returns a proxy for the CUDA device with a given id. More...
 
device_t default_ ()
 Obtains (a proxy for) the default CUDA device, being the device with the default CUDA device id.
 
device_t cpu ()
 A named constructor idiom for a "dummy" CUDA device representing the CPU. 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 cuda::device_t itself)

Typedef Documentation

◆ attribute_t

using cuda::device::attribute_t = typedef CUdevice_attribute

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

This is the type for attribute identifiers/indices.

◆ host_thread_sync_scheduling_policy_t

◆ id_t

using cuda::device::id_t = typedef CUdevice

Numeric ID of a CUDA device used by the CUDA Runtime API.

Note
at the time of writing and the foreseeable future, this type should be an int.

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::handle_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

◆ cpu()

device_t cuda::device::cpu ( )
inline

A named constructor idiom for a "dummy" CUDA device representing the CPU.

Note
Only use this idiom when comparing the results of functions returning locations, which can be either a GPU device or the CPU; any other use will likely result in a runtime error being thrown.

◆ get() [1/3]

device_t cuda::device::get ( id_t  id)
inline

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

◆ wrap()

device_t cuda::device::wrap ( id_t  id)
inline

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

Parameters
idthe ID of the device for which to obtain the wrapper
Note
Effectively, this is an alias of the get function.