Simpatico  v1.10
List of all members | Public Types | Public Member Functions
DdMd::Buffer Class Reference

Detailed Description

Buffer for interprocessor communication.

A Buffer manages two blocks of raw memory, a send buffer and a receive buffer, that are used to communicate data between processors. The class provides a simple interace for:

The functions that send, receive and broadcast data are relatively simple wrappers around MPI functions.

The send and receive buffers contain one or more blocks of data. Each block contains a prefix and data segment. The data segment contains a sequence of items of the same data type. The prefix contains information about the data segment, including the length of the buffer, the number of items, and the type of data.

Data types

Different possible types of data are enumerated by the public enum Buffer::BlockDataType. The allowed values of this enum are:

The standard ATOM, GHOST, UPDATE, FORCE, and GROUP(2,3,4) types are used in the implementation of the Exchanger class.

The DdMd::Atom class and DdMd::Group class template provide provide member functions to pack and unpack individual items of standard types (atoms and groups). The pack and unpack functions in these classes each take a Buffer by reference as an argument. They are implemented using the primitive Buffer::pack<T>() and Buffer::unpack<T>() member function templates of the Buffer class, which a user to pack and unpack a single C variable of type T to or from a Buffer.

The SPECIAL BlockDataType value is a generic label for any specialized, non-standard data type. Code that uses an Buffer to communicate a specialized data type should provide functions to pack and unpack individual items of the required type. Like the pack and unpack functions for atoms and groups, these functions should be implemented using the Buffer::pack() and Buffer::unpack() function templates.

Packing a block of data

Example - packing a block of Group<2> objects:

Buffer buffer;
DArray< Group<2> > bonds;
// Clear buffer before packing
buffer.clear();
// Pack data block
buffer.beginSendBlock(Buffer::GROUP2);
for (i = 0; i < bonds.size(); ++i) {
bonds[i].pack(buffer);
buffer.incrementSendSize();
}
bool isComplete = true;
// Pack subsequent blocks, if any.
buffer.send(communicator, destination);

Note:

Unpacking a block of data

Example - unpacking a block of Group<2> objects:

Buffer buffer;
DArray< Group<2> > bonds;
MPI::Intracomm communicator;
int source;
// Receive the buffer
buffer.recv(communicator, source);
// Unpack a data block
bool isComplete;
int i = 0;
isComplete = buffer.beginRecvBlock();
while (buffer.recvSize()) {
bonds[i].unpack(buffer);
buffer.decrementRecvSize();
++i;
}
// Subsequent blocks, if any

Note:

Sending a block in several messages

The above examples shows a simple case of packing and unpacking a complete block without any explicit checking of whether the message will fit in the buffer on the source processor or checking of the isComplete flag on the destination. Code that needs to send blocks that may exceed the buffer size can use the isComplete flag to break the a block of data into in several messages, by setting isComplete false in all but the last message of the sequence.

Here is an example of the code to receive an array of data that may have been split into several messages:

Buffer buffer;
DArray< Group<2> > bonds;
MPI::Intracomm communicator;
int source;
int i = 0;
bool isComplete = false;
while (!isComplete) {
buffer.recv(communicator, source);
isComplete = buffer.beginRecvBlock();
while (buffer.recvSize()) {
bonds[i].unpack(buffer);
buffer.decrementRecvSize();
++i;
}
}

The code required to avoid overfilling the send buffer on the source processor (not shown), requires knowledge of the packed size of one object. This is provided for Atom and Group objects by the Atom::packedAtomSize(), Atom::packedGhostSize() and Group::packedSize() static functions.

This idiom for dividing large blocks is used in the implementation of all the DdMd Distributor and Collector classes (AtomDistributor, AtomCollector, GroupDistributor and GroupCollector).

Definition at line 217 of file Buffer.h.

#include <Buffer.h>

Inheritance diagram for DdMd::Buffer:
Util::ParamComposite Util::ParamComponent Util::Serializable Util::MpiFileIo

Public Types

- Public Types inherited from Util::Serializable
typedef BinaryFileOArchive OArchive
 Type of output archive used by save method. More...
 
typedef BinaryFileIArchive IArchive
 Type of input archive used by load method. More...
 

Public Member Functions

 Buffer ()
 Constructor. More...
 
virtual ~Buffer ()
 Destructor. More...
 
void readParameters (std::istream &in)
 Read capacity and allocate buffers. More...
 
virtual void loadParameters (Serializable::IArchive &ar)
 Load internal state from an archive. More...
 
virtual void save (Serializable::OArchive &ar)
 Save internal state to an archive. More...
 
void allocate (int atomCapacity, int ghostCapacity)
 Allocate send and recv buffers. More...
 
Send Buffer Management
void clearSendBuffer ()
 Clear the send buffer. More...
 
void beginSendBlock (int sendType)
 Initialize a data block. More...
 
template<typename T >
void pack (const T &data)
 Function template for packing one variable into the send buffer. More...
 
void incrementSendSize ()
 Increment sendSize counter after packing an item (an Atom or Group). More...
 
void endSendBlock (bool isComplete=true)
 Finalize a block in the send buffer. More...
 
Receive Buffer Management
bool beginRecvBlock ()
 Begin to receive a block from the recv buffer. More...
 
template<typename T >
void unpack (T &data)
 Function template unpacking one variable from the receive buffer. More...
 
void decrementRecvSize ()
 Decrement recvSize counter after completely unpacking an item. More...
 
void endRecvBlock ()
 Finish processing a block in the recv buffer. More...
 
Interprocessor Communication
void sendRecv (MPI::Intracomm &comm, int source, int dest)
 Receive from processor send and send to processor recv. More...
 
void send (MPI::Intracomm &comm, int dest)
 Send a complete buffer. More...
 
void recv (MPI::Intracomm &comm, int source)
 Receive a buffer. More...
 
void bcast (MPI::Intracomm &comm, int source)
 Broadcast a buffer. More...
 
Statistics
virtual void computeStatistics (MPI::Intracomm &comm)
 Compute statistics (reduce from all processors). More...
 
void outputStatistics (std::ostream &out)
 Output statistics. More...
 
void clearStatistics ()
 Clear any accumulated usage statistics. More...
 
Accessors
int sendSize () const
 Number of items in current send block. More...
 
int recvSize () const
 Number of unread items left in current recv block. More...
 
bool isAllocated () const
 Has memory been allocated for this Buffer? More...
 
bool isInitialized () const
 Has this Buffer been initialized? More...
 
int atomCapacity () const
 Maximum number of atoms for which space is available. More...
 
int ghostCapacity () const
 Maximum number of ghost atoms for which space is available. More...
 
template<int N>
int groupCapacity () const
 Maximum number of group<N> objects for which space is available. More...
 
- Public Member Functions inherited from Util::ParamComposite
 ParamComposite ()
 Constructor. More...
 
 ParamComposite (const ParamComposite &other)
 Copy constructor. More...
 
 ParamComposite (int capacity)
 Constructor. More...
 
virtual ~ParamComposite ()
 Virtual destructor. More...
 
void resetParam ()
 Resets ParamComposite to its empty state. More...
 
virtual void readParam (std::istream &in)
 Read the parameter file block. More...
 
virtual void readParamOptional (std::istream &in)
 Read optional parameter file block. More...
 
virtual void writeParam (std::ostream &out)
 Write all parameters to an output stream. More...
 
virtual void load (Serializable::IArchive &ar)
 Load all parameters from an input archive. More...
 
virtual void loadOptional (Serializable::IArchive &ar)
 Load an optional ParamComposite. More...
 
void saveOptional (Serializable::OArchive &ar)
 Saves isActive flag, and then calls save() iff isActive is true. More...
 
void readParamComposite (std::istream &in, ParamComposite &child, bool next=true)
 Add and read a required child ParamComposite. More...
 
void readParamCompositeOptional (std::istream &in, ParamComposite &child, bool next=true)
 Add and attempt to read an optional child ParamComposite. More...
 
template<typename Type >
ScalarParam< Type > & read (std::istream &in, const char *label, Type &value)
 Add and read a new required ScalarParam < Type > object. More...
 
template<typename Type >
ScalarParam< Type > & readOptional (std::istream &in, const char *label, Type &value)
 Add and read a new optional ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & readCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read a required C array parameter. More...
 
template<typename Type >
CArrayParam< Type > & readOptionalCArray (std::istream &in, const char *label, Type *value, int n)
 Add and read an optional C array parameter. More...
 
template<typename Type >
DArrayParam< Type > & readDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read a required DArray < Type > parameter. More...
 
template<typename Type >
DArrayParam< Type > & readOptionalDArray (std::istream &in, const char *label, DArray< Type > &array, int n)
 Add and read an optional DArray < Type > parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & readFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read a required FArray < Type, N > array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & readOptionalFArray (std::istream &in, const char *label, FArray< Type, N > &array)
 Add and read an optional FArray < Type, N > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & readCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read a required CArray2DParam < Type > 2D C-array. More...
 
template<typename Type >
CArray2DParam< Type > & readOptionalCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np)
 Add and read an optional CArray2DParam < Type > 2D C-array parameter. More...
 
template<typename Type >
DMatrixParam< Type > & readDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read a required DMatrix < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & readOptionalDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and read an optional DMatrix < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & readDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read a required symmetrix DMatrix. More...
 
template<typename Type >
DSymmMatrixParam< Type > & readOptionalDSymmMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int n)
 Add and read an optional DMatrix matrix parameter. More...
 
BeginreadBegin (std::istream &in, const char *label, bool isRequired=true)
 Add and read a class label and opening bracket. More...
 
EndreadEnd (std::istream &in)
 Add and read the closing bracket. More...
 
BlankreadBlank (std::istream &in)
 Add and read a new Blank object, representing a blank line. More...
 
void loadParamComposite (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load a required child ParamComposite. More...
 
void loadParamCompositeOptional (Serializable::IArchive &ar, ParamComposite &child, bool next=true)
 Add and load an optional child ParamComposite if isActive. More...
 
template<typename Type >
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value, bool isRequired)
 Add and load a new ScalarParam < Type > object. More...
 
template<typename Type >
ScalarParam< Type > & loadParameter (Serializable::IArchive &ar, const char *label, Type &value)
 Add and load new required ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n, bool isRequired)
 Add a C array parameter and load its elements. More...
 
template<typename Type >
CArrayParam< Type > & loadCArray (Serializable::IArchive &ar, const char *label, Type *value, int n)
 Add and load a required CArrayParam< Type > array parameter. More...
 
template<typename Type >
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n, bool isRequired)
 Add an load a DArray < Type > array parameter. More...
 
template<typename Type >
DArrayParam< Type > & loadDArray (Serializable::IArchive &ar, const char *label, DArray< Type > &array, int n)
 Add and load a required DArray< Type > array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array, bool isRequired)
 Add and load an FArray < Type, N > fixed-size array parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & loadFArray (Serializable::IArchive &ar, const char *label, FArray< Type, N > &array)
 Add and load a required FArray < Type > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np, bool isRequired)
 Add and load a CArray2DParam < Type > C 2D array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & loadCArray2D (Serializable::IArchive &ar, const char *label, Type *value, int m, int n, int np)
 Add and load a required < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired)
 Add and load a DMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DMatrixParam< Type > & loadDMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int m, int n)
 Add and load a required DMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n, bool isRequired)
 Add and load a symmetric DSymmMatrixParam < Type > matrix parameter. More...
 
template<typename Type >
DSymmMatrixParam< Type > & loadDSymmMatrix (Serializable::IArchive &ar, const char *label, DMatrix< Type > &matrix, int n)
 Add and load a required DSymmMatrixParam < Type > matrix parameter. More...
 
void addParamComposite (ParamComposite &child, bool next=true)
 Add a child ParamComposite object to the format array. More...
 
BeginaddBegin (const char *label)
 Add a Begin object representing a class name and bracket. More...
 
EndaddEnd ()
 Add a closing bracket. More...
 
BlankaddBlank ()
 Create and add a new Blank object, representing a blank line. More...
 
std::string className () const
 Get class name string. More...
 
bool isRequired () const
 Is this ParamComposite required in the input file? More...
 
bool isActive () const
 Is this parameter active? More...
 
- Public Member Functions inherited from Util::ParamComponent
virtual ~ParamComponent ()
 Destructor. More...
 
void setIndent (const ParamComponent &parent, bool next=true)
 Set indent level. More...
 
std::string indent () const
 Return indent string for this object (string of spaces). More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 Serialize this ParamComponent as a string. More...
 
- Public Member Functions inherited from Util::Serializable
virtual ~Serializable ()
 Destructor. More...
 
- Public Member Functions inherited from Util::MpiFileIo
 MpiFileIo ()
 Constructor. More...
 
 MpiFileIo (const MpiFileIo &other)
 Copy constructor. More...
 
bool isIoProcessor () const
 Can this processor do file I/O ? More...
 
void setIoCommunicator (MPI::Intracomm &communicator)
 Set the communicator. More...
 
void clearCommunicator ()
 Clear (nullify) the communicator. More...
 
bool hasIoCommunicator () const
 Does this object have an associated MPI communicator? More...
 
MPI::Intracomm & ioCommunicator () const
 Get the MPI communicator by reference. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Util::ParamComponent
static void initStatic ()
 Initialize static echo member to false. More...
 
static void setEcho (bool echo=true)
 Enable or disable echoing for all subclasses of ParamComponent. More...
 
static bool echo ()
 Get echo parameter. More...
 
- Protected Member Functions inherited from Util::ParamComposite
void setClassName (const char *className)
 Set class name string. More...
 
void setIsRequired (bool isRequired)
 Set or unset the isActive flag. More...
 
void setIsActive (bool isActive)
 Set or unset the isActive flag. More...
 
void setParent (ParamComponent &param, bool next=true)
 Set this to the parent of a child component. More...
 
void addComponent (ParamComponent &param, bool isLeaf=true)
 Add a new ParamComponent object to the format array. More...
 
template<typename Type >
ScalarParam< Type > & add (std::istream &in, const char *label, Type &value, bool isRequired=true)
 Add a new required ScalarParam < Type > object. More...
 
template<typename Type >
CArrayParam< Type > & addCArray (std::istream &in, const char *label, Type *value, int n, bool isRequired=true)
 Add (but do not read) a required C array parameter. More...
 
template<typename Type >
DArrayParam< Type > & addDArray (std::istream &in, const char *label, DArray< Type > &array, int n, bool isRequired=true)
 Add (but do not read) a DArray < Type > parameter. More...
 
template<typename Type , int N>
FArrayParam< Type, N > & addFArray (std::istream &in, const char *label, FArray< Type, N > &array, bool isRequired=true)
 Add (but do not read) a FArray < Type, N > array parameter. More...
 
template<typename Type >
CArray2DParam< Type > & addCArray2D (std::istream &in, const char *label, Type *value, int m, int n, int np, bool isRequired=true)
 Add (but do not read) a CArray2DParam < Type > 2D C-array. More...
 
template<typename Type >
DMatrixParam< Type > & addDMatrix (std::istream &in, const char *label, DMatrix< Type > &matrix, int m, int n, bool isRequired=true)
 Add and read a required DMatrix < Type > matrix parameter. More...
 
- Protected Member Functions inherited from Util::ParamComponent
 ParamComponent ()
 Constructor. More...
 
 ParamComponent (const ParamComponent &other)
 Copy constructor. More...
 

Member Enumeration Documentation

Enumeration of types of data to be sent in blocks.

Definition at line 225 of file Buffer.h.

Constructor & Destructor Documentation

DdMd::Buffer::Buffer ( )

Constructor.

Definition at line 22 of file Buffer.cpp.

References Util::ParamComposite::setClassName().

DdMd::Buffer::~Buffer ( )
virtual

Destructor.

Definition at line 49 of file Buffer.cpp.

Member Function Documentation

void DdMd::Buffer::readParameters ( std::istream &  in)
virtual

Read capacity and allocate buffers.

Parameters
ininput parameter stream

Reimplemented from Util::ParamComposite.

Definition at line 86 of file Buffer.cpp.

References allocate(), and UTIL_THROW.

void DdMd::Buffer::loadParameters ( Serializable::IArchive ar)
virtual

Load internal state from an archive.

Parameters
arinput/loading archive

Reimplemented from Util::ParamComposite.

Definition at line 112 of file Buffer.cpp.

References allocate(), and UTIL_THROW.

void DdMd::Buffer::save ( Serializable::OArchive ar)
virtual

Save internal state to an archive.

Parameters
aroutput/saving archive

Reimplemented from Util::ParamComposite.

Definition at line 137 of file Buffer.cpp.

void DdMd::Buffer::allocate ( int  atomCapacity,
int  ghostCapacity 
)

Allocate send and recv buffers.

Calculate amounts of memory required to accommodate specified number of local atoms (atomCapacity), or the specified number of ghosts (ghostCapacity), and allocate send and receive buffers large enough to hold the larger value.

Parameters
atomCapacitymax expected number of local atoms.
ghostCapacitymax expected number of ghost atoms.

Definition at line 62 of file Buffer.cpp.

References allocate(), atomCapacity(), ghostCapacity(), and UTIL_THROW.

Referenced by allocate(), loadParameters(), and readParameters().

void DdMd::Buffer::clearSendBuffer ( )
void DdMd::Buffer::beginSendBlock ( int  sendType)
template<typename T >
void DdMd::Buffer::pack ( const T &  data)
inline

Function template for packing one variable into the send buffer.

This template is used to implement the pack functions provided by the DdMd::Atom and DdMd::Group classes. It is designed to pack a single primitive C variable into the send buffer. It will also work on any plain old data type T for which assignment (=) does a straight bitwise copy.

Parameters
datavariable to be packed into the send buffer.

Definition at line 563 of file Buffer.h.

References UTIL_THROW.

Referenced by DdMd::Group< N >::pack(), DdMd::Atom::packAtom(), DdMd::Atom::packForce(), DdMd::Atom::packGhost(), and DdMd::Atom::packUpdate().

void DdMd::Buffer::incrementSendSize ( )
inline

Increment sendSize counter after packing an item (an Atom or Group).

Definition at line 604 of file Buffer.h.

Referenced by DdMd::Group< N >::pack(), DdMd::Atom::packAtom(), DdMd::Atom::packForce(), DdMd::Atom::packGhost(), and DdMd::Atom::packUpdate().

void DdMd::Buffer::endSendBlock ( bool  isComplete = true)

Finalize a block in the send buffer.

This method writes the "prefix" section at the beginning of a data block. The descriptor specifies the length of the block, the type of data, and whether the block is "complete".

A block should be marked as incomplete iff the required data of the relevant sendtype did not fit into the buffer. This tells the receiving processor to expect one or more other buffers containing the remaining data of the same type type.

Parameters
isCompletefalse if data block is incomplete, true otherwise

Definition at line 247 of file Buffer.cpp.

Referenced by DdMd::AtomDistributor::addAtom(), DdMd::Exchanger::exchange(), DdMd::AtomDistributor::newAtomPtr(), DdMd::GroupDistributor< N >::newPtr(), DdMd::GroupStorage< N >::pack(), DdMd::Exchanger::reverseUpdate(), DdMd::AtomCollector::send(), DdMd::GroupCollector< N >::send(), DdMd::GroupDistributor< N >::send(), DdMd::AtomDistributor::send(), and DdMd::Exchanger::update().

bool DdMd::Buffer::beginRecvBlock ( )

Begin to receive a block from the recv buffer.

This method reads the descriptor section at the beginning of a block, and sets the receive cursor to be ready to unpack the first item.

Returns
false if this block is complete, false otherwise.

Definition at line 271 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::Exchanger::exchange(), DdMd::AtomCollector::nextPtr(), DdMd::GroupCollector< N >::nextPtr(), DdMd::GroupDistributor< N >::receive(), DdMd::AtomDistributor::receive(), DdMd::Exchanger::reverseUpdate(), DdMd::GroupStorage< N >::unpack(), and DdMd::Exchanger::update().

template<typename T >
void DdMd::Buffer::unpack ( T &  data)
inline

Function template unpacking one variable from the receive buffer.

This template is used to implement the unpack functions provided by the DdMd::Atom and DdMd::Group classes. It is designed to unpack a single primitive C variable from the buffer. It will work on any plain old data type T for which the assignment (=) operator does a straight bitwise copy.

Parameters
datavariable into which data should be copied from buffer.

Definition at line 578 of file Buffer.h.

References UTIL_THROW.

Referenced by DdMd::Group< N >::unpack(), DdMd::Atom::unpackAtom(), DdMd::Atom::unpackForce(), DdMd::Atom::unpackGhost(), and DdMd::Atom::unpackUpdate().

void DdMd::Buffer::decrementRecvSize ( )
inline

Decrement recvSize counter after completely unpacking an item.

Definition at line 610 of file Buffer.h.

Referenced by DdMd::Group< N >::unpack(), DdMd::Atom::unpackAtom(), DdMd::Atom::unpackForce(), DdMd::Atom::unpackGhost(), and DdMd::Atom::unpackUpdate().

void DdMd::Buffer::endRecvBlock ( )

Finish processing a block in the recv buffer.

This method checks that the recvSize() is zero at the end of a block, and that the receive buffer cursor is at the expected positon, and throws an exception if any suprises occur. It also nullifies the recvSize counter.

Definition at line 301 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::Exchanger::exchange(), DdMd::AtomCollector::nextPtr(), DdMd::AtomDistributor::receive(), DdMd::Exchanger::reverseUpdate(), DdMd::GroupStorage< N >::unpack(), and DdMd::Exchanger::update().

void DdMd::Buffer::sendRecv ( MPI::Intracomm &  comm,
int  source,
int  dest 
)

Receive from processor send and send to processor recv.

After transmission, clears the send buffer for reuse, by calling clearSend(), and sets the receive buffer for unpacking, by setting recvSize() to the total number of atoms recieved and setting the receive pointer to first atom to be unpacked.

Throws an Exception if atomType() == NONE or sendSize() == 0.

Parameters
commMPI communicator object
sourceMPI rank of processor from which data is sent
destMPI rank of processor to which data is sent

Definition at line 319 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::Exchanger::exchange(), DdMd::Exchanger::reverseUpdate(), and DdMd::Exchanger::update().

void DdMd::Buffer::send ( MPI::Intracomm &  comm,
int  dest 
)

Send a complete buffer.

Upon sending buffer, clears the send buffer for reuse by calling clearSend().

Parameters
commMPI communicator
destrank of processor to which data is sent

Definition at line 365 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::AtomDistributor::addAtom(), DdMd::AtomDistributor::newAtomPtr(), DdMd::AtomCollector::send(), DdMd::GroupCollector< N >::send(), and DdMd::AtomDistributor::send().

void DdMd::Buffer::recv ( MPI::Intracomm &  comm,
int  source 
)

Receive a buffer.

Parameters
commMPI communicator
sourcerank of processor from which data is sent.

Definition at line 393 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::AtomCollector::nextPtr(), DdMd::GroupCollector< N >::nextPtr(), and DdMd::AtomDistributor::receive().

void DdMd::Buffer::bcast ( MPI::Intracomm &  comm,
int  source 
)

Broadcast a buffer.

Parameters
commMPI communicator.
sourcerank of source processor.

Definition at line 417 of file Buffer.cpp.

References UTIL_THROW.

Referenced by DdMd::GroupDistributor< N >::newPtr(), DdMd::GroupDistributor< N >::receive(), and DdMd::GroupDistributor< N >::send().

void DdMd::Buffer::computeStatistics ( MPI::Intracomm &  comm)
virtual

Compute statistics (reduce from all processors).

Call on all processors.

Parameters
commMPI communicator

Definition at line 449 of file Buffer.cpp.

References Util::Setable< T >::set().

void DdMd::Buffer::outputStatistics ( std::ostream &  out)

Output statistics.

Call this on master, after calling computeStatistics on all processors.

Parameters
outoutput stream

Definition at line 475 of file Buffer.cpp.

References Util::Setable< T >::value().

void DdMd::Buffer::clearStatistics ( )

Clear any accumulated usage statistics.

Definition at line 466 of file Buffer.cpp.

References Util::Setable< T >::unset().

Referenced by DdMd::Integrator::clear().

int DdMd::Buffer::sendSize ( ) const

Number of items in current send block.

Definition at line 489 of file Buffer.cpp.

int DdMd::Buffer::recvSize ( ) const
bool DdMd::Buffer::isAllocated ( ) const

Has memory been allocated for this Buffer?

Definition at line 501 of file Buffer.cpp.

Referenced by isInitialized().

bool DdMd::Buffer::isInitialized ( ) const
int DdMd::Buffer::atomCapacity ( ) const

Maximum number of atoms for which space is available.

Definition at line 146 of file Buffer.cpp.

Referenced by allocate(), and DdMd::AtomDistributor::readParameters().

int DdMd::Buffer::ghostCapacity ( ) const

Maximum number of ghost atoms for which space is available.

Definition at line 152 of file Buffer.cpp.

Referenced by DdMd::Exchanger::allocate(), and allocate().

template<int N>
int DdMd::Buffer::groupCapacity ( ) const

Maximum number of group<N> objects for which space is available.

Definition at line 593 of file Buffer.h.

References UTIL_THROW.

Referenced by DdMd::GroupCollector< N >::send().


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