ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
utils.cuh File Reference
#include "utils.hpp"
#include <cuda.h>
#include <cuda_runtime.h>
#include <string>

Go to the source code of this file.

Classes

class  cuda_runtime_error_cuda
 

Macros

#define CUDA_CHECK(statement)
 Convert CUDA error codes into runtime errors.
 
#define cuda_safe_mem(a)   cuda_safe_mem_exit((a), __FILE__, __LINE__)
 
#define KERNELCALL_shared(_function, _grid, _block, _stream, ...)
 
#define KERNELCALL(_function, _grid, _block, ...)    KERNELCALL_shared(_function, _grid, _block, 0, ##__VA_ARGS__)
 

Functions

void cuda_safe_mem_exit (cudaError_t CU_err, const char *file, unsigned int line)
 In case of error during CUDA memory allocation and memory copy, print the error message and exit.
 
void cuda_check_errors_exit (const dim3 &block, const dim3 &grid, const char *function, const char *file, unsigned int line)
 In case of error during a CUDA operation, print the error message and exit.
 

Variables

cudaStream_t stream [1]
 CUDA streams for parallel computing on CPU and GPU.
 

Macro Definition Documentation

◆ CUDA_CHECK

#define CUDA_CHECK (   statement)
Value:
{ \
cudaError_t const error_code = (statement); \
if (error_code != cudaSuccess) { \
static_cast<void>(cudaGetLastError()); /* clear non-sticky errors */ \
throw cuda_runtime_error_cuda(error_code); \
} \
}

Convert CUDA error codes into runtime errors.

Definition at line 46 of file utils.cuh.

◆ cuda_safe_mem

#define cuda_safe_mem (   a)    cuda_safe_mem_exit((a), __FILE__, __LINE__)

Definition at line 73 of file utils.cuh.

◆ KERNELCALL

#define KERNELCALL (   _function,
  _grid,
  _block,
  ... 
)     KERNELCALL_shared(_function, _grid, _block, 0, ##__VA_ARGS__)

Definition at line 79 of file utils.cuh.

◆ KERNELCALL_shared

#define KERNELCALL_shared (   _function,
  _grid,
  _block,
  _stream,
  ... 
)
Value:
_function<<<_grid, _block, _stream, stream[0]>>>(__VA_ARGS__); \
cuda_check_errors_exit(_grid, _block, #_function, __FILE__, __LINE__);

Definition at line 75 of file utils.cuh.

Function Documentation

◆ cuda_check_errors_exit()

void cuda_check_errors_exit ( const dim3 &  block,
const dim3 &  grid,
const char *  function,
const char *  file,
unsigned int  line 
)

In case of error during a CUDA operation, print the error message and exit.

Definition at line 48 of file common_cuda.cu.

References block().

Referenced by assign_charges(), and assign_forces().

◆ cuda_safe_mem_exit()

void cuda_safe_mem_exit ( cudaError_t  CU_err,
const char *  file,
unsigned int  line 
)

In case of error during CUDA memory allocation and memory copy, print the error message and exit.

Parameters
CU_errcuda error code
file.cu file were the error took place
lineline of the file were the error took place

Definition at line 61 of file common_cuda.cu.

Variable Documentation

◆ stream

cudaStream_t stream[1]
extern

CUDA streams for parallel computing on CPU and GPU.

Definition at line 34 of file common_cuda.cu.

Referenced by GpuParticleData::Storage::copy_particles_to_device(), cuda_init(), cuda_set_device(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::getInnerSweep(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::getInnerSweep(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::getOuterSweep(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::getOuterSweep(), walberla::pystencils::CollideSweepDoublePrecisionLeesEdwardsCUDA::getSweep(), walberla::pystencils::CollideSweepDoublePrecisionThermalizedCUDA::getSweep(), walberla::pystencils::CollideSweepSinglePrecisionLeesEdwardsCUDA::getSweep(), walberla::pystencils::CollideSweepSinglePrecisionThermalizedCUDA::getSweep(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::getSweep(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::getSweep(), walberla::pystencils::InitialPDFsSetterDoublePrecisionCUDA::getSweep(), walberla::pystencils::InitialPDFsSetterSinglePrecisionCUDA::getSweep(), walberla::pystencils::StreamSweepDoublePrecisionCUDA::getSweep(), walberla::pystencils::StreamSweepSinglePrecisionCUDA::getSweep(), walberla::pystencils::CollideSweepDoublePrecisionLeesEdwardsCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepDoublePrecisionThermalizedCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepSinglePrecisionLeesEdwardsCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepSinglePrecisionThermalizedCUDA::getSweepOnCellInterval(), walberla::pystencils::InitialPDFsSetterDoublePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::InitialPDFsSetterSinglePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::StreamSweepDoublePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::StreamSweepSinglePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepDoublePrecisionLeesEdwardsCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepDoublePrecisionThermalizedCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepSinglePrecisionLeesEdwardsCUDA::getSweepOnCellInterval(), walberla::pystencils::CollideSweepSinglePrecisionThermalizedCUDA::getSweepOnCellInterval(), walberla::pystencils::InitialPDFsSetterDoublePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::InitialPDFsSetterSinglePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::StreamSweepDoublePrecisionCUDA::getSweepOnCellInterval(), walberla::pystencils::StreamSweepSinglePrecisionCUDA::getSweepOnCellInterval(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::inner(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::inner(), walberla::pystencils::CollideSweepDoublePrecisionLeesEdwardsCUDA::operator()(), walberla::pystencils::CollideSweepDoublePrecisionThermalizedCUDA::operator()(), walberla::pystencils::CollideSweepSinglePrecisionLeesEdwardsCUDA::operator()(), walberla::pystencils::CollideSweepSinglePrecisionThermalizedCUDA::operator()(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::operator()(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::operator()(), walberla::pystencils::InitialPDFsSetterDoublePrecisionCUDA::operator()(), walberla::pystencils::InitialPDFsSetterSinglePrecisionCUDA::operator()(), walberla::pystencils::StreamSweepDoublePrecisionCUDA::operator()(), walberla::pystencils::StreamSweepSinglePrecisionCUDA::operator()(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::outer(), walberla::lbm::Dynamic_UBB_single_precisionCUDA::outer(), walberla::lbm::Dynamic_UBB_double_precisionCUDA::run(), and walberla::lbm::Dynamic_UBB_single_precisionCUDA::run().