19#include "owl/common.h"
20#include <cuda_runtime.h>
22#define OWL_CUDA_CHECK( call ) \
24 cudaError_t rc = call; \
25 if (rc != cudaSuccess) { \
27 "CUDA call (%s) failed with code %d (line %d): %s\n", \
28 #call, rc, __LINE__, cudaGetErrorString(rc)); \
29 OWL_RAISE("fatal cuda error"); \
33#define OWL_CUDA_CALL(call) OWL_CUDA_CHECK(cuda##call)
35#define OWL_CUDA_CHECK2( where, call ) \
37 cudaError_t rc = call; \
38 if(rc != cudaSuccess) { \
40 fprintf(stderr, "at %s: CUDA call (%s) " \
41 "failed with code %d (line %d): %s\n", \
42 where,#call, rc, __LINE__, cudaGetErrorString(rc)); \
44 "CUDA call (%s) failed with code %d (line %d): %s\n", \
45 #call, rc, __LINE__, cudaGetErrorString(rc)); \
46 OWL_RAISE("fatal cuda error"); \
50#define OWL_CUDA_SYNC_CHECK() \
52 cudaError_t rc = cudaDeviceSynchronize(); \
53 if (rc != cudaSuccess) { \
54 fprintf(stderr, "error (%s: line %d): %s\n", \
55 __FILE__, __LINE__, cudaGetErrorString(rc)); \
56 OWL_RAISE("fatal cuda error"); \
60#define OWL_CUDA_SYNC_CHECK_STREAM(s) \
62 cudaError_t rc = cudaStreamSynchronize(s); \
63 if (rc != cudaSuccess) { \
64 fprintf(stderr, "error (%s: line %d): %s\n", \
65 __FILE__, __LINE__, cudaGetErrorString(rc)); \
66 OWL_RAISE("fatal cuda error"); \
72#define OWL_CUDA_CHECK_NOTHROW( call ) \
74 cudaError_t rc = call; \
75 if (rc != cudaSuccess) { \
77 "CUDA call (%s) failed with code %d (line %d): %s\n", \
78 #call, rc, __LINE__, cudaGetErrorString(rc)); \
83#define OWL_CUDA_CALL_NOTHROW(call) OWL_CUDA_CHECK_NOTHROW(cuda##call)
85#define OWL_CUDA_CHECK2_NOTHROW( where, call ) \
87 cudaError_t rc = call; \
88 if(rc != cudaSuccess) { \
90 fprintf(stderr, "at %s: CUDA call (%s) " \
91 "failed with code %d (line %d): %s\n", \
92 where,#call, rc, __LINE__, cudaGetErrorString(rc)); \
94 "CUDA call (%s) failed with code %d (line %d): %s\n", \
95 #call, rc, __LINE__, cudaGetErrorString(rc)); \