GENIE
cuda_macros.h File Reference
#include <stdio.h>
#include <genie/exception/exception.h>
#include <genie/utility/Logger.h>

Go to the source code of this file.

Macros

#define cudaCheckErrors(err)   __cudaSafeCall( err, __FILE__, __LINE__ )
 The wrapper function to validate CUDA calls. More...
 
#define CUDA_CHECK_ERROR(err)   __cudaSafeCall( err, __FILE__, __LINE__ )
 
#define CUDA_LAST_ERROR()   __cudaGetLastError (__FILE__, __LINE__)
 

Functions

void __cudaSafeCall (cudaError err, const char *file, const int line)
 The hidden wrapper function to validate CUDA calls. More...
 
void __cudaGetLastError (const char *file, const int line)
 

Macro Definition Documentation

◆ CUDA_CHECK_ERROR

#define CUDA_CHECK_ERROR (   err)    __cudaSafeCall( err, __FILE__, __LINE__ )

Definition at line 24 of file cuda_macros.h.

◆ CUDA_LAST_ERROR

#define CUDA_LAST_ERROR ( )    __cudaGetLastError (__FILE__, __LINE__)

Definition at line 33 of file cuda_macros.h.

◆ cudaCheckErrors

cudaCheckErrors (   err)    __cudaSafeCall( err, __FILE__, __LINE__ )

The wrapper function to validate CUDA calls.

Check for existing cuda errors.

Please wrap all CUDA calls with this function.

Once a CUDA error is detected, a genie::exception::gpu_runtime_error will be thrown and the error will be logged.

Parameters
errThe CUDA error.

Once a CUDA error is detected, a genie::exception::gpu_runtime_error will be thrown and the error will be logged.

Definition at line 23 of file cuda_macros.h.

Function Documentation

◆ __cudaGetLastError()

void __cudaGetLastError ( const char *  file,
const int  line 
)
inline

Definition at line 64 of file cuda_macros.h.

◆ __cudaSafeCall()

void __cudaSafeCall ( cudaError  err,
const char *  file,
const int  line 
)
inline

The hidden wrapper function to validate CUDA calls.

This function should not be called directly. It is wrapped in a macro expansion cudaCheckErrors( err ) . Please wrap all CUDA calls with cudaCheckErrors.

Once cuda errors are detected, a genie::exception::gpu_runtime_error will be thrown and the errors will be logged.

Parameters
errThe CUDA error.
fileThe source code file name.
lineThe line number that indicates the source of the error.

Definition at line 49 of file cuda_macros.h.