Peano
Loading...
Searching...
No Matches
TreeManagementMessage.h
Go to the documentation of this file.
1// This file is part of the Peano project. For conditions of distribution and
2// use, please see the copyright notice at www.peano-framework.org
3#pragma once
4
5#include <string>
6
7#ifdef Parallel
8 #include <mpi.h>
9 #include <functional>
10#endif
11
12#include "tarch/la/Vector.h"
13#include "tarch/mpi/Rank.h"
18
19
20
21namespace peano4{
22namespace parallel{
23 struct TreeManagementMessage;
24}
25}
26
28 public:
32
34 TreeManagementMessage(int __masterSpacetreeId, int __workerSpacetreeId, Action __action);
35
36 int getMasterSpacetreeId() const;
37 void setMasterSpacetreeId(int value);
38 int getWorkerSpacetreeId() const;
39 void setWorkerSpacetreeId(int value);
41 void setAction(Action value);
43
44
45 #ifdef Parallel
51 [[clang::map_mpi_datatype]]
52 static MPI_Datatype getForkDatatype();
53
54 [[clang::map_mpi_datatype]]
55 static MPI_Datatype getJoinDatatype();
56
57 [[clang::map_mpi_datatype]]
58 static MPI_Datatype getBoundaryExchangeDatatype();
59
60 [[clang::map_mpi_datatype]]
61 static MPI_Datatype getMultiscaleDataExchangeDatatype();
62
63 [[clang::map_mpi_datatype]]
64 static MPI_Datatype getGlobalCommunciationDatatype();
65
66 [[clang::map_mpi_datatype]]
67 static void freeForkDatatype();
68
69 [[clang::map_mpi_datatype]]
70 static void freeJoinDatatype();
71
72 [[clang::map_mpi_datatype]]
73 static void freeBoundaryExchangeDatatype();
74
75 [[clang::map_mpi_datatype]]
77
78 [[clang::map_mpi_datatype]]
80
85 int getSenderRank() const;
86
91 static void initDatatype();
92
96 static void shutdownDatatype();
97
106 static void send(const peano4::parallel::TreeManagementMessage& buffer, int destination, int tag, MPI_Comm communicator );
107 static void receive(peano4::parallel::TreeManagementMessage& buffer, int source, int tag, MPI_Comm communicator );
108
115 static void send(const peano4::parallel::TreeManagementMessage& buffer, int destination, int tag, std::function<void()> startCommunicationFunctor, std::function<void()> waitFunctor, MPI_Comm communicator );
116 static void receive( peano4::parallel::TreeManagementMessage& buffer, int source, int tag, std::function<void()> startCommunicationFunctor, std::function<void()> waitFunctor, MPI_Comm communicator );
117 #endif
118
119
123
126
127#ifdef Parallel
128 static void sendAndPollDanglingMessages(const peano4::parallel::TreeManagementMessage& message, int destination, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator());
129 static void receiveAndPollDanglingMessages(peano4::parallel::TreeManagementMessage& message, int source, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator() );
130#endif
131
132 std::string toString() const;
133
134 private:
135 [[clang::pack_range(-1,std::numeric_limits<int>::max())]] int _masterSpacetreeId;
136 [[clang::pack_range(0,std::numeric_limits<int>::max())]] int _workerSpacetreeId;
137 [[clang::pack]] Action _action;
138
139 #ifdef Parallel
140 private:
142
143 #if !defined(__MPI_ATTRIBUTES_LANGUAGE_EXTENSION__)
150 static MPI_Datatype Datatype;
151 #endif
152 #endif
153};
static Rank & getInstance()
This operation returns the singleton instance.
Definition Rank.cpp:539
The parallel namespace is Peano's core abstracts from both MPI and multicore parallelisation.
peano4::parallel::TreeManagementMessage::Action getAction() const
static void send(const peano4::parallel::TreeManagementMessage &buffer, int destination, int tag, MPI_Comm communicator)
In DaStGen (the first version), I had a non-static version of the send as well as the receive.
static void shutdownDatatype()
Free the underlying MPI datatype.
static MPI_Datatype Datatype
Whenever we use LLVM's MPI extension (DaStGe), we rely on lazy initialisation of the datatype.
TreeManagementMessage(const TreeManagementMessage &copy)=default
static void sendAndPollDanglingMessages(const peano4::parallel::TreeManagementMessage &message, int destination, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator())
static void receiveAndPollDanglingMessages(peano4::parallel::TreeManagementMessage &message, int source, int tag, MPI_Comm communicator=tarch::mpi::Rank::getInstance().getCommunicator())
static MPI_Datatype getForkDatatype()
Hands out MPI datatype if we work without the LLVM MPI extension.
static void receive(peano4::parallel::TreeManagementMessage &buffer, int source, int tag, MPI_Comm communicator)
static void initDatatype()
Wrapper around getDatatype() to trigger lazy evaluation if we use the lazy initialisation.