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

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

#include <gpuUtils.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()

Drp::Gpu::CudaContext::CudaContext ( )
inline

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

Member Function Documentation

◆ context()

CUcontext Drp::Gpu::CudaContext::context ( ) const
inline

Return the context created by init().

◆ device()

CUdevice Drp::Gpu::CudaContext::device ( ) const
inline

Return the device handle selected by init().

◆ deviceNo()

int Drp::Gpu::CudaContext::deviceNo ( ) const
inline

Return the device number selected by init().

◆ getAttribute()

int Drp::Gpu::CudaContext::getAttribute ( CUdevice_attribute  attr)

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

◆ init()

bool Drp::Gpu::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 Drp::Gpu::CudaContext::listDevices ( )

Dumps a list of devices to stdout.

Member Data Documentation

◆ context_

CUcontext Drp::Gpu::CudaContext::context_

Context created by init().

◆ device_

CUdevice Drp::Gpu::CudaContext::device_

Device handle selected by init().


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