19 #ifndef OPM_GPUISTL_GPUOWNEROVERLAPCOPY_HPP 20 #define OPM_GPUISTL_GPUOWNEROVERLAPCOPY_HPP 22 #include <dune/istl/owneroverlapcopy.hh> 24 #include <opm/simulators/linalg/FlowLinearSolverParameters.hpp> 25 #include <opm/simulators/linalg/gpuistl/GpuAwareMPISender.hpp> 26 #include <opm/simulators/linalg/gpuistl/GpuObliviousMPISender.hpp> 27 #include <opm/simulators/linalg/gpuistl/GpuVector.hpp> 53 template <
class field_type,
class OwnerOverlapCopyCommunicationType>
64 void copyOwnerToAll(
const X& source,
X& dest)
const 66 m_sender->copyOwnerToAll(source, dest);
69 void dot(
const X& x,
const X& y, field_type& output)
const 71 m_sender->dot(x, y, output);
74 field_type norm(
const X& x)
const 76 return m_sender->norm(x);
79 void project(
X& x)
const 90 return m_sender->communicator();
94 std::shared_ptr<GPUSender<field_type, OwnerOverlapCopyCommunicationType>> m_sender;
97 template <
class field_type,
int block_size,
class OwnerOverlapCopyCommunicationType>
98 std::shared_ptr<GpuOwnerOverlapCopy<field_type, OwnerOverlapCopyCommunicationType>>
99 makeGpuOwnerOverlapCopy(
const OwnerOverlapCopyCommunicationType& cpuOwnerOverlapCopy)
102 const auto useGPUAwareMPI = Opm::Parameters::Get<Opm::Parameters::GpuAwareMpi>();
103 const auto verifyGPUAwareMPI = Opm::Parameters::Get<Opm::Parameters::VerifyGpuAwareMpi>();
104 std::shared_ptr<Opm::gpuistl::GPUSender<field_type, OwnerOverlapCopyCommunicationType>> gpuComm;
106 if (useGPUAwareMPI) {
107 if (verifyGPUAwareMPI) {
110 bool mpiSupportsCudaAwareAtCompileTime =
false;
111 bool mpiSupportsCudaAwareAtRunTime =
false;
113 #if defined(MPIX_CUDA_AWARE_SUPPORT) && MPIX_CUDA_AWARE_SUPPORT 114 mpiSupportsCudaAwareAtCompileTime =
true;
117 #if defined(MPIX_CUDA_AWARE_SUPPORT) 118 if (1 == MPIX_Query_cuda_support()) {
119 mpiSupportsCudaAwareAtRunTime =
true;
123 if (!mpiSupportsCudaAwareAtCompileTime || !mpiSupportsCudaAwareAtRunTime) {
124 OPM_THROW(std::runtime_error,
125 fmt::format(fmt::runtime(
"The GPU-aware MPI support is not available. " 126 "CUDA aware support at compile time: {}, " 127 "CUDA aware support at runtime: {}. " 128 "Please check your MPI installation and the OPM configuration " 129 "or run with --gpu-aware-mpi=false. If you are sure that your MPI " 130 "implementation supports GPU aware MPI, you can disable this check " 131 "by setting --verify-gpu-aware-mpi=false."),
132 mpiSupportsCudaAwareAtCompileTime ?
"yes" :
"no",
133 mpiSupportsCudaAwareAtRunTime ?
"yes" :
"no"));
136 gpuComm = std::make_shared<
138 cpuOwnerOverlapCopy);
141 gpuComm = std::make_shared<
143 cpuOwnerOverlapCopy);
146 using CudaCommunication = GpuOwnerOverlapCopy<field_type, OwnerOverlapCopyCommunicationType>;
148 return std::make_shared<CudaCommunication>(gpuComm);
CUDA compatiable variant of Dune::OwnerOverlapCopyCommunication.
Definition: GpuOwnerOverlapCopy.hpp:54
Derived class of GPUSender that handles MPI calls that should NOT use GPU direct communicatoin The im...
Definition: GpuObliviousMPISender.hpp:43
GPUSender is a wrapper class for classes which will implement copOwnerToAll This is implemented with ...
Definition: GpuSender.hpp:43
const ::Dune::Communication< MPI_Comm > & communicator() const
communicator returns the MPI communicator used by this GpuOwnerOverlapCopy
Definition: GpuOwnerOverlapCopy.hpp:88
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37
Derived class of GPUSender that handles MPI made with CUDA aware MPI The copOwnerToAll function uses ...
Definition: GpuAwareMPISender.hpp:45