ls1-MarDyn
ls1-MarDyn molecular dynamics code
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DomainDecompMPIBase Class Referenceabstract
Inheritance diagram for DomainDecompMPIBase:
DomainDecompBase MemoryProfilable DomainDecomposition GeneralDomainDecomposition KDDecomposition

Public Member Functions

void barrier () const override
 synchronizes all processes More...
 
unsigned Ndistribution (unsigned localN, float *minrnd, float *maxrnd)
 returns total number of molecules More...
 
void assertIntIdentity (int IX)
 checks identity of random number generators More...
 
void assertDisjunctivity (ParticleContainer *moleculeContainer) const override
 
void collCommInit (int numValues, int key=0) override
 has to call init method of a CollComm class More...
 
void collCommFinalize () override
 has to call finalize method of a CollComm class More...
 
void collCommAppendInt (int intValue) override
 has to call appendInt method of a CollComm class More...
 
void collCommAppendUnsLong (unsigned long unsLongValue) override
 has to call appendUnsLong method of a CollComm class More...
 
void collCommAppendFloat (float floatValue) override
 has to call appendFloat method of a CollComm class More...
 
void collCommAppendDouble (double doubleValue) override
 has to call appendDouble method of a CollComm class More...
 
void collCommAppendLongDouble (long double longDoubleValue) override
 has to call appendLongDouble method of a CollComm class More...
 
int collCommGetInt () override
 has to call getInt method of a CollComm class More...
 
unsigned long collCommGetUnsLong () override
 has to call getUnsLong method of a CollComm class More...
 
float collCommGetFloat () override
 has to call getFloat method of a CollComm class More...
 
double collCommGetDouble () override
 has to call getDouble method of a CollComm class More...
 
long double collCommGetLongDouble () override
 has to call getLongDouble method of a CollComm class More...
 
void collCommAllreduceSum () override
 has to call allreduceSum method of a CollComm class (none in sequential version) More...
 
void collCommAllreduceSumAllowPrevious () override
 has to call allreduceSum method of a CollComm class (none in sequential version), allows for values of previous iteration. More...
 
void collCommAllreduceCustom (ReduceType type) override
 has to call allreduceCustom method of a CollComm class (none in sequential version) More...
 
void collCommScanSum () override
 has to call scanSum method of a CollComm class (none in sequential version) More...
 
void collCommBroadcast (int root=0) override
 has to call broadcast method of a CollComm class (none in sequential version) More...
 
virtual void balanceAndExchangeInitNonBlocking (bool forceRebalancing, ParticleContainer *moleculeContainer, Domain *domain)
 
virtual void prepareNonBlockingStage (bool forceRebalancing, ParticleContainer *moleculeContainer, Domain *domain, unsigned int stageNumber)=0
 
virtual void finishNonBlockingStage (bool forceRebalancing, ParticleContainer *moleculeContainer, Domain *domain, unsigned int stageNumber)=0
 
void exchangeMoleculesMPI (ParticleContainer *moleculeContainer, Domain *domain, MessageType msgType, bool doHaloPositionCheck=true, bool removeRecvDuplicates=false)
 exchange molecules between processes More...
 
void exchangeForces (ParticleContainer *moleculeContainer, Domain *domain) override
 Exchanges forces at the domain boundaries if it's required by the cell container. More...
 
std::vector< int > getNeighbourRanks () override=0
 
std::vector< int > getNeighbourRanksFullShell () override=0
 
virtual std::vector< CommunicationPartnergetNeighboursFromHaloRegion (Domain *domain, const HaloRegion &haloRegion, double cutoff)=0
 
MPI_Datatype getMPIParticleType ()
 
MPI_Datatype getMPIParticleForceType ()
 
MPI_Comm getCommunicator () override
 
virtual void readXML (XMLfileUnits &xmlconfig)
 Read in XML configuration for DomainDecompMPIBase. More...
 
virtual void setCommunicationScheme (const std::string &scheme, const std::string &comScheme)
 
virtual int getNonBlockingStageCount () override
 
virtual size_t getTotalSize () override
 
virtual void printSubInfo (int offset) override
 
virtual void printDecomp (const std::string &filename, Domain *domain, ParticleContainer *particleContainer) override
 writes information about the current decomposition into the given file More...
 
virtual std::string getName () override
 
void printCommunicationPartners (std::string filename) const override
 
- Public Member Functions inherited from DomainDecompBase
 DomainDecompBase ()
 The Constructor determines the own rank and the number of the neighbours *‍/.
 
 ~DomainDecompBase () override
 The Destructor finalizes MPI.
 
void exchangeMolecules (ParticleContainer *moleculeContainer, Domain *domain)
 exchange molecules between processes More...
 
virtual bool queryBalanceAndExchangeNonBlocking (bool forceRebalancing, ParticleContainer *moleculeContainer, Domain *domain, double etime)
 Checks whether the balance and exchange step can be performed non-blocking. More...
 
virtual void balanceAndExchange (double lastTraversalTime, bool forceRebalancing, ParticleContainer *moleculeContainer, Domain *domain)
 balance the load (and optimize communication) and exchange boundary particles More...
 
virtual bool procOwnsPos (double x, double y, double z, Domain *domain) final
 find out whether the given position belongs to the domain of this process More...
 
void getBoundingBoxMinMax (Domain *domain, double *min, double *max)
 get the minimum and maximum coordinate of the bounding box of this process' domain More...
 
virtual double getBoundingBoxMin (int dimension, Domain *domain)
 get the minimum of the bounding box of this process' domain in the given dimension (0,1,2) More...
 
virtual double getBoundingBoxMax (int dimension, Domain *domain)
 get the maximum of the bounding box of this process' domain in the given dimension (0,1,2) More...
 
virtual int getRank () const
 returns the own rank More...
 
virtual int getNumProcs () const
 returns the number of processes More...
 
virtual double getTime () const
 returns the time in seconds since some time in the past
 
double getIOCutoffRadius (int dim, Domain *domain, ParticleContainer *moleculeContainer)
 returns an cutoff radius for a dimension for a global linked cells datastructure More...
 
void writeMoleculesToMPIFileBinary (const std::string &filename, ParticleContainer *moleculeContainer) const
 appends molecule data to the file. The format is the same as that of the input file This version uses, MPI IO. More...
 
void writeMoleculesToFile (const std::string &filename, ParticleContainer *moleculeContainer, bool binary=false) const
 appends molecule data to the file. The format is the same as that of the input file If MPI is enabled and binary files are supposed to be written this function will call writeMoleculesToMPIFileBinary(). Otherwise, to ensure that not more than one process writes to the file at any time, there is a loop over all processes with a barrier in between. More...
 
void updateSendLeavingWithCopies (bool sendTogether)
 
bool sendLeavingWithCopies () const
 
virtual std::vector< std::vector< std::vector< int > > > getAllRanks ()
 

Protected Member Functions

virtual void prepareNonBlockingStageImpl (ParticleContainer *moleculeContainer, Domain *domain, unsigned int stageNumber, MessageType msgType, bool removeRecvDuplicates=false)
 
virtual void finishNonBlockingStageImpl (ParticleContainer *moleculeContainer, Domain *domain, unsigned int stageNumber, MessageType msgType, bool removeRecvDuplicates=false)
 
- Protected Member Functions inherited from DomainDecompBase
void addLeavingMolecules (std::vector< Molecule > &&invalidMolecules, ParticleContainer *moleculeContainer)
 
void handleDomainLeavingParticles (unsigned dim, ParticleContainer *moleculeContainer) const
 
void handleDomainLeavingParticlesDirect (const HaloRegion &haloRegion, ParticleContainer *moleculeContainer, std::vector< Molecule > &invalidParticles) const
 
void handleForceExchange (unsigned dim, ParticleContainer *moleculeContainer) const
 Does the force exchange for each dimension. Will be called for dim=0, 1 and 2. More...
 
virtual void handleForceExchangeDirect (const HaloRegion &haloRegion, ParticleContainer *moleculeContainer) const
 
void populateHaloLayerWithCopies (unsigned dim, ParticleContainer *moleculeContainer) const
 
void populateHaloLayerWithCopiesDirect (const HaloRegion &haloRegion, ParticleContainer *moleculeContainer, bool positionCheck=true) const
 

Protected Attributes

MPI_Datatype _mpiParticleType
 
MPI_Datatype _mpiParticleForceType
 
MPI_Comm _comm
 
std::unique_ptr< NeighbourCommunicationScheme_neighbourCommunicationScheme
 
bool _forceDirectPP {false}
 
- Protected Attributes inherited from DomainDecompBase
int _rank
 the id of the current process
 
int _numProcs
 total number of processes in the simulation
 

Member Function Documentation

◆ assertDisjunctivity()

void DomainDecompMPIBase::assertDisjunctivity ( ParticleContainer moleculeContainer) const
overridevirtual
Todo:
FIXME: This implementation does not scale.

Reimplemented from DomainDecompBase.

◆ assertIntIdentity()

void DomainDecompMPIBase::assertIntIdentity ( int  IX)
virtual

checks identity of random number generators

Reimplemented from DomainDecompBase.

◆ balanceAndExchangeInitNonBlocking()

void DomainDecompMPIBase::balanceAndExchangeInitNonBlocking ( bool  forceRebalancing,
ParticleContainer moleculeContainer,
Domain domain 
)
virtual

Initialises the non-blocking balance and exchange. Nothing really important needs to be done here. Some ideas: decide between possible communication schemes,...

Parameters
forceRebalancingtrue if rebalancing should be forced
moleculeContainerpointer to the molecule container
domainpointer to the domain

◆ barrier()

void DomainDecompMPIBase::barrier ( ) const
inlineoverridevirtual

synchronizes all processes

Reimplemented from DomainDecompBase.

◆ collCommAllreduceCustom()

void DomainDecompMPIBase::collCommAllreduceCustom ( ReduceType  type)
inlineoverridevirtual

has to call allreduceCustom method of a CollComm class (none in sequential version)

Reimplemented from DomainDecompBase.

◆ collCommAllreduceSum()

void DomainDecompMPIBase::collCommAllreduceSum ( )
inlineoverridevirtual

has to call allreduceSum method of a CollComm class (none in sequential version)

Reimplemented from DomainDecompBase.

◆ collCommAllreduceSumAllowPrevious()

void DomainDecompMPIBase::collCommAllreduceSumAllowPrevious ( )
overridevirtual

has to call allreduceSum method of a CollComm class (none in sequential version), allows for values of previous iteration.

Reimplemented from DomainDecompBase.

◆ collCommAppendDouble()

void DomainDecompMPIBase::collCommAppendDouble ( double  doubleValue)
inlineoverridevirtual

has to call appendDouble method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommAppendFloat()

void DomainDecompMPIBase::collCommAppendFloat ( float  floatValue)
inlineoverridevirtual

has to call appendFloat method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommAppendInt()

void DomainDecompMPIBase::collCommAppendInt ( int  intValue)
inlineoverridevirtual

has to call appendInt method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommAppendLongDouble()

void DomainDecompMPIBase::collCommAppendLongDouble ( long double  longDoubleValue)
inlineoverridevirtual

has to call appendLongDouble method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommAppendUnsLong()

void DomainDecompMPIBase::collCommAppendUnsLong ( unsigned long  unsLongValue)
inlineoverridevirtual

has to call appendUnsLong method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommBroadcast()

void DomainDecompMPIBase::collCommBroadcast ( int  root = 0)
inlineoverridevirtual

has to call broadcast method of a CollComm class (none in sequential version)

Reimplemented from DomainDecompBase.

◆ collCommFinalize()

void DomainDecompMPIBase::collCommFinalize ( )
inlineoverridevirtual

has to call finalize method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommGetDouble()

double DomainDecompMPIBase::collCommGetDouble ( )
inlineoverridevirtual

has to call getDouble method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommGetFloat()

float DomainDecompMPIBase::collCommGetFloat ( )
inlineoverridevirtual

has to call getFloat method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommGetInt()

int DomainDecompMPIBase::collCommGetInt ( )
inlineoverridevirtual

has to call getInt method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommGetLongDouble()

long double DomainDecompMPIBase::collCommGetLongDouble ( )
inlineoverridevirtual

has to call getLongDouble method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommGetUnsLong()

unsigned long DomainDecompMPIBase::collCommGetUnsLong ( )
inlineoverridevirtual

has to call getUnsLong method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommInit()

void DomainDecompMPIBase::collCommInit ( int  numValues,
int  key = 0 
)
inlineoverridevirtual

has to call init method of a CollComm class

Reimplemented from DomainDecompBase.

◆ collCommScanSum()

void DomainDecompMPIBase::collCommScanSum ( )
inlineoverridevirtual

has to call scanSum method of a CollComm class (none in sequential version)

Reimplemented from DomainDecompBase.

◆ exchangeForces()

void DomainDecompMPIBase::exchangeForces ( ParticleContainer moleculeContainer,
Domain domain 
)
overridevirtual

Exchanges forces at the domain boundaries if it's required by the cell container.

Parameters
moleculeContainerThe particle container
domain

Reimplemented from DomainDecompBase.

◆ exchangeMoleculesMPI()

void DomainDecompMPIBase::exchangeMoleculesMPI ( ParticleContainer moleculeContainer,
Domain domain,
MessageType  msgType,
bool  doHaloPositionCheck = true,
bool  removeRecvDuplicates = false 
)

exchange molecules between processes

molecules which aren't in the domain of their process any more are transferred to their neighbours. Additionally, the molecules for the halo-region are transferred. To reduce the number of neighbours a single process has to communicate with, particles that i.e. have to be moved to the lower right neighbour are moved to the right neighbour first and then from the right neighbour to the lower neighbour.

Parameters
moleculeContainerneeded to get those molecules which have to be exchanged
domainis e.g. needed to get the size of the local domain

◆ finishNonBlockingStage()

virtual void DomainDecompMPIBase::finishNonBlockingStage ( bool  forceRebalancing,
ParticleContainer moleculeContainer,
Domain domain,
unsigned int  stageNumber 
)
pure virtual

Finishes the stageNumber'th stage. This includes receiving the particles, that have to be received in that stage.

Parameters
forceRebalancingtrue if rebalancing should be forced
moleculeContainerpointer to the molecule container
domainpointer to the domain
stageNumberthe number of the stage, the communication is in.

Implemented in DomainDecomposition, GeneralDomainDecomposition, and KDDecomposition.

◆ finishNonBlockingStageImpl()

void DomainDecompMPIBase::finishNonBlockingStageImpl ( ParticleContainer moleculeContainer,
Domain domain,
unsigned int  stageNumber,
MessageType  msgType,
bool  removeRecvDuplicates = false 
)
protectedvirtual

Finishes the stageNumber'th stage. This includes receiving the particles, that have to be received in that stage.

Parameters
forceRebalancingtrue if rebalancing should be forced
moleculeContainerpointer to the molecule container
domainpointer to the domain
stageNumberthe number of the stage, the communication is in.

◆ getCommunicator()

MPI_Comm DomainDecompMPIBase::getCommunicator ( )
inlineoverridevirtual

Reimplemented from DomainDecompBase.

◆ getName()

virtual std::string DomainDecompMPIBase::getName ( )
inlineoverridevirtual

Reimplemented from DomainDecompBase.

◆ getNeighbourRanks()

std::vector<int> DomainDecompMPIBase::getNeighbourRanks ( )
overridepure virtual

Reimplemented from DomainDecompBase.

◆ getNeighbourRanksFullShell()

std::vector<int> DomainDecompMPIBase::getNeighbourRanksFullShell ( )
overridepure virtual

Reimplemented from DomainDecompBase.

Implemented in DomainDecomposition.

◆ getNonBlockingStageCount()

int DomainDecompMPIBase::getNonBlockingStageCount ( )
overridevirtual

Specifies the amount of non-blocking stages, when performing overlapping balanceAndExchange and computation. For a communication scheme, where only direct neighbours communicate, 3 stages of communication are necessary, since the particles have to be transmitted in the x-direction first, then in the y-direction, then in the z-direction.

Returns
The amount of communication stages. Returns -1 if it is not possible.

Reimplemented from DomainDecompBase.

◆ getTotalSize()

size_t DomainDecompMPIBase::getTotalSize ( )
overridevirtual

Reimplemented from DomainDecompBase.

◆ Ndistribution()

unsigned DomainDecompMPIBase::Ndistribution ( unsigned  localN,
float *  minrnd,
float *  maxrnd 
)
virtual

returns total number of molecules

Reimplemented from DomainDecompBase.

◆ prepareNonBlockingStage()

virtual void DomainDecompMPIBase::prepareNonBlockingStage ( bool  forceRebalancing,
ParticleContainer moleculeContainer,
Domain domain,
unsigned int  stageNumber 
)
pure virtual

Prepares the stageNumber'th stage. This includes sending particles, that have to be send in that stage.

Parameters
forceRebalancingtrue if rebalancing should be forced
moleculeContainerpointer to the molecule container
domainpointer to the domain
stageNumberthe number of the stage, the communication is in.

Implemented in DomainDecomposition, GeneralDomainDecomposition, and KDDecomposition.

◆ prepareNonBlockingStageImpl()

void DomainDecompMPIBase::prepareNonBlockingStageImpl ( ParticleContainer moleculeContainer,
Domain domain,
unsigned int  stageNumber,
MessageType  msgType,
bool  removeRecvDuplicates = false 
)
protectedvirtual

Prepares the stageNumber'th stage. This includes sending particles, that have to be send in that stage.

Parameters
moleculeContainerpointer to the molecule container
domainpointer to the domain
stageNumberthe number of the stage, the communication is in.

◆ printCommunicationPartners()

void DomainDecompMPIBase::printCommunicationPartners ( std::string  filename) const
overridevirtual

Reimplemented from DomainDecompBase.

◆ printDecomp()

void DomainDecompMPIBase::printDecomp ( const std::string &  filename,
Domain domain,
ParticleContainer particleContainer 
)
overridevirtual

writes information about the current decomposition into the given file

Parameters
filenamename of the file into which the data will be written
domaine.g. needed to get the bounding boxes
particleContainerneeded to print information about the parts of the decomposition

Reimplemented from DomainDecompBase.

◆ printSubInfo()

void DomainDecompMPIBase::printSubInfo ( int  offset)
overridevirtual

Reimplemented from DomainDecompBase.

◆ readXML()

void DomainDecompMPIBase::readXML ( XMLfileUnits xmlconfig)
virtual

Read in XML configuration for DomainDecompMPIBase.

The following xml object structure is handled by this method:

<parallelisation type="DomainDecomposition" OR "KDDecomposition">
<!--default: indirect, unless in autopas mode-->
<CommunicationScheme>indirect OR direct OR direct-pp</CommunicationScheme>
<!--default: no-->
<overlappingCollectives>yes OR no</overlappingCollectives>
<!--default: 5-->
<overlappingStartAtStep></overlappingStartAtStep>
<!--default: yes-->
<useSequentialFallback>yes OR no</useSequentialFallback>
<!-- structure handled by DomainDecomposition or KDDecomposition -->
</parallelisation>

Reimplemented from DomainDecompBase.

Reimplemented in DomainDecomposition, GeneralDomainDecomposition, and KDDecomposition.

◆ setCommunicationScheme()

void DomainDecompMPIBase::setCommunicationScheme ( const std::string &  scheme,
const std::string &  comScheme 
)
virtual

Sets the communicationScheme.

Note
If this function is called dynamically, make sure to reinitialise the CommunicationPartners before exchanging molecules!
Parameters
scheme
comScheme

Member Data Documentation

◆ _forceDirectPP

bool DomainDecompMPIBase::_forceDirectPP {false}
protected

Indicates whether the direct-pp communication scheme should be forced. Flag to indicate necessity to use the direct-pp neighbour communication scheme. Can be overwritten by any child class.

Note
Intended to be used in readXML().

The documentation for this class was generated from the following files: