19 #ifndef OPM_GPUISTL_GPUSENDER_HPP 20 #define OPM_GPUISTL_GPUSENDER_HPP 22 #include <dune/istl/owneroverlapcopy.hh> 24 #include <opm/simulators/linalg/FlowLinearSolverParameters.hpp> 25 #include <opm/simulators/linalg/gpuistl/GpuVector.hpp> 42 template <
class field_type,
class OwnerOverlapCopyCommunicationType>
48 GPUSender(
const OwnerOverlapCopyCommunicationType& cpuOwnerOverlapCopy)
49 : m_cpuOwnerOverlapCopy(cpuOwnerOverlapCopy)
65 virtual void initIndexSet()
const = 0;
76 std::call_once(m_initializedIndices, [&]() { initIndexSet(); });
77 x.setZeroAtIndexSet(*m_indicesCopy);
89 void dot(
const X& x,
const X& y, field_type& output)
const 91 std::call_once(m_initializedIndices, [&]() { initIndexSet(); });
93 const auto dotAtRank = x.dot(y, *m_indicesOwner);
94 output = m_cpuOwnerOverlapCopy.communicator().sum(dotAtRank);
105 auto xDotX = field_type(0);
109 return std::sqrt(xDotX);
119 return m_cpuOwnerOverlapCopy.communicator();
126 mutable std::once_flag m_initializedIndices;
127 mutable std::unique_ptr<GpuVector<int>> m_indicesOwner;
128 mutable std::unique_ptr<GpuVector<int>> m_indicesCopy;
129 const OwnerOverlapCopyCommunicationType& m_cpuOwnerOverlapCopy;
134 #endif // OPM_GPUISTL_GPUSENDER_HPP
field_type norm(const X &x) const
norm computes the l^2-norm of x across processes.
Definition: GpuSender.hpp:103
const ::Dune::Communication< MPI_Comm > & communicator() const
communicator returns the MPI communicator used by this GPUSender
Definition: GpuSender.hpp:117
void dot(const X &x, const X &y, field_type &output) const
dot will carry out the dot product between x and y on the owned indices, then sum up the result acros...
Definition: GpuSender.hpp:89
GPUSender is a wrapper class for classes which will implement copOwnerToAll This is implemented with ...
Definition: GpuSender.hpp:43
A small, fixed‑dimension MiniVector class backed by std::array that can be used in both host and CUD...
Definition: AmgxInterface.hpp:37
void project(X &x) const
project will project x to the owned subspace
Definition: GpuSender.hpp:74
virtual void copyOwnerToAll(const X &source, X &dest) const =0
copyOwnerToAll will copy the data in source to all processes.