QMCPACK
CUDAerror.h File Reference
+ Include dependency graph for CUDAerror.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define cudaErrorCheck(ans, cause)
 
#define cudaCheck(ans)
 

Functions

void cudaAssert (cudaError_t code, const std::string &cause, const char *filename, int line, bool abort=true)
 prints CUDA error messages. Always use cudaErrorCheck macro. More...
 

Macro Definition Documentation

◆ cudaCheck

#define cudaCheck (   ans)
Value:
{ \
cudaAssert((ans), "", __FILE__, __LINE__); \
}

Definition at line 27 of file CUDAerror.h.

Referenced by qmcplusplus::TEST_CASE().

◆ cudaErrorCheck

#define cudaErrorCheck (   ans,
  cause 
)
Value:
{ \
cudaAssert((ans), cause, __FILE__, __LINE__); \
}

Definition at line 21 of file CUDAerror.h.

Referenced by getCUDAdeviceFreeMem().

Function Documentation

◆ cudaAssert()

void cudaAssert ( cudaError_t  code,
const std::string &  cause,
const char *  filename,
int  line,
bool  abort = true 
)
inline

prints CUDA error messages. Always use cudaErrorCheck macro.

Definition at line 33 of file CUDAerror.h.

References cudaGetErrorName, cudaGetErrorString, and cudaSuccess.

34 {
35  if (code != cudaSuccess)
36  {
37  std::ostringstream err;
38  err << "cudaAssert: " << cudaGetErrorName(code) << " " << cudaGetErrorString(code) << ", file " << filename
39  << ", line " << line << std::endl
40  << cause << std::endl;
41  std::cerr << err.str();
42  if (abort)
43  throw std::runtime_error(cause);
44  }
45 }
#define cudaGetErrorName
Definition: cuda2hip.h:104
#define cudaSuccess
Definition: cuda2hip.h:154
#define cudaGetErrorString
Definition: cuda2hip.h:105