Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:24

0001 #pragma once
0002 
0003 
0004 #include <stdexcept>
0005 #include <sstream>
0006 
0007 
0008 #define CUDA_CHECK( call )                                                     \
0009     do                                                                         \
0010     {                                                                          \
0011         cudaError_t error = call;                                              \
0012         if( error != cudaSuccess )                                             \
0013         {                                                                      \
0014             std::stringstream ss;                                              \
0015             ss << "CUDA call (" << #call << " ) failed with error: '"          \
0016                << cudaGetErrorString( error )                                  \
0017                << "' (" __FILE__ << ":" << __LINE__ << ")\n";                  \
0018             throw CUDA_Exception( ss.str().c_str() );                        \
0019         }                                                                      \
0020     } while( 0 )
0021 
0022 
0023 #define CUDA_SYNC_CHECK()                                                      \
0024     do                                                                         \
0025     {                                                                          \
0026         cudaDeviceSynchronize();                                               \
0027         cudaError_t error = cudaGetLastError();                                \
0028         if( error != cudaSuccess )                                             \
0029         {                                                                      \
0030             std::stringstream ss;                                              \
0031             ss << "CUDA error on synchronize with error '"                     \
0032                << cudaGetErrorString( error )                                  \
0033                << "' (" __FILE__ << ":" << __LINE__ << ")\n";                  \
0034             throw CUDA_Exception( ss.str().c_str() );                        \
0035         }                                                                      \
0036     } while( 0 )
0037 
0038 
0039 
0040 class CUDA_Exception : public std::runtime_error
0041 {
0042  public:
0043      CUDA_Exception( const char* msg )
0044          : std::runtime_error( msg )
0045      { }
0046 
0047 };
0048 
0049