-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhip_errors.hpp
More file actions
31 lines (26 loc) · 748 Bytes
/
hip_errors.hpp
File metadata and controls
31 lines (26 loc) · 748 Bytes
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
#ifndef HIP_ERRORS_HPP
#define HIP_ERRORS_HPP
#include <hip_runtime.h>
#include <iostream>
#define hipSafeCall(err) _hipSafeCall(err, __FILE__, __LINE__)
#define hipCheckError() _hipCheckError(__FILE__, __LINE__)
/**
* hip version of error handling functions
*/
inline void _hipSafeCall(hipError_t err, const char *file, const int line)
{
if (err != hipSuccess)
{
std::cerr << "HIP failed at [" << file
<< "] line: " << line
<< " error: " << hipGetErrorString(err)
<< std::endl;
exit(-1);
}
}
inline void _hipCheckError(const char *file, const int line)
{
hipError_t err = hipGetLastError();
_hipSafeCall(err, file, line);
}
#endif // HIP_ERRORS_HPP