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

GPU DRP utilities: CUDA error checks, CudaContext, CoreRegisters (GpuAsyncCore registers, real or simulated), DMA target selection and GPUTimer. More...

#include "psdaq/aes-stream-drivers/GpuAsync.h"
#include "psdaq/aes-stream-drivers/GpuAsyncUser.h"
#include <string>
#include <memory>
#include <assert.h>
#include <stdint.h>
#include <cuda.h>
#include <cuda_runtime.h>

Classes

class  Drp::Gpu::CudaContext
 Wraps a cuda context and handles some initialization for you. More...
 
class  Drp::Gpu::CoreRegisters
 Access to the GpuAsyncCore registers, either through a GpuAsyncCoreRegs object on the mapped firmware registers or, in simulator mode, through a plain memory block laid out like them. More...
 
struct  Drp::Gpu::GPUTimer
 Class for timing various things. More...
 

Namespaces

namespace  Drp
 This class services detectors whose event data is formatted from the AxiStreamBatcherEventBuilder firmware module This class depends upon the existence of a python module "psdaq.configdb.<detType>_config.py", which contains the following functions: <detType>_init (str) - returns a handle (PyObject) for interacting with the device configuration <detType>_connect (handle) - returns a dictionary with "paddr" element for Xpm link ID.
 
namespace  Drp::Gpu
 Namespace of the GPU DRP code (psdaq/drpGpu); only Gpu::Detector is forward-declared here.
 

Macros

#define deviceFunc
 Empty when not compiling with nvcc; device under nvcc.
 
#define globalFunc
 Empty when not compiling with nvcc; global under nvcc.
 
#define hostFunc
 Empty when not compiling with nvcc; host under nvcc.
 
#define NOARG   ""
 Empty string literal put in front of the optional message, so that the message argument is never empty (per the code comment).
 
#define chkFatal(rc, ...)   checkError((rc), #rc, __FILE__, __LINE__, true, NOARG __VA_ARGS__)
 Check a CUDA driver or runtime result rc with checkError(), logging any failure with the optional message and aborting.
 
#define chkError(rc, ...)   checkError((rc), #rc, __FILE__, __LINE__, false, NOARG __VA_ARGS__)
 Check a CUDA driver or runtime result rc with checkError(), logging any failure with the optional message without aborting; evaluates to true on failure.
 

Enumerations

enum  Drp::Gpu::DmaTgt_t { Drp::Gpu::TGT_CPU =0x0 , Drp::Gpu::TGT_GPU =0x1 , Drp::Gpu::TGT_ERR =-1u }
 Functions to get and set the DMA destination. More...
 

Functions

bool Drp::Gpu::checkError (CUresult status, const char *func, const char *file, int line, bool crash=true, const char *msg="")
 If status is not CUDA_SUCCESS, log file, line, the error name and description and msg, then abort if crash is true.
 
bool Drp::Gpu::checkError (cudaError status, const char *func, const char *file, int line, bool crash=true, const char *msg="")
 If status is not cudaSuccess, log file, line, the error name and description and msg, then abort if crash is true.
 
DmaTgt_t Drp::Gpu::dmaTgtGet (CoreRegisters &)
 Return TGT_CPU or TGT_GPU for the AXI stream demux select value of coreRegs, or TGT_ERR for any other value.
 
void Drp::Gpu::dmaTgtSet (CoreRegisters &, DmaTgt_t)
 Write tgt to the AXI stream demux select field of coreRegs.
 
void Drp::Gpu::dmaIdxReset (CoreRegisters &)
 Function to reset the DMA buffer round-robin index.
 

Detailed Description

GPU DRP utilities: CUDA error checks, CudaContext, CoreRegisters (GpuAsyncCore registers, real or simulated), DMA target selection and GPUTimer.

Macro Definition Documentation

◆ chkError

#define chkError (   rc,
  ... 
)    checkError((rc), #rc, __FILE__, __LINE__, false, NOARG __VA_ARGS__)

Check a CUDA driver or runtime result rc with checkError(), logging any failure with the optional message without aborting; evaluates to true on failure.

◆ chkFatal

#define chkFatal (   rc,
  ... 
)    checkError((rc), #rc, __FILE__, __LINE__, true, NOARG __VA_ARGS__)

Check a CUDA driver or runtime result rc with checkError(), logging any failure with the optional message and aborting.

◆ deviceFunc

#define deviceFunc

Empty when not compiling with nvcc; device under nvcc.

◆ globalFunc

#define globalFunc

Empty when not compiling with nvcc; global under nvcc.

◆ hostFunc

#define hostFunc

Empty when not compiling with nvcc; host under nvcc.

◆ NOARG

#define NOARG   ""

Empty string literal put in front of the optional message, so that the message argument is never empty (per the code comment).