39 switch (requirement) {
104 auto dir = location.parent_path();
116 return this->size ==
size;
124 return this->name ==
name;
132 return this->rank ==
rank;
151 Par::Parallel::CommState::world()->synchronize();
153 Par::Parallel::CommState::world()->synchronize();
163 const int globalRank = baseComm->rank();
164 const int available = baseComm->size();
172 auto required = groups.
back();
173 if (required > available) {
178 if (globalRank >= required) {
205#ifndef PRECICE_NO_MPI
226 er.setDirectory(
"./precice-profiling");
243#ifndef PRECICE_NO_GINKGO
256 switch (options.
type) {
270 "Acceptor \"" + acceptor +
"\" not defined in this context."};
274 "Connector \"" + connector +
"\" not defined in this context."};
279 m2n->acceptPrimaryRankConnection(acceptor, connector, configHash);
280 }
else if (
isNamed(connector)) {
281 m2n->requestPrimaryRankConnection(acceptor, connector, configHash);
283 throw std::runtime_error{
"You try to connect " + acceptor +
" and " + connector +
", but this context is named " +
name};
291 return "This test context is invalid!";
298 os <<
" represents \"" <<
name <<
'"';
300 os <<
" and runs on rank " <<
rank <<
" out of " <<
size <<
'.';
303 os <<
" Initialized: {";
305 os <<
" IntraComm Communication ";
T weakly_canonical(T... args)
Provides connection methods for processes located in one communicator.
Implements Communication by using sockets.
static void initialize(int *argc, char ***argv)
static EventRegistry & instance()
Returns the only instance (singleton) of the EventRegistry class.
void finalize()
Sets the global end time and flushes buffers.
bool isRank(Rank rank) const
Check whether this context has a given rank inside the Participant.
std::string prefix(const std::string &filename) const
void initialize(const Participants &participants)
Main entrypoint.
bool _initIntraComm
whether this context needs to initialize the intracomm
TestContext(TestSetup setup)
void initializePetsc()
Initialize PETSc if required.
bool invalid
whether this context is valid or not
m2n::PtrM2N connectPrimaryRanks(const std::string &acceptor, const std::string &connector, const ConnectionOptions &options=ConnectionOptions{}) const
std::set< std::string > _names
contains the name of every known Participant
void initializeMPI(const Participants &participants)
bool isNamed(const std::string &name) const
Check whether this context has a given name.
int size
the size of the Communicator of the current participant
std::string describe() const
Provides a user- and log-friendly description of the current context.
bool hasSize(int size) const
Check whether this context has a given size.
utils::Parallel::CommStatePtr _contextComm
the MPI communicator of the context
void initializeIntraComm()
Initialize the intra-participant communication connection if requested.
void initializeGinkgo()
Initialize Ginkgo if required.
void initializeEvents()
Initialize Events if required.
Rank rank
the rank of the current participant
std::string name
the name of the current participant
void setContextFrom(const ParticipantState &p)
std::string config() const
static com::PtrCommunication & getCommunication()
Intra-participant communication.
static void configure(Rank rank, int size)
Configures the intra-participant communication.
Utility class for managing MPI operations.
static void resetCommState()
static CommStatePtr current()
Returns an owning pointer to the current CommState.
static void resetManagedMPI()
static void splitCommunicator(std::optional< int > group=std::nullopt)
Splits and creates a local MPI communicator according to groupName.
static void finalize()
Finalizes Petsc environment.
static void initialize(utils::Parallel::Communicator comm)
Initializes the Petsc environment.
std::shared_ptr< Communication > PtrCommunication
void setMPIRank(int const rank)
void setParticipant(std::string const &participant)
contains the testing framework.
@ PETSc
Require to initialize PETSc. This implies the initialization of Events.
@ Events
Require to initialize Event.
@ Ginkgo
Ginkgo initialization.
std::string getFullTestName()
Return the full name of the current test as seen in boost assertions.
std::string getTestPath()
Returns the full path to the file containing the current test.
std::string getTestName()
Returns the name of the current test.
Represents a ParticipantState in a test.
int size
the amount of ranks this participant runs on
bool initIntraComm
whether to initialize an intra-participant communication for this participant
std::string_view name
the name of the participant
Contains the setup description of a test including participants and requirements.
bool petsc
whether to initialize PETSc
int totalRanks() const
total amount of ranks required by this setup
std::vector< ParticipantState > participants
All known participants.
bool events
whether to initialize events
bool ginkgo
whether to initialize Ginkgo (the device)
void handleOption(ParticipantState participants)