Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #ifndef CUDA_ERROR_CHECK_H
  2. #define CUDA_ERROR_CHECK
  3.  
  4. static void HandleError( cudaError_t err,
  5.                          const char *file,
  6.                          int line ) {
  7.     if (err != cudaSuccess) {
  8.         printf( "%s in %s at line %d\n", cudaGetErrorString( err ),
  9.                 file, line );
  10.         exit( EXIT_FAILURE );
  11.     }
  12. }
  13. #define HANDLE_ERROR( err ) (HandleError( err, __FILE__, __LINE__ ))
  14.  
  15. #define HANDLE_ERROR_FUNC() cudaThreadSynchronize(); HandleError( cudaPeekAtLastError(), __FILE__, __LINE__ )
  16.  
  17.  
  18. #define HANDLE_NULL( a ) {if (a == NULL) { \
  19.                             printf( "Host memory failed in %s at line %d\n", \
  20.                                     __FILE__, __LINE__ ); \
  21.                             exit( EXIT_FAILURE );}}
  22. #endif