cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
device.hpp File Reference

Implementations requiring the definitions of multiple CUDA entity proxy classes, and which regard devices, including primary contexts. More...

#include "../device.hpp"
#include "../error.hpp"
#include "../event.hpp"
#include "../kernel_launch.hpp"
#include "../stream.hpp"
#include "../primary_context.hpp"
#include "../current_context.hpp"
#include "../current_device.hpp"
#include "../peer_to_peer.hpp"
#include "../types.hpp"
#include <string>
Include dependency graph for device.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 cuda
 Definitions and functionality wrapping CUDA APIs.
 
 cuda::device
 Definitions and functionality related to CUDA devices (not including the device wrapper type cuda::device_t itself)
 
 cuda::device::peer_to_peer
 API functions and definitions relating to communications among peer CUDA GPU devices on the same system.
 

Functions

bool cuda::device::primary_context::is_active (const device_t &device)
 
void cuda::device::primary_context::destroy (const device_t &device)
 Destroy and clean up all resources associated with the specified device's primary context. More...
 
primary_context_t cuda::device::primary_context::get (const device_t &device)
 Obtain a handle to the primary context of a given device - creating it ("activating" it) if it doesn't exist. More...
 
bool cuda::device::peer_to_peer::can_access (const device_t &accessor, const device_t &peer)
 Determine whether one CUDA device can access the global memory of another CUDA device. More...
 
void cuda::device::peer_to_peer::enable_access (const device_t &accessor, const device_t &peer)
 Enable access by one CUDA device to the global memory of another. More...
 
void cuda::device::peer_to_peer::disable_access (const device_t &accessor, const device_t &peer)
 Disable access by one CUDA device to the global memory of another. More...
 
bool cuda::device::peer_to_peer::can_access_each_other (const device_t &first, const device_t &second)
 Determine whether two CUDA devices can currently access each other.
 
void cuda::device::peer_to_peer::enable_bidirectional_access (const device_t &first, const device_t &second)
 Enable access both by the first to the second device and the other way around.
 
void cuda::device::peer_to_peer::disable_bidirectional_access (const device_t &first, const device_t &second)
 Disable access both by the first to the second device and the other way around.
 
attribute_value_t cuda::device::peer_to_peer::get_attribute (attribute_t attribute, const device_t &first, const device_t &second)
 Get one of the numeric attributes for a(n ordered) pair of devices, relating to their interaction. More...
 
void cuda::synchronize (const device_t &device)
 Waits for all previously-scheduled tasks on all streams (= queues) on a specified device to conclude. More...
 

Detailed Description

Implementations requiring the definitions of multiple CUDA entity proxy classes, and which regard devices, including primary contexts.

Specifically:

  1. Functions in the cuda::device namespace.
  2. Methods of cuda::device_t and possibly some relates classes.

Function Documentation

◆ destroy()

void cuda::device::primary_context::destroy ( const device_t device)
inline

Destroy and clean up all resources associated with the specified device's primary context.

Parameters
deviceThe device whose primary context is to be destroyed

◆ get()

primary_context_t cuda::device::primary_context::get ( const device_t device)
inline

Obtain a handle to the primary context of a given device - creating it ("activating" it) if it doesn't exist.

Note
This method and its returned object will "perform their own" reference accounting vis-a-vis the driver, i.e. the caller does not need to worry about increasing or decreasing the CUDA driver reference count for the primary context. Naturally, though, the caller must not interfere with this reference accounting by decreasing the reference count arbitrarily by more than it has increased it, by destroying the primary context etc.
Parameters
deviceThe device whose primary context is to be proxied
Returns
A proxy object for the specified device

◆ is_active()

bool cuda::device::primary_context::is_active ( const device_t device)
inline
Returns
true if the device's primary context is active (i.e. has resources allocated for it), which implies we are holding a refcount unit for it somewhere.
Note
recall a primary context being active does not mean that it is the current context