-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcudaCheck.h
45 lines (35 loc) · 1.21 KB
/
cudaCheck.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef HeterogeneousCore_CUDAUtilities_cudaCheck_h
#define HeterogeneousCore_CUDAUtilities_cudaCheck_h
#include <iostream>
#ifdef __CUDACC__
#include <cuda.h>
#include <cuda_runtime.h>
inline
bool cudaCheck_(const char* file, int line, const char* cmd, CUresult result)
{
//std::cerr << file << ", line " << line << ": " << cmd << std::endl;
if (result == CUDA_SUCCESS)
return true;
const char* error;
const char* message;
cuGetErrorName(result, &error);
cuGetErrorString(result, &message);
std::cerr << file << ", line " << line << ": " << error << ": " << message << std::endl;
abort();
return false;
}
inline
bool cudaCheck_(const char* file, int line, const char* cmd, cudaError_t result)
{
//std::cerr << file << ", line " << line << ": " << cmd << std::endl;
if (result == cudaSuccess)
return true;
const char* error = cudaGetErrorName(result);
const char* message = cudaGetErrorString(result);
std::cerr << file << ", line " << line << ": " << error << ": " << message << std::endl;
abort();
return false;
}
#define cudaCheck(ARG) (cudaCheck_(__FILE__, __LINE__, #ARG, (ARG)))
#endif
#endif // HeterogeneousCore_CUDAUtilities_cudaCheck_h