CoMD
A Mini-app for Co-Design of Classical Molecular Dynamics.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
haloExchange.h File Reference

Communicate halo data such as "ghost" atoms with neighboring tasks. More...

#include "mytype.h"
Include dependency graph for haloExchange.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  HaloExchangeSt
 A polymorphic structure to store information about a halo exchange. More...
 

Typedefs

typedef struct HaloExchangeSt HaloExchange
 A polymorphic structure to store information about a halo exchange. More...
 

Functions

HaloExchangeinitAtomHaloExchange (struct DomainSt *domain, struct LinkCellSt *boxes)
 Create a HaloExchange for atom data. More...
 
HaloExchangeinitForceHaloExchange (struct DomainSt *domain, struct LinkCellSt *boxes)
 Create a HaloExchange for force data. More...
 
void destroyHaloExchange (HaloExchange **haloExchange)
 HaloExchange destructor. More...
 
void haloExchange (HaloExchange *haloExchange, void *data)
 Execute a halo exchange. More...
 
void sortAtomsInCell (struct AtomsSt *atoms, struct LinkCellSt *boxes, int iBox)
 Sort the atoms by gid in the specified link cell. More...
 

Detailed Description

Communicate halo data such as "ghost" atoms with neighboring tasks.

Definition in file haloExchange.h.

Typedef Documentation

typedef struct HaloExchangeSt HaloExchange

A polymorphic structure to store information about a halo exchange.

This structure can be thought of as an abstract base class that specifies the interface and implements the communication patterns of a halo exchange. Concrete sub-classes supply actual implementations of the loadBuffer, unloadBuffer, and destroy functions, that are specific to the actual data being exchanged. If the subclass needs additional data members, these can be stored in a structure that is pointed to by parms.

Designing the structure this way allows us to re-use the communication code for both atom data and partial force data.

See Also
eamForce
redistributeAtoms

Function Documentation

void destroyHaloExchange ( HaloExchange **  haloExchange)

HaloExchange destructor.

Definition at line 239 of file haloExchange.c.

Here is the caller graph for this function:

void haloExchange ( HaloExchange haloExchange,
void *  data 
)

Execute a halo exchange.

Definition at line 246 of file haloExchange.c.

Here is the call graph for this function:

Here is the caller graph for this function:

HaloExchange* initAtomHaloExchange ( Domain domain,
LinkCell boxes 
)

Create a HaloExchange for atom data.

When called in proper sequence by redistributeAtoms, the atom halo exchange helps serve three purposes:

  • Send ghost atom data to neighbor tasks.
  • Shift atom coordinates by the global simulation size when they cross periodic boundaries. This shift is performed in loadAtomsBuffer.
  • Transfer ownership of atoms between tasks as the atoms move across spatial domain boundaries. This transfer of ownership occurs in two places. The former owner gives up ownership when updateLinkCells moves a formerly local atom into a halo link cell. The new owner accepts ownership when unloadAtomsBuffer calls putAtomInBox to place a received atom into a local link cell.

This constructor does the following:

  • Sets the bufCapacity to hold the largest possible number of atoms that can be sent across a face.
  • Initialize function pointers to the atom-specific versions
  • Sets the number of link cells to send across each face.
  • Builds the list of link cells to send across each face. As explained in the comments for mkAtomCellList, this list must include any link cell, local or halo, that could possibly contain an atom that needs to be sent across the face. Atoms that need to be sent include "ghost atoms" that are located in local link cells that correspond to halo link cells on receiving tasks as well as formerly local atoms that have just moved into halo link cells and need to be sent to the rank that owns the spatial domain the atom has moved into.
  • Sets a coordinate shift factor for each face to account for periodic boundary conditions. For most faces the factor is zero. For faces on the +x, +y, or +z face of the simulation domain the factor is -1.0 (to shift the coordinates by -1 times the simulation domain size). For -x, -y, and -z faces of the simulation domain, the factor is +1.0.
See Also
redistributeAtoms

Definition at line 144 of file haloExchange.c.

Here is the call graph for this function:

Here is the caller graph for this function:

HaloExchange* initForceHaloExchange ( Domain domain,
LinkCell boxes 
)

Create a HaloExchange for force data.

Create a HaloExchange for force data.

In the force case we only need to exchange data that is needed to complete the force calculation. Since the atoms have not moved we only need to send data from local link cells and we are guaranteed that the same atoms exist in the same order in corresponding halo cells on remote tasks. The only tricky part is the size of the plane of local cells that needs to be sent grows in each direction. This is because the y-axis send must send some of the data that was received from the x-axis send, and the z-axis must send some data from the y-axis send. This accumulation of data to send is responsible for data reaching neighbor cells that share only edges or corners.

See Also
eam.c for an explanation of the requirement to exchange force data.

Definition at line 205 of file haloExchange.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void sortAtomsInCell ( Atoms atoms,
LinkCell boxes,
int  iBox 
)

Sort the atoms by gid in the specified link cell.

The force exchange assumes that the atoms are in the same order in both a given local link cell and the corresponding remote cell(s). However, the atom exchange does not guarantee this property, especially when atoms cross a domain decomposition boundary and move from one task to another. Trying to maintain the atom order during the atom exchange would immensely complicate that code. Instead, we just sort the atoms after the atom exchange.

Definition at line 612 of file haloExchange.c.

Here is the call graph for this function:

Here is the caller graph for this function: