xgboost/src/common/gpu_error_check.h
2024-10-20 17:34:51 +02:00

15 lines
466 B
C++

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