Go to the documentation of this file.
6 #ifndef OPENMPCD_CUDA_MACROS_HPP
7 #define OPENMPCD_CUDA_MACROS_HPP
15 #define OPENMPCD_CUDA_HOST_AND_DEVICE __host__ __device__
20 #define OPENMPCD_CUDA_HOST __host__
25 #define OPENMPCD_CUDA_DEVICE __device__
30 #define OPENMPCD_CUDA_GLOBAL __global__
32 #define OPENMPCD_CUDA_HOST_AND_DEVICE
33 #define OPENMPCD_CUDA_HOST
34 #define OPENMPCD_CUDA_DEVICE
35 #define OPENMPCD_CUDA_GLOBAL
53 #define OPENMPCD_CUDA_LAUNCH_WORKUNITS_SIZES_BEGIN(numberOfWorkUnits_, maxGridSize_, blockSize_) \
55 const unsigned int _numberOfWorkUnits = (numberOfWorkUnits_); \
56 static const unsigned int _maxGridSize = (maxGridSize_); \
57 static const unsigned int _blockSize = (blockSize_); \
58 for(unsigned int _workUnit = 0; _workUnit < _numberOfWorkUnits; _workUnit += _maxGridSize * _blockSize) \
60 const unsigned int _requiredGridSize = (_numberOfWorkUnits - _workUnit) / _blockSize + 1; \
62 const unsigned int gridSize = _requiredGridSize > _maxGridSize ? _maxGridSize : _requiredGridSize; \
63 const unsigned int blockSize = _blockSize; \
64 const unsigned int workUnitOffset = _workUnit;
70 #define OPENMPCD_CUDA_LAUNCH_WORKUNITS_END \
81 #define OPENMPCD_CUDA_LAUNCH_WORKUNITS_GRIDSIZE_BEGIN(numberOfWorkUnits_, maxGridSize_) \
82 OPENMPCD_CUDA_LAUNCH_WORKUNITS_SIZES_BEGIN((numberOfWorkUnits_), (maxGridSize_), 512)
90 #define OPENMPCD_CUDA_LAUNCH_WORKUNITS_BEGIN(numberOfWorkUnits_) \
91 OPENMPCD_CUDA_LAUNCH_WORKUNITS_SIZES_BEGIN((numberOfWorkUnits_), 1024, 512)
96 #define OPENMPCD_CUDA_THROW_ON_ERROR do{const cudaError_t e=cudaGetLastError(); if(e!=cudaSuccess) OPENMPCD_THROW(OpenMPCD::CUDA::Exception, cudaGetErrorString(e));} while(0)