Nektar++
Public Member Functions | Private Attributes | List of all members
Nektar::MultiRegions::AllToAllV Class Referencefinal

#include <AssemblyCommDG.h>

Inheritance diagram for Nektar::MultiRegions::AllToAllV:
[legend]

Public Member Functions

 AllToAllV (const LibUtilities::CommSharedPtr &comm, const std::map< int, std::vector< int > > &rankSharedEdges, const std::map< int, std::vector< int > > &edgeToTrace, const int &nRanks)
 Default constructor. More...
 
void PerformExchange (const Array< OneD, NekDouble > &testFwd, Array< OneD, NekDouble > &testBwd) final
 
- Public Member Functions inherited from Nektar::MultiRegions::ExchangeMethod
 ExchangeMethod ()=default
 Default constructor. More...
 
virtual ~ExchangeMethod ()=default
 Default destructor. More...
 
virtual void PerformExchange (const Array< OneD, NekDouble > &testFwd, Array< OneD, NekDouble > &testBwd)=0
 

Private Attributes

LibUtilities::CommSharedPtr m_comm
 Communicator. More...
 
std::vector< int > m_allVEdgeIndex
 List of trace map indices of the quad points to exchange. More...
 
Array< OneD, int > m_allVSendCount
 List of counts for MPI_alltoallv. More...
 
Array< OneD, int > m_allVSendDisp
 List of displacements for MPI_alltoallv. More...
 

Detailed Description

Uses the MPI_AllToAllV collective operation to perform the exchange of quadrature values. This allows for varying exchange array sizes to minimise communication data size. All ranks communicate to all other ranks, however the array size can be 0 to avoid unnecessary data transfer. One collective peration is posted on each rank which requires communication.

Definition at line 133 of file AssemblyCommDG.h.

Constructor & Destructor Documentation

◆ AllToAllV()

Nektar::MultiRegions::AllToAllV::AllToAllV ( const LibUtilities::CommSharedPtr comm,
const std::map< int, std::vector< int > > &  rankSharedEdges,
const std::map< int, std::vector< int > > &  edgeToTrace,
const int &  nRanks 
)

Default constructor.

Definition at line 99 of file AssemblyCommDG.cpp.

103 : m_comm(comm)
104{
105 m_allVSendCount = Array<OneD, int>(nRanks, 0);
106 for (size_t i = 0; i < nRanks; ++i)
107 {
108 if (rankSharedEdges.find(i) != rankSharedEdges.end())
109 {
110 for (size_t j = 0; j < rankSharedEdges.at(i).size(); ++j)
111 {
112 std::vector<int> edgeIndex =
113 edgeToTrace.at(rankSharedEdges.at(i)[j]);
114 m_allVEdgeIndex.insert(m_allVEdgeIndex.end(), edgeIndex.begin(),
115 edgeIndex.end());
116 m_allVSendCount[i] += edgeIndex.size();
117 }
118 }
119 else
120 {
121 m_allVSendCount[i] = 0;
122 }
123 }
124
125 m_allVSendDisp = Array<OneD, int>(nRanks, 0);
126 for (size_t i = 1; i < nRanks; ++i)
127 {
128 m_allVSendDisp[i] = m_allVSendDisp[i - 1] + m_allVSendCount[i - 1];
129 }
130}
std::vector< int > m_allVEdgeIndex
List of trace map indices of the quad points to exchange.
LibUtilities::CommSharedPtr m_comm
Communicator.
Array< OneD, int > m_allVSendCount
List of counts for MPI_alltoallv.
Array< OneD, int > m_allVSendDisp
List of displacements for MPI_alltoallv.

References m_allVEdgeIndex, m_allVSendCount, and m_allVSendDisp.

Member Function Documentation

◆ PerformExchange()

void Nektar::MultiRegions::AllToAllV::PerformExchange ( const Array< OneD, NekDouble > &  testFwd,
Array< OneD, NekDouble > &  testBwd 
)
finalvirtual

Perform MPI comm exchange taking the Fwd trace and sending partition edge trace values to the matching locations in the Bwd trace of corresponding adjacent partitions.

Parameters
[in]testFwdThe values to send to adjacent partitions
[out]testBwdThe values received from adjacent partitions

Implements Nektar::MultiRegions::ExchangeMethod.

Definition at line 272 of file AssemblyCommDG.cpp.

274{
275 Array<OneD, NekDouble> sendBuff(m_allVEdgeIndex.size(), -1);
276 Array<OneD, NekDouble> recvBuff(m_allVEdgeIndex.size(), -1);
277
278 Vmath::Gathr(int(m_allVEdgeIndex.size()), testFwd.data(),
279 m_allVEdgeIndex.data(), sendBuff.data());
280
281 m_comm->AlltoAllv(sendBuff, m_allVSendCount, m_allVSendDisp, recvBuff,
283
284 Vmath::Scatr(int(m_allVEdgeIndex.size()), recvBuff.data(),
285 m_allVEdgeIndex.data(), testBwd.data());
286}
void Gathr(I n, const T *x, const I *y, T *z)
Gather vector z[i] = x[y[i]].
Definition: Vmath.hpp:507
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i].
Definition: Vmath.hpp:539

References Vmath::Gathr(), m_allVEdgeIndex, m_allVSendCount, m_allVSendDisp, m_comm, and Vmath::Scatr().

Member Data Documentation

◆ m_allVEdgeIndex

std::vector<int> Nektar::MultiRegions::AllToAllV::m_allVEdgeIndex
private

List of trace map indices of the quad points to exchange.

Definition at line 150 of file AssemblyCommDG.h.

Referenced by AllToAllV(), and PerformExchange().

◆ m_allVSendCount

Array<OneD, int> Nektar::MultiRegions::AllToAllV::m_allVSendCount
private

List of counts for MPI_alltoallv.

Definition at line 152 of file AssemblyCommDG.h.

Referenced by AllToAllV(), and PerformExchange().

◆ m_allVSendDisp

Array<OneD, int> Nektar::MultiRegions::AllToAllV::m_allVSendDisp
private

List of displacements for MPI_alltoallv.

Definition at line 154 of file AssemblyCommDG.h.

Referenced by AllToAllV(), and PerformExchange().

◆ m_comm

LibUtilities::CommSharedPtr Nektar::MultiRegions::AllToAllV::m_comm
private

Communicator.

Definition at line 148 of file AssemblyCommDG.h.

Referenced by PerformExchange().