Sierra Toolkit  Version of the Day
CudaCall.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef stk_algsup_CudaCall_hpp
10 #define stk_algsup_CudaCall_hpp
11 
12 #ifdef STK_HAVE_CUDA
13 
14 #include <cuda.h>
15 #include <cuda_runtime.h>
16 
17 //----------------------------------------------------------------
18 inline
19 void stk_cuda_call(cudaError err , const char* name )
20 {
21  if ( err != cudaSuccess ) {
22  fprintf(stderr, "%s error: %s\n",name, cudaGetErrorString(err) );
23  exit(-1);
24  }
25 }
26 
27 #define CUDA_CALL( cuda_fn ) stk_cuda_call( cuda_fn , #cuda_fn )
28 
29 #endif
30 
31 #endif
32