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...
 

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 136 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 101 of file AssemblyCommDG.cpp.

105  : m_comm(comm)
106 {
107  m_allVSendCount = Array<OneD, int>(nRanks, 0);
108  for (size_t i = 0; i < nRanks; ++i)
109  {
110  if (rankSharedEdges.find(i) != rankSharedEdges.end())
111  {
112  for (size_t j = 0; j < rankSharedEdges.at(i).size(); ++j)
113  {
114  std::vector<int> edgeIndex =
115  edgeToTrace.at(rankSharedEdges.at(i)[j]);
116  m_allVEdgeIndex.insert(m_allVEdgeIndex.end(), edgeIndex.begin(),
117  edgeIndex.end());
118  m_allVSendCount[i] += edgeIndex.size();
119  }
120  }
121  else
122  {
123  m_allVSendCount[i] = 0;
124  }
125  }
126 
127  m_allVSendDisp = Array<OneD, int>(nRanks, 0);
128  for (size_t i = 1; i < nRanks; ++i)
129  {
130  m_allVSendDisp[i] = m_allVSendDisp[i - 1] + m_allVSendCount[i - 1];
131  }
132 }
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 274 of file AssemblyCommDG.cpp.

276 {
277  Array<OneD, NekDouble> sendBuff(m_allVEdgeIndex.size(), -1);
278  Array<OneD, NekDouble> recvBuff(m_allVEdgeIndex.size(), -1);
279 
280  for (size_t i = 0; i < m_allVEdgeIndex.size(); ++i)
281  {
282  sendBuff[i] = testFwd[m_allVEdgeIndex[i]];
283  }
284 
285  m_comm->AlltoAllv(sendBuff, m_allVSendCount, m_allVSendDisp, recvBuff,
287 
288  for (size_t i = 0; i < m_allVEdgeIndex.size(); ++i)
289  {
290  testBwd[m_allVEdgeIndex[i]] = recvBuff[i];
291  }
292 }

References m_allVEdgeIndex, m_allVSendCount, m_allVSendDisp, and m_comm.

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 153 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 155 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 157 of file AssemblyCommDG.h.

Referenced by AllToAllV(), and PerformExchange().

◆ m_comm

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

Communicator.

Definition at line 151 of file AssemblyCommDG.h.

Referenced by PerformExchange().