lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
CudaContext Class Reference

Wraps a cuda context and handles some initialization for you. More...

#include <GpuAsyncLib.hh>

Public Member Functions

 CudaContext ()
 Initialize the CUDA driver API (cuInit()), aborting on failure.
 
bool init (int device=-1, bool quiet=false)
 Creates a CUDA context, selects a device and ensures that stream memory ops are available.
 
void listDevices ()
 Dumps a list of devices to stdout.
 
int getAttribute (CUdevice_attribute attr)
 Return the value of device attribute attr for the selected device, or 0 if the query fails.
 
CUdevice device () const
 Return the device handle selected by init().
 
CUcontext context () const
 Return the context created by init().
 
int deviceNo () const
 Return the device number selected by init().
 

Public Attributes

CUcontext context_
 Context created by init().
 
CUdevice device_
 Device handle selected by init().
 

Detailed Description

Wraps a cuda context and handles some initialization for you.

Constructor & Destructor Documentation

◆ CudaContext()

CudaContext::CudaContext ( )
inline

Initialize the CUDA driver API (cuInit()), aborting on failure.

Member Function Documentation

◆ context()

CUcontext CudaContext::context ( ) const
inline

Return the context created by init().

◆ device()

CUdevice CudaContext::device ( ) const
inline

Return the device handle selected by init().

◆ deviceNo()

int CudaContext::deviceNo ( ) const
inline

Return the device number selected by init().

◆ getAttribute()

int CudaContext::getAttribute ( CUdevice_attribute  attr)

Return the value of device attribute attr for the selected device, or 0 if the query fails.

◆ init()

bool CudaContext::init ( int  device = -1,
bool  quiet = false 
)

Creates a CUDA context, selects a device and ensures that stream memory ops are available.

Parameters
deviceIf >= 0, selects a device to use
quietWheter to spew or not
Returns
Bool if success

◆ listDevices()

void CudaContext::listDevices ( )

Dumps a list of devices to stdout.

Member Data Documentation

◆ context_

CUcontext CudaContext::context_

Context created by init().

◆ device_

CUdevice CudaContext::device_

Device handle selected by init().


The documentation for this class was generated from the following file: