add gpu error check
This commit is contained in:
parent
fd95be5f20
commit
ab41cd26a6
15
src/common/gpu_error_check.h
Normal file
15
src/common/gpu_error_check.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <hip/hip_runtime.h>
|
||||
|
||||
#define GPU_CHECK(ans) { gpuAssert((ans), __FILE__, __LINE__); }
|
||||
inline void gpuAssert(hipError_t code, const char *file, int line, bool abort=true)
|
||||
{
|
||||
if (code != hipSuccess)
|
||||
{
|
||||
std::cerr << "GPU Error: " << hipGetErrorString(code) << " " << file << " " << line << std::endl;
|
||||
if (abort) exit(code);
|
||||
}
|
||||
}
|
||||
|
||||
#define GPU_CHECK_LAST() { gpuAssert(hipGetLastError(), __FILE__, __LINE__); }
|
||||
Loading…
x
Reference in New Issue
Block a user