// Copyright Supranational LLC
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef __SPPARK_UTIL_EXCEPTION_CUH__
#define __SPPARK_UTIL_EXCEPTION_CUH__
#include "exception.hpp"
using cuda_error = sppark_error;
#define CUDA_UNWRAP_SPPARK(expr) do { \
cudaError_t code = expr; \
if (code != cudaSuccess) { \
auto file = std::strstr(__FILE__, "sppark"); \
auto str = fmt("%s@%s:%d failed: \"%s\"", #expr, \
file ? file : __FILE__, __LINE__, \
cudaGetErrorString(code)); \
throw cuda_error{-code, str}; \
} \
} while(0)
#endif