add gpu error check

This commit is contained in:
Hendrik Groove 2024-10-20 17:34:51 +02:00
parent fd95be5f20
commit ab41cd26a6

View 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__); }