Replaced exit() with OPM_THROW. Replaced primitive pointer with unique_ptr.

This commit is contained in:
T.D. (Tongdong) Qiu 2019-12-16 10:05:12 +01:00
parent 13e524dba2
commit 293bd5816f
3 changed files with 7 additions and 22 deletions

View File

@ -225,7 +225,7 @@ protected:
static const int numEq = Indices::numEq;
#if HAVE_CUDA
BdaBridge *bdaBridge;
std::unique_ptr<BdaBridge> bdaBridge;
#endif
public:
@ -252,27 +252,19 @@ protected:
const bool matrix_add_well_contributions = EWOMS_GET_PARAM(TypeTag, bool, MatrixAddWellContributions);
const int linear_solver_verbosity = parameters_.linear_solver_verbosity_;
if(use_gpu && !matrix_add_well_contributions){
std::cerr << "Error cannot use GPU solver if command line parameter --matrix-add-well-contributions is false, because the GPU solver performs a standard bicgstab" << std::endl;
exit(1);
OPM_THROW(std::logic_error,"Error cannot use GPU solver if command line parameter --matrix-add-well-contributions is false, because the GPU solver performs a standard bicgstab");
}
bdaBridge = new BdaBridge(use_gpu, linear_solver_verbosity, maxit, tolerance);
bdaBridge.reset(new BdaBridge(use_gpu, linear_solver_verbosity, maxit, tolerance));
#else
const bool use_gpu = EWOMS_GET_PARAM(TypeTag, bool, UseGpu);
if(use_gpu){
std::cerr << "Error cannot use GPU solver since CUDA was not found during compilation" << std::endl;
exit(1);
OPM_THROW(std::logic_error,"Error cannot use GPU solver since CUDA was not found during compilation");
}
#endif
extractParallelGridInformationToISTL(simulator_.vanguard().grid(), parallelInformation_);
detail::findOverlapRowsAndColumns(simulator_.vanguard().grid(),overlapRowAndColumns_);
}
~ISTLSolverEbos(){
#if HAVE_CUDA
delete bdaBridge;
#endif
}
// nothing to clean here
void eraseMatrix() {
matrix_for_preconditioner_.reset();

View File

@ -35,21 +35,14 @@ namespace Opm
{
BdaBridge::BdaBridge(bool use_gpu_, int linear_solver_verbosity OPM_UNUSED, int maxit OPM_UNUSED, double tolerance OPM_UNUSED) : use_gpu(use_gpu_) {
#if HAVE_CUDA
if(use_gpu){
backend = new cusparseSolverBackend(linear_solver_verbosity, maxit, tolerance);
}
#endif
}
BdaBridge::~BdaBridge(){
#if HAVE_CUDA
if(use_gpu){
delete backend;
backend.reset(new cusparseSolverBackend(linear_solver_verbosity, maxit, tolerance));
}
#endif
}
#if HAVE_CUDA
template <class BridgeMatrix>
int checkZeroDiagonal(BridgeMatrix& mat) {

View File

@ -40,7 +40,7 @@ class BdaBridge
{
private:
#if HAVE_CUDA
cusparseSolverBackend *backend;
std::unique_ptr<cusparseSolverBackend> backend;
#endif
bool use_gpu;