25#if BITPIT_ENABLE_MPI==1
27#ifndef __BITPIT_COMMUNICATIONS_HPP__
28#define __BITPIT_COMMUNICATIONS_HPP__
32#include <unordered_map>
34#include "bitpit_common.hpp"
35#include "bitpit_containers.hpp"
37#include "communications_buffers.hpp"
45 BITPIT_PUBLIC_API
static const int TAG_AUTO = -1;
55 void finalize(
bool synchronous =
false);
57 void setTag(
int exchangeTag);
58 void setTags(
int exchangeTag,
int discoverTag,
int notificationTag);
73 void setSend(
int rank,
long length = 0);
74 void setRecv(
int rank,
long length = 0);
100 int waitAnySend(
const std::vector<int> &blackList = std::vector<int>());
104 int waitAnyRecv(
const std::vector<int> &blackList = std::vector<int>());
118 MPI_Comm m_communicator;
122 int m_notificationTag;
123 bool m_customExchangeTag;
124 bool m_customDiscoverTag;
125 bool m_customNotificationTag;
126 bool m_recvsContinuous;
128 std::vector<int> m_recvRanks;
129 std::unordered_map<int, int> m_recvIds;
130 std::vector<MPI_Request> m_recvRequests;
131 std::vector<RecvBuffer> m_recvBuffers;
133 std::vector<int> m_sendRanks;
134 std::unordered_map<int, int> m_sendIds;
135 std::vector<MPI_Request> m_sendRequests;
136 std::vector<SendBuffer> m_sendBuffers;
138 void _startSend(
int dstRank);
139 void _startRecv(
int srcRank);
141 MPI_Datatype getChunkDataType(
int chunkSize)
const;
The DataCommunicator class provides the infrastructure needed to exchange data among processes.
int waitAnySend(const std::vector< int > &blackList=std::vector< int >())
void clearAllSends(bool synchronous=false)
void finalize(bool synchronous=false)
void setRecv(int rank, long length=0)
const MPI_Comm & getCommunicator() const
void startRecv(int srcRank)
SendBuffer & getSendBuffer(int rank)
bool isRecvActive(int rank)
int getExchangeTag() const
const std::vector< int > & getRecvRanks() const
int getProcessorCount() const
void resizeSend(int rank, long resize)
void setTags(int exchangeTag, int discoverTag, int notificationTag)
const std::vector< int > & getSendRanks() const
bool isSendActive(int rank)
void cancelRecv(int rank)
int waitAnyRecv(const std::vector< int > &blackList=std::vector< int >())
DataCommunicator(MPI_Comm communicator)
int getNotificationTag() const
void resizeRecv(int rank, long resize)
void setSend(int rank, long length=0)
void setExchangeTag(int tag)
int getDiscoverTag() const
void cancelAllRecvs(bool synchronous=false)
void cancelSend(int rank)
void cancelAllSends(bool synchronous=false)
void setTag(int exchangeTag)
bool areRecvsContinuous()
void setNotificationTag(int tag)
void setDiscoverTag(int tag)
void clearAllRecvs(bool synchronous=false)
void setRecvsContinuous(bool enabled)
RecvBuffer & getRecvBuffer(int rank)
void startSend(int dstRank)
Buffer to be used for receive communications.
Buffer to be used for send communications.