diff --git a/ebos/eclbasevanguard.hh b/ebos/eclbasevanguard.hh index b3c35c5bc..7d69a62c6 100644 --- a/ebos/eclbasevanguard.hh +++ b/ebos/eclbasevanguard.hh @@ -92,12 +92,12 @@ struct EdgeWeightsMethod { using type = UndefinedProperty; }; -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE template struct NumJacobiBlocks { using type = UndefinedProperty; }; -#endif // HAVE_OPENCL +#endif // HAVE_OPENCL || HAVE_ROCSPARSE template struct OwnerCellsFirst { @@ -153,12 +153,12 @@ struct EdgeWeightsMethod { static constexpr int value = 1; }; -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE template struct NumJacobiBlocks { static constexpr int value = 0; }; -#endif // HAVE_OPENCL +#endif // HAVE_OPENCL || HAVE_ROCSPARSE template struct OwnerCellsFirst { @@ -248,7 +248,7 @@ public: EWOMS_REGISTER_PARAM(TypeTag, int, EdgeWeightsMethod, "Choose edge-weighing strategy: 0=uniform, 1=trans, 2=log(trans)."); -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE EWOMS_REGISTER_PARAM(TypeTag, int, NumJacobiBlocks, "Number of blocks to be created for the Block-Jacobi preconditioner."); #endif @@ -288,7 +288,7 @@ public: fileName_ = EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName); edgeWeightsMethod_ = Dune::EdgeWeightMethod(EWOMS_GET_PARAM(TypeTag, int, EdgeWeightsMethod)); -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE numJacobiBlocks_ = EWOMS_GET_PARAM(TypeTag, int, NumJacobiBlocks); #endif diff --git a/ebos/eclgenericvanguard.hh b/ebos/eclgenericvanguard.hh index 3ccaaeaf6..058e59fb8 100644 --- a/ebos/eclgenericvanguard.hh +++ b/ebos/eclgenericvanguard.hh @@ -202,7 +202,7 @@ public: */ int numJacobiBlocks() const { -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE return numJacobiBlocks_; #else return 0; @@ -283,9 +283,9 @@ protected: std::string fileName_; Dune::EdgeWeightMethod edgeWeightsMethod_; -#if HAVE_OPENCL +#if HAVE_OPENCL || HAVE_ROCSPARSE int numJacobiBlocks_{0}; -#endif // HAVE_OPENCL +#endif // HAVE_OPENCL || HAVE_ROCSPARSE bool ownersFirst_; #if HAVE_MPI diff --git a/opm/simulators/linalg/bda/rocsparseSolverBackend.cpp b/opm/simulators/linalg/bda/rocsparseSolverBackend.cpp index 733813be4..14392564d 100644 --- a/opm/simulators/linalg/bda/rocsparseSolverBackend.cpp +++ b/opm/simulators/linalg/bda/rocsparseSolverBackend.cpp @@ -48,29 +48,41 @@ #undef HIP_HAVE_CUDA_DEFINED #endif -#define HIP_CHECK(stat) \ - { \ - if(stat != hipSuccess) \ - { \ - OPM_THROW(std::logic_error, "HIP error"); \ - } \ - } +#define HIP_CHECK(STAT) \ + do { \ + const hipError_t stat = (STAT); \ + if(stat != hipSuccess) \ + { \ + std::ostringstream oss; \ + oss << "rocsparseSolverBackend::hip "; \ + oss << "error: " << hipGetErrorString(stat); \ + OPM_THROW(std::logic_error, oss.str()); \ + } \ + } while(0) -#define ROCSPARSE_CHECK(stat) \ - { \ - if(stat != rocsparse_status_success) \ - { \ - OPM_THROW(std::logic_error, "rocsparse error"); \ - } \ - } +#define ROCSPARSE_CHECK(STAT) \ + do { \ + const rocsparse_status stat = (STAT); \ + if(stat != rocsparse_status_success) \ + { \ + std::ostringstream oss; \ + oss << "rocsparseSolverBackend::rocsparse "; \ + oss << "error: " << stat; \ + OPM_THROW(std::logic_error, oss.str()); \ + } \ + } while(0) -#define ROCBLAS_CHECK(stat) \ - { \ - if(stat != rocblas_status_success) \ - { \ - OPM_THROW(std::logic_error, "rocblas error"); \ - } \ - } +#define ROCBLAS_CHECK(STAT) \ + do { \ + const rocblas_status stat = (STAT); \ + if(stat != rocblas_status_success) \ + { \ + std::ostringstream oss; \ + oss << "rocsparseSolverBackend::rocblas "; \ + oss << "error: " << stat; \ + OPM_THROW(std::logic_error, oss.str()); \ + } \ + } while(0) #include @@ -153,7 +165,6 @@ void rocsparseSolverBackend::gpu_pbicgstab([[maybe_unused]] WellCont d_Avals, d_Arows, d_Acols, block_size, d_x, &zero, d_r)); #endif - 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_dcopy(blas_handle, N, d_r, 1, d_rw, 1)); @@ -526,18 +537,7 @@ void rocsparseSolverBackend::solve_system(WellContributions &wellCon Timer t; // actually solve - 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; - } + gpu_pbicgstab(wellContribs, res); if (verbosity >= 3) { HIP_CHECK(hipStreamSynchronize(stream)); diff --git a/opm/simulators/linalg/bda/rocsparseSolverBackend.hpp b/opm/simulators/linalg/bda/rocsparseSolverBackend.hpp index 4fa470774..0736fcce5 100644 --- a/opm/simulators/linalg/bda/rocsparseSolverBackend.hpp +++ b/opm/simulators/linalg/bda/rocsparseSolverBackend.hpp @@ -22,7 +22,6 @@ #include -#include #include #include #include