5#ifndef _MOLECULARDYNAMICS_COUPLING_SENDRECV_SENDRECEIVEBUFFER_H_
6#define _MOLECULARDYNAMICS_COUPLING_SENDRECV_SENDRECEIVEBUFFER_H_
8#include "DataExchangeFromMD2Macro.h"
9#include "coupling/CouplingMDDefinitions.h"
10#include "coupling/indexing/IndexingService.h"
11#include "coupling/sendrecv/DataExchange.h"
12#include "tarch/la/Vector.h"
17#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
151 struct BufferWithID {
153 unsigned int bufferSize;
155 BufferWithID() : buffer(NULL), bufferSize(0) {}
158 struct BufferCollective {
159 std::vector<double> buffer;
160 std::set<unsigned int> nonRootRanks;
161 std::set<unsigned int> cellIndices;
162 unsigned int rootRank;
164 BufferCollective() : buffer(), nonRootRanks(), cellIndices(), rootRank(-1) {}
175 std::map<unsigned int, BufferWithID> _sendBuffer;
179 std::map<unsigned int, BufferCollective> _reduceBuffer;
181#if (COUPLING_MD_PARALLEL == COUPLING_MD_YES)
182 bool _requestsAllocated;
189 std::vector<MPI_Group> _subGroups;
190 int _bcastOrReduceSize;
192 static void elementWiseSum(
void* in,
void* inout,
int* len, MPI_Datatype* datatype) {
193 auto* output = (
double*)inout;
194 auto* input = (
double*)in;
195 for (
int i = 0; i < *len; ++i) {
196 output[i] += input[i];
200 MPI_Op elementWiseSumOperation;
204#include "SendReceiveBuffer.cpph"
data exchange from the MD solver to the macroscopic solver. Derived from the class coupling::sendrecv...
Definition DataExchangeFromMD2Macro.h:36
generic class for the the data exchange purposes.
Definition DataExchange.h:27
generic class for send-/ receive methodology.
Definition SendReceiveBuffer.h:35
void allocateReceiveBuffers(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, I01 idx)
void allocateBcastBufferForReceiving(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, I01 idx)
void deleteBuffers()
deletes the buffers
void writeToSendBuffer(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, const Container_T &cells)
fills all information that needs to be sent from a coupling cell into the send-buffer.
void readFromReceiveBuffer(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, const Container_T &cells)
void triggerReceiving(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange)
void allocateReduceRequests(unsigned int thisRank)
std::vector< MPI_Comm > _subComms
Definition SendReceiveBuffer.h:188
void waitAllCollectiveOperations()
int _sendSize
Definition SendReceiveBuffer.h:186
void triggerSending(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange)
void writeToReduceBuffer(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, const Cell_T &cell, I01 idx)
fills all information that needs to be reduced to a coupling cell into the reduce-buffer.
void triggerBcasts(unsigned int rank)
void allocateBcastRequests(unsigned int thisRank)
virtual ~SendReceiveBuffer()
std::map< unsigned int, BufferWithID > _receiveBuffer
Definition SendReceiveBuffer.h:174
MPI_Request * _requests
Definition SendReceiveBuffer.h:184
void allocateReduceBufferForReceiving(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, I01 idx)
std::map< unsigned int, BufferCollective > _bcastBuffer
Definition SendReceiveBuffer.h:178
void triggerReduce(unsigned int rank)
void deleteBuffer(std::map< unsigned int, BufferWithID > &buffer)
void readFromReduceBuffer(coupling::sendrecv::DataExchangeFromMD2Macro< dim > &dataExchange, Cell_T &couplingCell, I01 idx)
void writeToBcastBuffer(coupling::sendrecv::DataExchange< Cell_T, dim > &dataExchange, const Cell_T &cell, I01 idx)
fills all information that needs to be broadcast from a coupling cell into the broadcast-buffer.
everything necessary for coupling operations, is defined in here
Definition AdditiveMomentumInsertion.h:15