cuda-api-wrappers
Thin C++-flavored wrappers for the CUDA Runtime API
primary_context.hpp File Reference
#include "current_context.hpp"
#include "context.hpp"
Include dependency graph for primary_context.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cuda::device::primary_context_t
 A class for holding the primary context of a CUDA device. More...
 

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)
 

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::primary_context::is_current ()
 

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

◆ is_current()

bool cuda::device::primary_context::is_current ( )
inline
Returns
true if the current context is its device's primary context