19#ifndef OPM_GPUISTL_DETAIL_GPU_STREAM_HPP
20#define OPM_GPUISTL_DETAIL_GPU_STREAM_HPP
22#include <opm/common/ErrorMacros.hpp>
24#include <cuda_runtime.h>
27#include <source_location>
42 [[maybe_unused]] std::string_view name,
43 [[maybe_unused]]
const std::source_location location
44 = std::source_location::current())
47 const cudaError_t err = cudaStreamQuery(stream);
48 if (err == cudaSuccess || err == cudaErrorNotReady) {
52 if (err != cudaErrorInvalidResourceHandle) {
53 OPM_THROW(std::runtime_error,
54 std::format(
"GPU stream query for {} failed\n"
59 " GPU stream error: {}",
64 location.function_name(),
65 cudaGetErrorString(err)));
68 OPM_THROW(std::invalid_argument,
69 std::format(
"{} is not a valid GPU stream\n"
74 " GPU stream error: {} (invalid stream handle)",
79 location.function_name(),
80 cudaGetErrorString(err)));
89#define OPM_GPUISTL_DETAIL_ASSERT_GPU_STREAM(x) ::Opm::gpuistl::detail::assertGPUStream((x), #x)
Definition: autotuner.hpp:30
void assertGPUStream(cudaStream_t stream, std::string_view name, const std::source_location location=std::source_location::current())
Debug-only check that stream is a valid GPU stream handle.
Definition: gpu_stream.hpp:41