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>
53template <
class field_type,
class OwnerOverlapCopyCommunicationType>
54class GpuOwnerOverlapCopy
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;
97template <
class field_type,
int block_size,
class OwnerOverlapCopyCommunicationType>
98std::shared_ptr<GpuOwnerOverlapCopy<field_type, OwnerOverlapCopyCommunicationType>>
99makeGpuOwnerOverlapCopy(
const OwnerOverlapCopyCommunicationType& cpuOwnerOverlapCopy)
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<
137 Opm::gpuistl::GPUAwareMPISender<field_type, block_size, OwnerOverlapCopyCommunicationType>>(
138 cpuOwnerOverlapCopy);
141 gpuComm = std::make_shared<
142 Opm::gpuistl::GPUObliviousMPISender<field_type, block_size, OwnerOverlapCopyCommunicationType>>(
143 cpuOwnerOverlapCopy);
148 return std::make_shared<CudaCommunication>(gpuComm);
GPUSender is a wrapper class for classes which will implement copOwnerToAll This is implemented with ...
Definition GpuSender.hpp:44
CUDA compatiable variant of Dune::OwnerOverlapCopyCommunication.
Definition GpuOwnerOverlapCopy.hpp:55
const ::Dune::Communication< MPI_Comm > & communicator() const
communicator returns the MPI communicator used by this GpuOwnerOverlapCopy
Definition GpuOwnerOverlapCopy.hpp:88
Definition gpu_type_detection.hpp:30
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUDA...
Definition AmgxInterface.hpp:38
auto Get(bool errorIfNotRegistered=true)
Retrieve a runtime parameter.
Definition parametersystem.hpp:187