-
Notifications
You must be signed in to change notification settings - Fork 41
/
gpu-error.h
29 lines (27 loc) · 927 Bytes
/
gpu-error.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
#include <iostream>
#pragma once
#ifdef __NVCC__
#define GPU_ERROR(ans) \
{ gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(cudaError_t code, const char *file, int line,
bool abort = true) {
if (code != cudaSuccess) {
std::cerr << "GPUassert: \"" << cudaGetErrorString(code) << "\" in "
<< file << ": " << line << "\n";
if (abort)
exit(code);
}
}
#elif defined __HIP__
#define GPU_ERROR(ans) \
{ gpuAssert((ans), __FILE__, __LINE__); }
inline void gpuAssert(hipError_t code, const char *file, int line,
bool abort = true) {
if (code != hipSuccess) {
std::cerr << "GPUassert: \"" << hipGetErrorString(code) << "\" in " << file
<< ": " << line << "\n";
if (abort)
exit(code);
}
}
#endif