Correlation 4.10.0
An Analysis Tool for Liquids and for Amorphous Solids
Loading...
Searching...
No Matches
GPUErrorCheck.hpp
Go to the documentation of this file.
1
8
9#pragma once
10
12
13#include <format>
14#include <source_location>
15#include <stdexcept>
16
17namespace correlation::core::gpu {
18
22class GPUError : public std::runtime_error {
23public:
24 using std::runtime_error::runtime_error;
25};
26
33inline void hipCheck(hipError_t result,
34 std::source_location loc = std::source_location::current()) {
35 if (result != hipSuccess) {
36 throw GPUError(std::format("GPU error in {}:{} — {}", loc.file_name(), loc.line(),
37 hipGetErrorString(result)));
38 }
39}
40
41} // namespace correlation::core::gpu
Unified GPU portability layer between CUDA and HIP with host fallback stubs.
int hipError_t
Return error type for host fallback emulation.
Definition GPUPortability.hpp:54
constexpr int hipSuccess
Successful execution code.
Definition GPUPortability.hpp:56
const char * hipGetErrorString(hipError_t err) noexcept
Translates an error code to a human-readable description.
Definition GPUPortability.hpp:148
Exception type for GPU runtime errors.
Definition GPUErrorCheck.hpp:22
Definition DeviceBuffer.hpp:16
void hipCheck(hipError_t result, std::source_location loc=std::source_location::current())
Validates a HIP/CUDA runtime call result and throws GPUError on failure.
Definition GPUErrorCheck.hpp:33