138 assertionMsg( stack._currentElement==0,
"may not copy non-empty stack" );
140 assertionMsg( stack._ioMPIRequest==
nullptr,
"may not copy sending/receiving stack" );
162 _data[n] = data._data[n];
196 const T&
get(
int index)
const {
209 std::ostringstream msg;
210 msg <<
"(size=" <<
_size
252 inline T*
set(
int index,
const T& value) {
259 inline const T&
get(
int index)
const {
265 inline T&
get(
int index) {
272 std::ostringstream msg;
273 msg <<
"(size=" <<
_size
321 const T&
top(
int shift=0)
const {
332 void push(
const T& element ) {
336 _data.push_back( element );
404 [[maybe_unused]]
int rank,
405 [[maybe_unused]]
int tag,
406 [[maybe_unused]] MPI_Comm comm
418 int result = MPI_Isend(
421 translateContextIntoDatatype<T>( context ),
423 if (result!=MPI_SUCCESS) {
424 logError(
"startSend(int,int,bool)",
"was not able to send to node " << rank <<
" on tag " << tag
436 [[maybe_unused]]
int rank,
437 [[maybe_unused]]
int tag,
438 [[maybe_unused]] MPI_Comm comm,
439 [[maybe_unused]]
int numberOfElements
443 assertion3( numberOfElements>0, rank, tag, numberOfElements );
449 _data.resize(numberOfElements, T(T::ObjectConstruction::NoData));
456 int result = MPI_Irecv(
459 translateContextIntoDatatype<T>( context ),
461 if (result!=MPI_SUCCESS) {
462 logError(
"startReceive(int,int,int)",
"was not able to receive " << numberOfElements <<
" values from node " << rank <<
" on tag " << tag
494 logDebug(
"tryToFinishSendOrReceive()",
"send/receive complete, free MPI request: " <<
toString() );
530 std::reverse(std::begin(
_data), std::end(
_data));
534 std::ostringstream msg;
535 msg <<
"(size=" <<
size()
559 return T::getBoundaryExchangeDatatype();
561 return T::getMultiscaleDataExchangeDatatype();
563 return T::getForkDatatype();
565 return T::getJoinDatatype();
567 assertionMsg(
false,
"periodic boundary data is never exchanged via MPI" );
568 return T::getGlobalCommunciationDatatype();
570 assertionMsg(
false,
"no valid case statement found. This may not happen" );
571 return T::getGlobalCommunciationDatatype();
#define assertion2(expr, param0, param1)
#define assertionEquals1(lhs, rhs, a)
#define assertion3(expr, param0, param1, param2)
#define assertionEquals(lhs, rhs)
#define assertion1(expr, param)
#define assertionMsg(expr, message)
#define logError(methodName, logMacroMessageStream)
Wrapper macro around tarch::tarch::logging::Log to improve logging.
#define logDebug(methodName, logMacroMessageStream)
#define logTraceOutWith1Argument(methodName, argument0)
#define logTraceInWith4Arguments(methodName, argument0, argument1, argument2, argument3)
SendReceiveContext
There are three different scenarios when we merge data:
@ PeriodicBoundaryDataSwap
This class represents a whole block of the tree.
std::string toString() const
const T & get(int index) const
peano4::stacks::STDVectorStack< T > * _stack
PopBlockStackView(int size, int base, peano4::stacks::STDVectorStack< T > *stack)
Constructor.
const T & get(int index) const
T * set(int index, const T &value)
Set an entry.
std::string toString() const
peano4::stacks::STDVectorStack< T > * _stack
PushBlockStackView(int size, int base, peano4::stacks::STDVectorStack< T > *stack)
Constructor.
Default stack implementation using std::vector.
~STDVectorStack()=default
std::vector< T > _data
This is the attribute holding all the temporary stacks.
void startSend(peano4::grid::TraversalObserver::SendReceiveContext context, int rank, int tag, MPI_Comm comm)
Always pairs up with a finish... call.
bool tryToFinishSendOrReceive()
If this routine is invoked on a stack which is neither sending or receiving, then it degenerates to n...
PopBlockStackView popBlock(int numberOfElements)
This operation grabs numberOfElements from the input stack en block and returns a view to it.
int _currentElement
Identifies top element of stack.
void push(const T &element)
Pushes element to a stack.
STDVectorStack()
Constructor.
void reverse()
Reversing a stream is something I need extremely rarely.
static tarch::logging::Log _log
Logging device.
void startReceive(peano4::grid::TraversalObserver::SendReceiveContext context, int rank, int tag, MPI_Comm comm, int numberOfElements)
void clone(const STDVectorStack< T > &data)
Clone data into the current object on which clone() is called.
MPI_Request * _ioMPIRequest
STDVectorStack & operator=(const STDVectorStack< T > &stack)
One is allowed to copy a stack but it has to be empty.
PushBlockStackView pushBlock(int numberOfElements)
Push a block on the output stack.
std::string toString() const
const T & top(int shift=0) const
Get top element or shiftth top element.
T pop()
Pops element from a stack.
int sendingOrReceiving() const
I need this one to find out whether I'm waiting for data.
STDVectorStack(const STDVectorStack< T > &stack)
One is allowed to clone/copy a stack, but it has to be empty.
T & top(int shift=0)
Get top element or shiftth top element.
MPI_Datatype translateContextIntoDatatype(peano4::grid::TraversalObserver::SendReceiveContext context)
STDVectorStack< peano4::grid::GridVertex > GridVertexStack
std::string MPIReturnValueToString(int result)