mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-11 18:15:35 -06:00
Merge pull request #4883 from jychang48/jychang48-edits
Removed OpenCL dependencies for rocsparse backend & error exception handling
This commit is contained in:
commit
3f436501d2
@ -92,12 +92,12 @@ struct EdgeWeightsMethod {
|
||||
using type = UndefinedProperty;
|
||||
};
|
||||
|
||||
#if HAVE_OPENCL
|
||||
#if HAVE_OPENCL || HAVE_ROCSPARSE
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct NumJacobiBlocks {
|
||||
using type = UndefinedProperty;
|
||||
};
|
||||
#endif // HAVE_OPENCL
|
||||
#endif // HAVE_OPENCL || HAVE_ROCSPARSE
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct OwnerCellsFirst {
|
||||
@ -153,12 +153,12 @@ struct EdgeWeightsMethod<TypeTag, TTag::EclBaseVanguard> {
|
||||
static constexpr int value = 1;
|
||||
};
|
||||
|
||||
#if HAVE_OPENCL
|
||||
#if HAVE_OPENCL || HAVE_ROCSPARSE
|
||||
template<class TypeTag>
|
||||
struct NumJacobiBlocks<TypeTag, TTag::EclBaseVanguard> {
|
||||
static constexpr int value = 0;
|
||||
};
|
||||
#endif // HAVE_OPENCL
|
||||
#endif // HAVE_OPENCL || HAVE_ROCSPARSE
|
||||
|
||||
template<class TypeTag>
|
||||
struct OwnerCellsFirst<TypeTag, TTag::EclBaseVanguard> {
|
||||
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 <cstddef>
|
||||
|
||||
@ -153,7 +165,6 @@ void rocsparseSolverBackend<block_size>::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<block_size>::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));
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
|
||||
#include <opm/simulators/linalg/bda/BdaResult.hpp>
|
||||
#include <opm/simulators/linalg/bda/BdaSolver.hpp>
|
||||
#include <opm/simulators/linalg/bda/WellContributions.hpp>
|
||||
|
Loading…
Reference in New Issue
Block a user