mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Added detailed HIP exception handling
This commit is contained in:
parent
54d82d349e
commit
b5d8c3b5f0
@ -48,29 +48,41 @@
|
|||||||
#undef HIP_HAVE_CUDA_DEFINED
|
#undef HIP_HAVE_CUDA_DEFINED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HIP_CHECK(stat) \
|
#define HIP_CHECK(STAT) \
|
||||||
{ \
|
do { \
|
||||||
if(stat != hipSuccess) \
|
const hipError_t stat = (STAT); \
|
||||||
{ \
|
if(stat != hipSuccess) \
|
||||||
OPM_THROW(std::logic_error, "HIP error"); \
|
{ \
|
||||||
} \
|
std::ostringstream oss; \
|
||||||
}
|
oss << "rocsparseSolverBackend::hip "; \
|
||||||
|
oss << "error: " << hipGetErrorString(stat); \
|
||||||
|
OPM_THROW(std::logic_error, oss.str()); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define ROCSPARSE_CHECK(stat) \
|
#define ROCSPARSE_CHECK(STAT) \
|
||||||
{ \
|
do { \
|
||||||
if(stat != rocsparse_status_success) \
|
const rocsparse_status stat = (STAT); \
|
||||||
{ \
|
if(stat != rocsparse_status_success) \
|
||||||
OPM_THROW(std::logic_error, "rocsparse error"); \
|
{ \
|
||||||
} \
|
std::ostringstream oss; \
|
||||||
}
|
oss << "rocsparseSolverBackend::rocsparse "; \
|
||||||
|
oss << "error: " << stat; \
|
||||||
|
OPM_THROW(std::logic_error, oss.str()); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define ROCBLAS_CHECK(stat) \
|
#define ROCBLAS_CHECK(STAT) \
|
||||||
{ \
|
do { \
|
||||||
if(stat != rocblas_status_success) \
|
const rocblas_status stat = (STAT); \
|
||||||
{ \
|
if(stat != rocblas_status_success) \
|
||||||
OPM_THROW(std::logic_error, "rocblas error"); \
|
{ \
|
||||||
} \
|
std::ostringstream oss; \
|
||||||
}
|
oss << "rocsparseSolverBackend::rocblas "; \
|
||||||
|
oss << "error: " << stat; \
|
||||||
|
OPM_THROW(std::logic_error, oss.str()); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
@ -153,7 +165,6 @@ void rocsparseSolverBackend<block_size>::gpu_pbicgstab([[maybe_unused]] WellCont
|
|||||||
d_Avals, d_Arows, d_Acols, block_size,
|
d_Avals, d_Arows, d_Acols, block_size,
|
||||||
d_x, &zero, d_r));
|
d_x, &zero, d_r));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ROCBLAS_CHECK(rocblas_dscal(blas_handle, N, &mone, d_r, 1));
|
ROCBLAS_CHECK(rocblas_dscal(blas_handle, N, &mone, d_r, 1));
|
||||||
ROCBLAS_CHECK(rocblas_daxpy(blas_handle, N, &one, d_b, 1, d_r, 1));
|
ROCBLAS_CHECK(rocblas_daxpy(blas_handle, N, &one, d_b, 1, d_r, 1));
|
||||||
ROCBLAS_CHECK(rocblas_dcopy(blas_handle, N, d_r, 1, d_rw, 1));
|
ROCBLAS_CHECK(rocblas_dcopy(blas_handle, N, d_r, 1, d_rw, 1));
|
||||||
@ -528,20 +539,6 @@ void rocsparseSolverBackend<block_size>::solve_system(WellContributions &wellCon
|
|||||||
// actually solve
|
// actually solve
|
||||||
gpu_pbicgstab(wellContribs, res);
|
gpu_pbicgstab(wellContribs, res);
|
||||||
HIP_CHECK(hipStreamSynchronize(stream));
|
HIP_CHECK(hipStreamSynchronize(stream));
|
||||||
#if 0
|
|
||||||
try {
|
|
||||||
gpu_pbicgstab(wellContribs, res);
|
|
||||||
} catch (const cl::Error& error) {
|
|
||||||
std::ostringstream oss;
|
|
||||||
oss << "rocsparseSolverBackend::solve_system error: " << error.what() << "(" << error.err() << ")\n";
|
|
||||||
oss << getErrorString(error.err());
|
|
||||||
// rethrow exception
|
|
||||||
OPM_THROW(std::logic_error, oss.str());
|
|
||||||
} catch (const std::logic_error& error) {
|
|
||||||
// rethrow exception by OPM_THROW in the try{}, without this, a segfault occurs
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (verbosity >= 3) {
|
if (verbosity >= 3) {
|
||||||
std::ostringstream out;
|
std::ostringstream out;
|
||||||
|
Loading…
Reference in New Issue
Block a user