Classes | Public Types | Public Member Functions | Private Types | Static Private Member Functions | Private Attributes | Friends

LibGeoDecomp::MPILayer Class Reference

MPILayer is a wrapper that provides a mostly 1:1 identical access to MPI functions, but with a number of convenient twists, where appropriate. More...

#include <mpilayer.h>

Collaboration diagram for LibGeoDecomp::MPILayer:
Collaboration graph
[legend]

List of all members.

Classes

class  StreakToAddressTranslatingIterator
class  StreakToLengthTranslatingIterator

Public Types

enum  Tag { PATCH_LINK = 100, PARALLEL_MEMORY_WRITER = 200 }
 

Tags are required to distinguish different transmissions with identical sender, receiver, and communicator.

More...
typedef std::map< int,
std::vector< MPI_Request > > 
RequestsMap

Public Member Functions

 MPILayer (MPI_Comm communicator=MPI_COMM_WORLD, int tag=0)
 Sets up a new MPILayer.
 MPILayer (const MPILayer &other)
virtual ~MPILayer ()
template<typename T >
void send (const T *c, int dest, int num=1, const MPI_Datatype &datatype=Typemaps::lookup< T >())
template<typename T >
void send (const T *c, int dest, int num, int tag, const MPI_Datatype &datatype=Typemaps::lookup< T >())
template<typename T >
void recv (T *c, int src, int num=1, const MPI_Datatype &datatype=Typemaps::lookup< T >())
template<typename T >
void recv (T *c, int src, int num, int tag, const MPI_Datatype &datatype=Typemaps::lookup< T >())
void cancelAll ()
void cancel (int waitTag)
void waitAll ()
 blocks until all asynchronous communications have been completed.
void wait (int waitTag)
 waits until those communication requests tagged with waitTag are finished.
void testAll ()
void test (int testTag)
void barrier ()
MPI_Comm communicator ()
int size () const
 returns the number of nodes in the communicator.
int rank () const
 returns the id number of the current node.
template<typename T >
void sendVec (const std::vector< T > *vec, int dest, int waitTag=0, const MPI_Datatype &datatype=Typemaps::lookup< T >())
template<typename T >
void recvVec (std::vector< T > *vec, int src, int waitTag=0, const MPI_Datatype &datatype=Typemaps::lookup< T >())
template<int DIM>
void sendRegion (const Region< DIM > &region, int dest)
 Sends a region object synchronously to another node.
template<int DIM>
void recvRegion (Region< DIM > *region, int src)
 Receives a region object from another node, also synchronously.
template<int DIM>
Region< DIM > recvRegion (int src)
 Convenience function that will simply return the received Region by value.
template<typename GRID_TYPE , int DIM>
void recvUnregisteredRegion (GRID_TYPE *stripe, const Region< DIM > &region, int src, int tag, const MPI_Datatype &datatype)
template<typename GRID_TYPE , int DIM>
void sendUnregisteredRegion (GRID_TYPE *stripe, const Region< DIM > &region, int dest, int tag, const MPI_Datatype &datatype)
template<typename T >
std::vector< T > allGather (const T &source, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
void allGather (const T *source, T *target, int num, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
void allGather (const T &source, std::vector< T > *target, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
std::vector< T > allGatherV (const T *source, const std::vector< int > &lengths, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
void allGatherV (const T *source, const std::vector< int > &lengths, std::vector< T > *target, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
std::vector< T > gather (const T &item, int root, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
void gatherV (const T *source, int num, const std::vector< int > &lengths, int root, T *target, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
 Simple wrapper for MPI_Gatherv.
template<typename T >
void gatherV (const std::vector< T > &source, const std::vector< int > &lengths, int root, std::vector< T > &target, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
broadcast (const T &source, int root, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
 Broadcasts static size stuff.
template<typename T >
void broadcast (T *buffer, int num, int root, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
std::vector< T > broadcastVector (const std::vector< T > &source, int root, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const
template<typename T >
void broadcastVector (std::vector< T > *buffer, int root, const MPI_Datatype &datatype=Typemaps::lookup< T >()) const

Private Types

typedef std::pair< const void
*, unsigned
ChunkSpec

Static Private Member Functions

static bool addressLower (ChunkSpec a, ChunkSpec b)

Private Attributes

MPI_Comm comm
int tag
RequestsMap requests

Friends

class MPILayerTest
class ParallelMPILayerTest

Detailed Description

MPILayer is a wrapper that provides a mostly 1:1 identical access to MPI functions, but with a number of convenient twists, where appropriate.


Member Typedef Documentation

typedef std::pair<const void*, unsigned> LibGeoDecomp::MPILayer::ChunkSpec [private]
typedef std::map<int, std::vector<MPI_Request> > LibGeoDecomp::MPILayer::RequestsMap

Member Enumeration Documentation

Tags are required to distinguish different transmissions with identical sender, receiver, and communicator.

We list all tags in a central place to check for collisions. Mostly having one tag per class should be enough (assuming that those objects communicate with their siblings only). In those cases when we have multiple instances (e.g. two PatchLink connections), an offset to the tag should be used.

Enumerator:
PATCH_LINK 
PARALLEL_MEMORY_WRITER 

Constructor & Destructor Documentation

LibGeoDecomp::MPILayer::MPILayer ( MPI_Comm  communicator = MPI_COMM_WORLD,
int  tag = 0 
) [inline, explicit]

Sets up a new MPILayer.

communicator will be used as a scope for all MPI functions, tag will be the default tag passed to all point-to-point communication functions.

LibGeoDecomp::MPILayer::MPILayer ( const MPILayer other  )  [inline, explicit]
virtual LibGeoDecomp::MPILayer::~MPILayer (  )  [inline, virtual]

References requests.


Member Function Documentation

static bool LibGeoDecomp::MPILayer::addressLower ( ChunkSpec  a,
ChunkSpec  b 
) [inline, static, private]
template<typename T >
std::vector<T> LibGeoDecomp::MPILayer::allGather ( const T &  source,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
void LibGeoDecomp::MPILayer::allGather ( const T *  source,
T *  target,
int  num,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]

References allGather(), and size().

Referenced by allGather().

template<typename T >
void LibGeoDecomp::MPILayer::allGather ( const T &  source,
std::vector< T > *  target,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
std::vector<T> LibGeoDecomp::MPILayer::allGatherV ( const T *  source,
const std::vector< int > &  lengths,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]

References allGather().

template<typename T >
void LibGeoDecomp::MPILayer::allGatherV ( const T *  source,
const std::vector< int > &  lengths,
std::vector< T > *  target,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]

References allGatherV(), and LibGeoDecomp::sum().

Referenced by allGatherV().

void LibGeoDecomp::MPILayer::barrier (  )  [inline]

References requests.

template<typename T >
T LibGeoDecomp::MPILayer::broadcast ( const T &  source,
int  root,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
void LibGeoDecomp::MPILayer::broadcast ( T *  buffer,
int  num,
int  root,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
std::vector<T> LibGeoDecomp::MPILayer::broadcastVector ( const std::vector< T > &  source,
int  root,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
void LibGeoDecomp::MPILayer::broadcastVector ( std::vector< T > *  buffer,
int  root,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
void LibGeoDecomp::MPILayer::cancel ( int  waitTag  )  [inline]

References requests.

void LibGeoDecomp::MPILayer::cancelAll (  )  [inline]

References comm, and requests.

MPI_Comm LibGeoDecomp::MPILayer::communicator (  )  [inline]
template<typename T >
std::vector<T> LibGeoDecomp::MPILayer::gather ( const T &  item,
int  root,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
template<typename T >
void LibGeoDecomp::MPILayer::gatherV ( const T *  source,
int  num,
const std::vector< int > &  lengths,
int  root,
T *  target,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]

Simple wrapper for MPI_Gatherv.

lengths is only relevant on root. Expects that target has sufficient capacity.

Referenced by LibGeoDecomp::RemoteSteererHelpers::Pipe::moveSteeringFeedbackToRoot().

template<typename T >
void LibGeoDecomp::MPILayer::gatherV ( const std::vector< T > &  source,
const std::vector< int > &  lengths,
int  root,
std::vector< T > &  target,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) const [inline]
int LibGeoDecomp::MPILayer::rank (  )  const [inline]
template<typename T >
void LibGeoDecomp::MPILayer::recv ( T *  c,
int  src,
int  num,
int  tag,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]

References recv().

Referenced by recv().

template<typename T >
void LibGeoDecomp::MPILayer::recv ( T *  c,
int  src,
int  num = 1,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]
template<int DIM>
void LibGeoDecomp::MPILayer::recvRegion ( Region< DIM > *  region,
int  src 
) [inline]

Receives a region object from another node, also synchronously.

Referenced by LibGeoDecomp::ParallelMemoryWriter< CELL_TYPE >::sendRecvGrid(), and LibGeoDecomp::CollectingWriter< CELL_TYPE >::stepFinished().

template<int DIM>
Region<DIM> LibGeoDecomp::MPILayer::recvRegion ( int  src  )  [inline]

Convenience function that will simply return the received Region by value.

template<typename GRID_TYPE , int DIM>
void LibGeoDecomp::MPILayer::recvUnregisteredRegion ( GRID_TYPE *  stripe,
const Region< DIM > &  region,
int  src,
int  tag,
const MPI_Datatype &  datatype 
) [inline]
template<typename T >
void LibGeoDecomp::MPILayer::recvVec ( std::vector< T > *  vec,
int  src,
int  waitTag = 0,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]
template<typename T >
void LibGeoDecomp::MPILayer::send ( const T *  c,
int  dest,
int  num = 1,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]

Referenced by allGather().

template<typename T >
void LibGeoDecomp::MPILayer::send ( const T *  c,
int  dest,
int  num,
int  tag,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]

References send(), and tag.

Referenced by send().

template<int DIM>
void LibGeoDecomp::MPILayer::sendRegion ( const Region< DIM > &  region,
int  dest 
) [inline]
template<typename GRID_TYPE , int DIM>
void LibGeoDecomp::MPILayer::sendUnregisteredRegion ( GRID_TYPE *  stripe,
const Region< DIM > &  region,
int  dest,
int  tag,
const MPI_Datatype &  datatype 
) [inline]
template<typename T >
void LibGeoDecomp::MPILayer::sendVec ( const std::vector< T > *  vec,
int  dest,
int  waitTag = 0,
const MPI_Datatype &  datatype = Typemaps::lookup<T>() 
) [inline]
int LibGeoDecomp::MPILayer::size (  )  const [inline]
void LibGeoDecomp::MPILayer::test ( int  testTag  )  [inline]

References requests.

void LibGeoDecomp::MPILayer::testAll (  )  [inline]
void LibGeoDecomp::MPILayer::wait ( int  waitTag  )  [inline]
void LibGeoDecomp::MPILayer::waitAll (  )  [inline]

Friends And Related Function Documentation

friend class MPILayerTest [friend]
friend class ParallelMPILayerTest [friend]

Member Data Documentation

MPI_Comm LibGeoDecomp::MPILayer::comm [private]

Referenced by cancelAll(), rank(), and recv().

Referenced by send().


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