mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
refactor CuBlockPreconditioner
This commit is contained in:
parent
3f4ae4ddf4
commit
67bc9e8f34
@ -261,7 +261,7 @@ if (HAVE_CUDA)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg PreconditionerConvertFieldTypeAdapter.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg CuOwnerOverlapCopy.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg SolverAdapter.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg CuBlockPreconditioner.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg GpuBlockPreconditioner.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg PreconditionerHolder.hpp)
|
||||
ADD_CUDA_OR_HIP_FILE(PUBLIC_HEADER_FILES opm/simulators/linalg set_device.hpp)
|
||||
endif()
|
||||
|
@ -22,7 +22,7 @@
|
||||
// both with the normal cuistl path, and the hipistl path
|
||||
#if HAVE_CUDA
|
||||
#if USE_HIP
|
||||
#include <opm/simulators/linalg/hipistl/CuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/hipistl/GpuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/hipistl/CuDILU.hpp>
|
||||
#include <opm/simulators/linalg/hipistl/OpmCuILU0.hpp>
|
||||
#include <opm/simulators/linalg/hipistl/CuJac.hpp>
|
||||
@ -31,7 +31,7 @@
|
||||
#include <opm/simulators/linalg/hipistl/PreconditionerConvertFieldTypeAdapter.hpp>
|
||||
#include <opm/simulators/linalg/hipistl/detail/cuda_safe_call.hpp>
|
||||
#else
|
||||
#include <opm/simulators/linalg/cuistl/CuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/GpuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuDILU.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/OpmCuILU0.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuJac.hpp>
|
||||
|
@ -330,7 +330,7 @@ struct StandardPreconditioners {
|
||||
auto cuILU0 = std::make_shared<CuILU0>(op.getmat(), w);
|
||||
|
||||
auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, CuILU0>>(cuILU0);
|
||||
auto wrapped = std::make_shared<gpuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
return wrapped;
|
||||
});
|
||||
|
||||
@ -342,7 +342,7 @@ struct StandardPreconditioners {
|
||||
auto cuJac = std::make_shared<CuJac>(op.getmat(), w);
|
||||
|
||||
auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, CuJac>>(cuJac);
|
||||
auto wrapped = std::make_shared<gpuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
return wrapped;
|
||||
});
|
||||
|
||||
@ -354,7 +354,7 @@ struct StandardPreconditioners {
|
||||
auto cuDILU = std::make_shared<CuDILU>(op.getmat(), split_matrix, tune_gpu_kernels);
|
||||
|
||||
auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, CuDILU>>(cuDILU);
|
||||
auto wrapped = std::make_shared<gpuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
return wrapped;
|
||||
});
|
||||
|
||||
@ -366,7 +366,7 @@ struct StandardPreconditioners {
|
||||
auto cuilu0 = std::make_shared<OpmCuILU0>(op.getmat(), split_matrix, tune_gpu_kernels);
|
||||
|
||||
auto adapted = std::make_shared<gpuistl::PreconditionerAdapter<V, V, OpmCuILU0>>(cuilu0);
|
||||
auto wrapped = std::make_shared<gpuistl::CuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
auto wrapped = std::make_shared<gpuistl::GpuBlockPreconditioner<V, V, Comm>>(adapted, comm);
|
||||
return wrapped;
|
||||
});
|
||||
#endif
|
||||
|
@ -16,8 +16,8 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef OPM_CUISTL_CUBLOCKPRECONDITIONER_HPP
|
||||
#define OPM_CUISTL_CUBLOCKPRECONDITIONER_HPP
|
||||
#ifndef OPM_CUISTL_GPUBLOCKPRECONDITIONER_HPP
|
||||
#define OPM_CUISTL_GPUBLOCKPRECONDITIONER_HPP
|
||||
|
||||
#include <dune/common/shared_ptr.hh>
|
||||
#include <memory>
|
||||
@ -31,7 +31,7 @@ namespace Opm::gpuistl
|
||||
//!
|
||||
//! @note We aim to intgrate this into OwningBlockPreconditioner (or a relative thereof).
|
||||
template <class X, class Y, class C, class P = Dune::PreconditionerWithUpdate<X, Y>>
|
||||
class CuBlockPreconditioner : public Dune::PreconditionerWithUpdate<X, Y>, public PreconditionerHolder<X, Y>
|
||||
class GpuBlockPreconditioner : public Dune::PreconditionerWithUpdate<X, Y>, public PreconditionerHolder<X, Y>
|
||||
{
|
||||
public:
|
||||
using domain_type = X;
|
||||
@ -47,13 +47,13 @@ public:
|
||||
//! @param c The communication object for syncing overlap and copy
|
||||
//! data points. (E.~g. OwnerOverlapCopyCommunication )
|
||||
//!
|
||||
CuBlockPreconditioner(const std::shared_ptr<P>& p, const std::shared_ptr<const communication_type>& c)
|
||||
GpuBlockPreconditioner(const std::shared_ptr<P>& p, const std::shared_ptr<const communication_type>& c)
|
||||
: m_preconditioner(p)
|
||||
, m_communication(c)
|
||||
{
|
||||
}
|
||||
|
||||
CuBlockPreconditioner(const std::shared_ptr<P>& p, const communication_type& c)
|
||||
GpuBlockPreconditioner(const std::shared_ptr<P>& p, const communication_type& c)
|
||||
: m_preconditioner(p)
|
||||
, m_communication(Dune::stackobject_to_shared_ptr(c))
|
||||
{
|
@ -26,7 +26,7 @@
|
||||
#include <dune/istl/schwarz.hh>
|
||||
#include <dune/istl/solver.hh>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/GpuBlockPreconditioner.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuOwnerOverlapCopy.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuSparseMatrix.hpp>
|
||||
#include <opm/simulators/linalg/cuistl/CuVector.hpp>
|
||||
@ -149,7 +149,7 @@ private:
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"The preconditioner needs to be a CUDA preconditioner (eg. CuILU0) wrapped in a "
|
||||
"Opm::gpuistl::PreconditionerAdapter wrapped in a "
|
||||
"Opm::gpuistl::CuBlockPreconditioner. If you are unsure what this means, set "
|
||||
"Opm::gpuistl::GpuBlockPreconditioner. If you are unsure what this means, set "
|
||||
"preconditioner to 'CUILU0'"); // TODO: Suggest a better preconditioner
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ private:
|
||||
OPM_THROW(std::invalid_argument,
|
||||
"The preconditioner needs to be a CUDA preconditioner (eg. CuILU0) wrapped in a "
|
||||
"Opm::gpuistl::PreconditionerAdapter wrapped in a "
|
||||
"Opm::gpuistl::CuBlockPreconditioner. If you are unsure what this means, set "
|
||||
"Opm::gpuistl::GpuBlockPreconditioner. If you are unsure what this means, set "
|
||||
"preconditioner to 'CUILU0'"); // TODO: Suggest a better preconditioner
|
||||
}
|
||||
// We need to get the underlying preconditioner:
|
||||
@ -196,7 +196,7 @@ private:
|
||||
= Dune::OverlappingSchwarzOperator<CuSparseMatrix<real_type>, XGPU, XGPU, CudaCommunication>;
|
||||
auto cudaCommunication = std::make_shared<CudaCommunication>(gpuComm);
|
||||
|
||||
auto mpiPreconditioner = std::make_shared<CuBlockPreconditioner<XGPU, XGPU, CudaCommunication>>(
|
||||
auto mpiPreconditioner = std::make_shared<GpuBlockPreconditioner<XGPU, XGPU, CudaCommunication>>(
|
||||
preconditionerReallyOnGPU, cudaCommunication);
|
||||
|
||||
auto scalarProduct = std::make_shared<Dune::ParallelScalarProduct<XGPU, CudaCommunication>>(
|
||||
@ -206,8 +206,8 @@ private:
|
||||
// NOTE: Ownsership of cudaCommunication is handled by mpiPreconditioner. However, just to make sure we
|
||||
// remember
|
||||
// this, we add this check. So remember that we hold one count in this scope, and one in the
|
||||
// CuBlockPreconditioner instance. We accomedate for the fact that it could be passed around in
|
||||
// CuBlockPreconditioner, hence we do not test for != 2
|
||||
// GpuBlockPreconditioner instance. We accomedate for the fact that it could be passed around in
|
||||
// GpuBlockPreconditioner, hence we do not test for != 2
|
||||
OPM_ERROR_IF(cudaCommunication.use_count() < 2, "Internal error. Shared pointer not owned properly.");
|
||||
auto overlappingCudaOperator = std::make_shared<SchwarzOperator>(m_matrix, *cudaCommunication);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user