mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Updated HAVE_XX guards. Replaced string == compare with .compare()
This commit is contained in:
parent
39df7c9381
commit
b9e4bd3a95
@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
#include <opm/common/utility/platform_dependent/reenable_warnings.h>
|
||||||
|
|
||||||
#if HAVE_CUDA
|
#if HAVE_CUDA + HAVE_OPENCL
|
||||||
#include <opm/simulators/linalg/bda/BdaBridge.hpp>
|
#include <opm/simulators/linalg/bda/BdaBridge.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ protected:
|
|||||||
enum { pressureVarIndex = Indices::pressureSwitchIdx };
|
enum { pressureVarIndex = Indices::pressureSwitchIdx };
|
||||||
static const int numEq = Indices::numEq;
|
static const int numEq = Indices::numEq;
|
||||||
|
|
||||||
#if HAVE_CUDA
|
#if HAVE_CUDA + HAVE_OPENCL
|
||||||
std::unique_ptr<BdaBridge> bdaBridge;
|
std::unique_ptr<BdaBridge> bdaBridge;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -316,9 +316,9 @@ protected:
|
|||||||
prm_ = setupPropertyTree<TypeTag>(parameters_);
|
prm_ = setupPropertyTree<TypeTag>(parameters_);
|
||||||
}
|
}
|
||||||
const auto& gridForConn = simulator_.vanguard().grid();
|
const auto& gridForConn = simulator_.vanguard().grid();
|
||||||
#if HAVE_CUDA
|
#if HAVE_CUDA + HAVE_OPENCL
|
||||||
std::string gpu_mode = EWOMS_GET_PARAM(TypeTag, std::string, GpuMode);
|
std::string gpu_mode = EWOMS_GET_PARAM(TypeTag, std::string, GpuMode);
|
||||||
if (gridForConn.comm().size() > 1 && "none" != gpu_mode) {
|
if (gridForConn.comm().size() > 1 && gpu_mode.compare("none") != 0) {
|
||||||
OpmLog::warning("Warning cannot use GPU with MPI, GPU is disabled");
|
OpmLog::warning("Warning cannot use GPU with MPI, GPU is disabled");
|
||||||
gpu_mode = "none";
|
gpu_mode = "none";
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ protected:
|
|||||||
bdaBridge.reset(new BdaBridge(gpu_mode, linear_solver_verbosity, maxit, tolerance));
|
bdaBridge.reset(new BdaBridge(gpu_mode, linear_solver_verbosity, maxit, tolerance));
|
||||||
#else
|
#else
|
||||||
const bool gpu_mode = EWOMS_GET_PARAM(TypeTag, bool, GpuMode);
|
const bool gpu_mode = EWOMS_GET_PARAM(TypeTag, bool, GpuMode);
|
||||||
if ("none" != gpu_mode) {
|
if (gpu_mode.compare("none") != 0) {
|
||||||
OPM_THROW(std::logic_error,"Error cannot use GPU solver since CUDA was not found during compilation");
|
OPM_THROW(std::logic_error,"Error cannot use GPU solver since CUDA was not found during compilation");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -622,7 +622,7 @@ protected:
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
// tries to solve linear system
|
// tries to solve linear system
|
||||||
#if HAVE_CUDA
|
#if HAVE_CUDA + HAVE_OPENCL
|
||||||
bool use_gpu = bdaBridge->getUseGpu();
|
bool use_gpu = bdaBridge->getUseGpu();
|
||||||
if (use_gpu) {
|
if (use_gpu) {
|
||||||
WellContributions wellContribs;
|
WellContributions wellContribs;
|
||||||
|
@ -41,17 +41,24 @@ namespace Opm
|
|||||||
BdaBridge::BdaBridge(std::string gpu_mode_, int linear_solver_verbosity, int maxit, double tolerance)
|
BdaBridge::BdaBridge(std::string gpu_mode_, int linear_solver_verbosity, int maxit, double tolerance)
|
||||||
: gpu_mode(gpu_mode_)
|
: gpu_mode(gpu_mode_)
|
||||||
{
|
{
|
||||||
if (gpu_mode == "cusparse") {
|
std::cout << "mode: " << gpu_mode_ << std::endl;
|
||||||
|
if (gpu_mode.compare("cusparse") == 0) {
|
||||||
|
#if HAVE_CUDA
|
||||||
use_gpu = true;
|
use_gpu = true;
|
||||||
backend.reset(new bda::cusparseSolverBackend(linear_solver_verbosity, maxit, tolerance));
|
backend.reset(new bda::cusparseSolverBackend(linear_solver_verbosity, maxit, tolerance));
|
||||||
} else if (gpu_mode == "opencl") {
|
#else
|
||||||
|
OPM_THROW(std::logic_error, "Error cusparseSolver was chosen, but CUDA was not found by CMake");
|
||||||
|
#endif
|
||||||
|
} else if (gpu_mode.compare("opencl") == 0) {
|
||||||
#if HAVE_OPENCL
|
#if HAVE_OPENCL
|
||||||
use_gpu = true;
|
use_gpu = true;
|
||||||
backend.reset(new bda::openclSolverBackend(linear_solver_verbosity, maxit, tolerance));
|
backend.reset(new bda::openclSolverBackend(linear_solver_verbosity, maxit, tolerance));
|
||||||
#else
|
#else
|
||||||
OPM_THROW(std::logic_error, "Error openclSolver was chosen, but OpenCL was not found by CMake");
|
OPM_THROW(std::logic_error, "Error openclSolver was chosen, but OpenCL was not found by CMake");
|
||||||
#endif
|
#endif
|
||||||
} else if (gpu_mode != "none") {
|
} else if (gpu_mode.compare("none") == 0) {
|
||||||
|
use_gpu = false;
|
||||||
|
} else {
|
||||||
OPM_THROW(std::logic_error, "Error unknown value for parameter 'GpuMode', should be passed like '--gpu-mode=[none|cusparse|opencl]");
|
OPM_THROW(std::logic_error, "Error unknown value for parameter 'GpuMode', should be passed like '--gpu-mode=[none|cusparse|opencl]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user