LAMA
lama::MPICommunicator Class Reference

Communicator class that implements communication and data exchange via MPI. More...

#include <MPICommunicator.hpp>

Inheritance diagram for lama::MPICommunicator:

Public Types

enum  ThreadSafetyLevel { Funneled = 1, Serialized = 2, Multiple = 3 }
 Enumeration type for supported thread safety levels. More...

Public Member Functions

virtual ~MPICommunicator ()
virtual bool isEqual (const Communicator &other) const
 Virtual method used for the equality operator.
virtual ThreadSafetyLevel getThreadSafetyLevel () const
virtual PartitionId getSize () const
 Number of partitions.
virtual PartitionId getRank () const
 Id of this partitinon.
MPI_Comm getMPIComm () const
virtual void all2all (int *recvValues, const int *sendValues) const
 All-to-all exchange of an integer value between all processors.
virtual void exchangeByPlan (int *const recvData, const CommunicationPlan &recvPlan, const int *const sendData, const CommunicationPlan &sendPlan) const
 Exchange data between all processors by communication plans.
virtual void exchangeByPlan (float *const recvData, const CommunicationPlan &recvPlan, const float *const sendData, const CommunicationPlan &sendPlan) const
 Exchange of float values.
virtual void exchangeByPlan (double *const recvData, const CommunicationPlan &recvPlan, const double *const sendData, const CommunicationPlan &sendPlan) const
 Exchange of double values.
virtual std::auto_ptr< SyncTokenexchangeByPlanAsync (int *const recvData, const CommunicationPlan &recvPlan, const int *const sendData, const CommunicationPlan &sendPlan) const
virtual std::auto_ptr< SyncTokenexchangeByPlanAsync (float *const recvData, const CommunicationPlan &recvPlan, const float *const sendData, const CommunicationPlan &sendPlan) const
 Exchange of float values.
virtual std::auto_ptr< SyncTokenexchangeByPlanAsync (double *const recvData, const CommunicationPlan &recvPlan, const double *const sendData, const CommunicationPlan &sendPlan) const
 Exchange of double values.
template<typename T >
MPI_Request startrecv (T *buffer, int count, int source) const
template<typename T >
MPI_Request startsend (const T *buffer, int count, int target) const
virtual float sum (const float value) const
 Sum operations sum up one single value from each partition to a global value.
virtual double sum (const double value) const
virtual int sum (const int value) const
virtual float min (const float value) const
virtual size_t sum (const size_t value) const
virtual float max (const float value) const
virtual double min (const double value) const
virtual double max (const double value) const
virtual int min (const int value) const
virtual int max (const int value) const
virtual void gather (std::vector< float > &values, float value) const
 Gather single float value from each processor into a vector.
virtual void synchronize () const
 Barrier synchronization between all processors.
virtual IndexType shift (double newVals[], const IndexType newSize, const double oldVals[], const IndexType oldSize, const int direction) const
 This routine shifts data between neighbored processors.
virtual IndexType shift (float newVals[], const IndexType newSize, const float oldVals[], const IndexType oldSize, const int direction) const
virtual IndexType shift (int newVals[], const IndexType newSize, const int oldVals[], const IndexType oldSize, const int direction) const
virtual std::auto_ptr< SyncTokenshiftAsync (double newVals[], const double oldVals[], const IndexType size, const int direction) const
 Asynchronous version of shift.
virtual std::auto_ptr< SyncTokenshiftAsync (float newVals[], const float oldVals[], const IndexType size, const int direction) const
virtual std::auto_ptr< SyncTokenshiftAsync (int newVals[], const int oldVals[], const IndexType size, const int direction) const
virtual void bcast (double val[], const IndexType n, const PartitionId root) const
 Broadcast an array of doubles from root to all processors in simulation.
virtual void bcast (int val[], const IndexType n, const PartitionId root) const
 Broadcast an array of int from root to all processors in simulation.
virtual void bcast (float val[], const IndexType n, const PartitionId root) const
 Broadcast an array of float from root to all processors in simulation.
virtual void scatter (double myvals[], const IndexType n, const PartitionId root, const double allvals[]) const
 scatter
virtual void scatter (float myvals[], const IndexType n, const PartitionId root, const float allvals[]) const
virtual void scatter (int myvals[], const IndexType n, const PartitionId root, const int allvals[]) const
virtual void scatter (double myvals[], const IndexType n, const PartitionId root, const double allvals[], const IndexType sizes[]) const
 Scatter of an array of values from root to all other processors.
virtual void scatter (float myvals[], const IndexType n, const PartitionId root, const float allvals[], const IndexType sizes[]) const
virtual void scatter (int myvals[], const IndexType n, const PartitionId root, const int allvals[], const IndexType sizes[]) const
virtual void gather (double allvals[], const IndexType n, const PartitionId root, const double myvals[]) const
 gather
virtual void gather (float allvals[], const IndexType n, const PartitionId root, const float myvals[]) const
virtual void gather (int allvals[], const IndexType n, const PartitionId root, const int myvals[]) const
virtual void gather (double allvals[], const IndexType n, const PartitionId root, const double myvals[], const IndexType sizes[]) const
 Gather of an array of values from all processors to root.
virtual void gather (float allvals[], const IndexType n, const PartitionId root, const float myvals[], const IndexType sizes[]) const
virtual void gather (int allvals[], const IndexType n, const PartitionId root, const int myvals[], const IndexType sizes[]) const
virtual void maxloc (double &val, int &location, const PartitionId root) const
 Maximal value combined with a location value where maximum was found.
virtual void maxloc (float &val, int &location, const PartitionId root) const
virtual void maxloc (int &val, int &location, const PartitionId root) const
virtual void swap (double val[], const IndexType n, const PartitionId partner) const
 This routine swaps an array with a partner processor.
virtual void swap (float val[], const IndexType n, const PartitionId partner) const
virtual void swap (int val[], const IndexType n, const PartitionId partner) const
virtual void writeAt (std::ostream &stream) const
 Override virtual method of base class Printable.
void factorize2 (const double sizeX, const double sizeY, PartitionId procgrid[2]) const
void factorize3 (const double sizeX, const double sizeY, const double sizeZ, PartitionId procgrid[3]) const
void getGrid2Rank (PartitionId pos[2], const PartitionId procgrid[2]) const
void getGrid3Rank (PartitionId pos[3], const PartitionId procgrid[3]) const
bool operator== (const Communicator &other) const
 Equality operator for two communicators.
bool operator!= (const Communicator &other) const
PartitionId getNeighbor (int pos) const
 Help routine to get the rank of a neighbored position.
template<typename T >
void exchangeByPlan (LAMAArray< T > &recvArray, const CommunicationPlan &recvPlan, const LAMAArray< T > &sendArray, const CommunicationPlan &sendPlan) const
template<typename T >
std::auto_ptr< SyncTokenexchangeByPlanAsync (LAMAArray< T > &recvArray, const CommunicationPlan &recvPlan, const LAMAArray< T > &sendArray, const CommunicationPlan &sendPlan) const
template<typename T >
void updateHalo (LAMAArray< T > &haloValues, const LAMAArray< T > &localValues, const Halo &halo) const
 Update of halo array via Halo object.
template<typename T >
std::auto_ptr< SyncTokenupdateHaloAsync (LAMAArray< T > &haloValues, const LAMAArray< T > &localValues, const Halo &halo) const
 Asynchronous update of halo array via Halo object.
template<typename T >
void shift (LAMAArray< T > &recv, const LAMAArray< T > &send, const int direction) const
 Shift on LAMA arrays.
template<typename T >
std::auto_ptr< SyncTokenshiftAsync (LAMAArray< T > &recvArray, const LAMAArray< T > &sendArray, const int direction) const
 Asychronous shift on LAMA arrays.
void computeOwners (const std::vector< IndexType > &requiredIndexes, const Distribution &distribution, std::vector< PartitionId > &owners) const
 Ownership computation for indexes where only each partition individually can determine whether an index is local or not.
const std::string & getType () const
 getter for the type of a communicator.

Protected Member Functions

virtual ContextPtr getCommunicationContext () const
 getter for Context needed for Communication
template<typename T >
IndexType shift0 (T newVals[], const IndexType newSize, const T oldVals[], const IndexType oldSize) const
 Shift implementation for direction == 0, just copies values.
template<typename T >
std::auto_ptr< SyncTokendefaultShiftAsync (T newVals[], const T oldVals[], const IndexType size, const int direction) const
 Default asynchronous shift uses synchronous shift.

Static Protected Member Functions

static void getUserProcArray (PartitionId userProcArray[3])
 Read in the environment variable NP4LAMA for user processor array.

Protected Attributes

std::string mCommunicatorType

Private Member Functions

 MPICommunicator (int &argc, char **&argv)
template<typename T >
sumImpl (T myVal) const
template<typename T >
maxval (T myVal) const
template<typename T >
minval (T myVal) const
template<typename T >
void send (const T *buffer, int count, int target) const
template<typename T >
int getCount (MPI_Status &status) const
template<typename T >
void scatterImpl (T myvals[], const IndexType n, const PartitionId root, const T allvals[]) const
template<typename T >
void scatterImpl (T myvals[], const IndexType n, const PartitionId root, const T allvals[], const IndexType sizes[]) const
template<typename T >
void gatherImpl (T allvals[], const IndexType n, const PartitionId root, const T myvals[]) const
template<typename T >
void gatherImpl (T allvals[], const IndexType n, const PartitionId root, const T myvals[], const IndexType sizes[]) const
template<typename T >
IndexType shiftImpl (T newvals[], const IndexType newSize, const PartitionId source, const T oldVals[], const IndexType oldSize, const PartitionId dest) const
template<typename T >
std::auto_ptr< SyncTokenshiftAsyncImpl (T newvals[], const PartitionId source, const T oldVals[], const PartitionId dest, const IndexType size) const
template<typename T >
void swapImpl (T val[], const IndexType n, PartitionId partner) const
template<typename T >
void maxlocImpl (T &val, int &location, PartitionId root) const
template<typename T >
void exchangeByPlanImpl (T *const recvData, const CommunicationPlan &recvPlan, const T *const sendData, const CommunicationPlan &sendPlan) const
template<typename T >
std::auto_ptr< SyncTokenexchangeByPlanAsyncImpl (T *const recvData, const CommunicationPlan &recvPlan, const T *const sendData, const CommunicationPlan &sendPlan) const
MPI_Comm selectMPIComm () const
 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Static Private Member Functions

template<typename T >
static MPI_Datatype getMPIType ()
template<typename T1 , typename T2 >
static MPI_Datatype getMPI2Type ()

Private Attributes

MPI_Comm mCommWorld
MPI_Comm mComm
MPI_Comm mCommTask
const boost::thread mMainThread
Communicator::ThreadSafetyLevel mThreadSafetyLevel
int mRank
int mSize
bool mExternInitialization

Static Private Attributes

static const int defaultTag = 1

Friends

class MPICommunicatorManager

Detailed Description

Communicator class that implements communication and data exchange via MPI.

MPI_Init is called in the constructor, MPI_Finalize is called in the destructor.


Member Enumeration Documentation

Enumeration type for supported thread safety levels.

Enumerator:
Funneled 

The Program can be multithreaded but only the master thread should communicate.

Serialized 

The Program can be multithreaded but the communicator usage is serialized.

Multiple 

The Program can be multithreaded and the communicator can be used by all threads concurrently.


Constructor & Destructor Documentation


Member Function Documentation

void lama::MPICommunicator::all2all ( int *  recvValues,
const int *  sendValues 
) const [virtual]

All-to-all exchange of an integer value between all processors.

Parameters:
[out]recvValueswill contain one value from each processor
[in]sendValuesmust contain one value for each processor

recvValues and sendValues must both have a size of communicator size. recvValues[i] on processor j contains sendValues[j] of processor i.

Implements lama::Communicator.

References LAMA_ASSERT_ERROR, LAMA_MPICALL, and selectMPIComm().

void lama::MPICommunicator::bcast ( double  val[],
const IndexType  n,
const PartitionId  root 
) const [virtual]

Broadcast an array of doubles from root to all processors in simulation.

Implements lama::Communicator.

References LAMA_MPICALL, and selectMPIComm().

void lama::MPICommunicator::bcast ( int  val[],
const IndexType  n,
const PartitionId  root 
) const [virtual]

Broadcast an array of int from root to all processors in simulation.

Implements lama::Communicator.

References LAMA_MPICALL, and selectMPIComm().

void lama::MPICommunicator::bcast ( float  val[],
const IndexType  n,
const PartitionId  root 
) const [virtual]

Broadcast an array of float from root to all processors in simulation.

Implements lama::Communicator.

References LAMA_MPICALL, and selectMPIComm().

void lama::Communicator::computeOwners ( const std::vector< IndexType > &  requiredIndexes,
const Distribution distribution,
std::vector< PartitionId > &  owners 
) const [inherited]

Ownership computation for indexes where only each partition individually can determine whether an index is local or not.

This method should not be called for distributions where the owner can be computed by a closed formula.

References lama::WriteAccess< T >::get(), lama::Distribution::getCommunicator(), lama::Communicator::getRank(), lama::Communicator::getSize(), lama::Distribution::isLocal(), LAMA_ASSERT_ERROR, LAMA_THROWEXCEPTION, lama::Communicator::max(), lama::WriteAccess< T >::release(), lama::Communicator::shift(), and lama::LAMAArray< T >::swap().

Referenced by lama::HaloBuilder::build().

template<typename T >
template LAMA_DLL_IMPORTEXPORT auto_ptr< SyncToken > lama::Communicator::defaultShiftAsync ( newVals[],
const T  oldVals[],
const IndexType  size,
const int  direction 
) const [protected, inherited]

Default asynchronous shift uses synchronous shift.

References LAMA_ASSERT_ERROR, and lama::Communicator::shift().

Referenced by lama::PGASCommunicator::shiftAsync(), shiftAsync(), and lama::Communicator::shiftAsync().

void lama::MPICommunicator::exchangeByPlan ( int *const  recvData,
const CommunicationPlan recvPlan,
const int *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]

Exchange data between all processors by communication plans.

Parameters:
[out]recvDatabuffer for data received from other processors
[in]recvPlannumber of elements and offsets for receiving
[in]sendDatabuffer for data to send to other processors
[in]sendPlancontains number of elements and offsets for sending data

Implements lama::Communicator.

References exchangeByPlanImpl().

void lama::MPICommunicator::exchangeByPlan ( float *const  recvData,
const CommunicationPlan recvPlan,
const float *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]

Exchange of float values.

Implements lama::Communicator.

References exchangeByPlanImpl().

void lama::MPICommunicator::exchangeByPlan ( double *const  recvData,
const CommunicationPlan recvPlan,
const double *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]

Exchange of double values.

Implements lama::Communicator.

References exchangeByPlanImpl().

std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync ( int *const  recvData,
const CommunicationPlan recvPlan,
const int *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]
std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync ( float *const  recvData,
const CommunicationPlan recvPlan,
const float *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]

Exchange of float values.

Implements lama::Communicator.

References exchangeByPlanAsyncImpl().

std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync ( double *const  recvData,
const CommunicationPlan recvPlan,
const double *const  sendData,
const CommunicationPlan sendPlan 
) const [virtual]

Exchange of double values.

Implements lama::Communicator.

References exchangeByPlanAsyncImpl().

template<typename T >
std::auto_ptr< SyncToken > lama::Communicator::exchangeByPlanAsync ( LAMAArray< T > &  recvArray,
const CommunicationPlan recvPlan,
const LAMAArray< T > &  sendArray,
const CommunicationPlan sendPlan 
) const [inherited]
template<typename T >
auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsyncImpl ( T *const  recvData,
const CommunicationPlan recvPlan,
const T *const  sendData,
const CommunicationPlan sendPlan 
) const [private]
template<typename T >
void lama::MPICommunicator::exchangeByPlanImpl ( T *const  recvData,
const CommunicationPlan recvPlan,
const T *const  sendData,
const CommunicationPlan sendPlan 
) const [private]
void lama::Communicator::factorize2 ( const double  sizeX,
const double  sizeY,
PartitionId  procgrid[2] 
) const [inherited]
void lama::Communicator::factorize3 ( const double  sizeX,
const double  sizeY,
const double  sizeZ,
PartitionId  procgrid[3] 
) const [inherited]
void lama::MPICommunicator::gather ( std::vector< float > &  values,
float  value 
) const [virtual]

Gather single float value from each processor into a vector.

Implements lama::Communicator.

References LAMA_MPICALL, mSize, and selectMPIComm().

void lama::MPICommunicator::gather ( double  allvals[],
const IndexType  n,
const PartitionId  root,
const double  myvals[] 
) const [virtual]

gather

Implements lama::Communicator.

References gatherImpl().

void lama::MPICommunicator::gather ( float  allvals[],
const IndexType  n,
const PartitionId  root,
const float  myvals[] 
) const [virtual]

Implements lama::Communicator.

References gatherImpl().

void lama::MPICommunicator::gather ( int  allvals[],
const IndexType  n,
const PartitionId  root,
const int  myvals[] 
) const [virtual]

Implements lama::Communicator.

References gatherImpl().

void lama::MPICommunicator::gather ( double  allvals[],
const IndexType  n,
const PartitionId  root,
const double  myvals[],
const IndexType  sizes[] 
) const [virtual]

Gather of an array of values from all processors to root.

Parameters:
[out]allvalsvalues that I receive (size must be sum(sizes) )
[in]nnumber of elements in vector val
[in]rootprocessor with values for all processors
[in]myvalsvalues for all processors
[in]sizesnumber of total values for all processors

Implements lama::Communicator.

References gatherImpl().

void lama::MPICommunicator::gather ( float  allvals[],
const IndexType  n,
const PartitionId  root,
const float  myvals[],
const IndexType  sizes[] 
) const [virtual]

Implements lama::Communicator.

References gatherImpl().

void lama::MPICommunicator::gather ( int  allvals[],
const IndexType  n,
const PartitionId  root,
const int  myvals[],
const IndexType  sizes[] 
) const [virtual]

Implements lama::Communicator.

References gatherImpl().

template<typename T >
void lama::MPICommunicator::gatherImpl ( allvals[],
const IndexType  n,
const PartitionId  root,
const T  myvals[] 
) const [private]
template<typename T >
void lama::MPICommunicator::gatherImpl ( allvals[],
const IndexType  n,
const PartitionId  root,
const T  myvals[],
const IndexType  sizes[] 
) const [private]

getter for Context needed for Communication

Returns:
the ContextPtr

Implements lama::Communicator.

References lama::ContextFactory::getContext(), and lama::Context::Host.

template<typename T >
int lama::MPICommunicator::getCount ( MPI_Status &  status) const [inline, private]

References LAMA_MPICALL.

MPI_Datatype lama::MPICommunicator::getMPI2Type< int, int > ( ) [inline, static, private]

References LAMA_THROWEXCEPTION.

References mComm.

MPI_Datatype lama::MPICommunicator::getMPIType< unsigned long > ( ) [inline, static, private]
PartitionId lama::Communicator::getNeighbor ( int  pos) const [inline, inherited]

Help routine to get the rank of a neighbored position.

Parameters:
[in]posis the distance to the neighbor (also negative)
Returns:
rank of the neighbored processor

This method assumes a circular ring formed by all processors.

References lama::abs(), lama::Communicator::getRank(), lama::Communicator::getSize(), and LAMA_ASSERT.

Referenced by lama::DenseMatrix< T >::matrixTimesVectorImpl(), lama::PGASCommunicator::shift(), shift(), lama::PGASCommunicator::shiftAsync(), and shiftAsync().

Id of this partitinon.

Returns:
rank of this partition, 0 <= rank < getSize()

Implements lama::Communicator.

References mRank.

Referenced by gatherImpl(), scatterImpl(), shiftAsyncImpl(), and shiftImpl().

Number of partitions.

Implements lama::Communicator.

References mSize.

Referenced by gatherImpl(), scatterImpl(), shift(), and shiftAsync().

const std::string& lama::Communicator::getType ( ) const [inline, inherited]

getter for the type of a communicator.

void lama::Communicator::getUserProcArray ( PartitionId  userProcArray[3]) [static, protected, inherited]

Read in the environment variable NP4LAMA for user processor array.

Parameters:
[out]userProcArrayspecifies the user processor array.

Referenced by lama::Communicator::factorize2(), and lama::Communicator::factorize3().

bool lama::MPICommunicator::isEqual ( const Communicator other) const [virtual]

Virtual method used for the equality operator.

Implements lama::Communicator.

References mComm.

Reimplemented from lama::Communicator.

float lama::MPICommunicator::max ( const float  value) const [virtual]

Implements lama::Communicator.

References maxval().

double lama::MPICommunicator::max ( const double  value) const [virtual]

Implements lama::Communicator.

References maxval().

int lama::MPICommunicator::max ( const int  value) const [virtual]

Implements lama::Communicator.

References maxval().

void lama::MPICommunicator::maxloc ( double &  val,
int &  location,
const PartitionId  root 
) const [virtual]

Maximal value combined with a location value where maximum was found.

Parameters:
[in,out]valis a value on each processor, only out for root with maximal value
[in,out]locationis an additional int value, only out for root

Only root processor will contain the maximal value and the location loc.

Implements lama::Communicator.

References maxlocImpl().

void lama::MPICommunicator::maxloc ( float &  val,
int &  location,
const PartitionId  root 
) const [virtual]

Implements lama::Communicator.

References maxlocImpl().

void lama::MPICommunicator::maxloc ( int &  val,
int &  location,
const PartitionId  root 
) const [virtual]

Implements lama::Communicator.

References maxlocImpl().

template<typename T >
void lama::MPICommunicator::maxlocImpl ( T &  val,
int &  location,
PartitionId  root 
) const [private]

References mRank, and selectMPIComm().

Referenced by maxloc().

template<typename T >
T lama::MPICommunicator::maxval ( myVal) const [private]

References LAMA_MPICALL, and selectMPIComm().

Referenced by max().

float lama::MPICommunicator::min ( const float  value) const [virtual]

Implements lama::Communicator.

References minval().

double lama::MPICommunicator::min ( const double  value) const [virtual]

Implements lama::Communicator.

References minval().

int lama::MPICommunicator::min ( const int  value) const [virtual]

Implements lama::Communicator.

References minval().

template<typename T >
T lama::MPICommunicator::minval ( myVal) const [private]

References LAMA_MPICALL, and selectMPIComm().

Referenced by min().

bool lama::Communicator::operator!= ( const Communicator other) const [inherited]
bool lama::Communicator::operator== ( const Communicator other) const [inherited]

Equality operator for two communicators.

Parameters:
[in]othercommunicator for comparison
Returns:
true if this communicator is equal to other communicator.

Note: Logic of this operator is implemented via the virtual functions isEqual.

References lama::Communicator::isEqual().

void lama::MPICommunicator::scatter ( double  myvals[],
const IndexType  n,
const PartitionId  root,
const double  allvals[] 
) const [virtual]

scatter

Implements lama::Communicator.

References scatterImpl().

void lama::MPICommunicator::scatter ( float  myvals[],
const IndexType  n,
const PartitionId  root,
const float  allvals[] 
) const [virtual]

Implements lama::Communicator.

References scatterImpl().

void lama::MPICommunicator::scatter ( int  myvals[],
const IndexType  n,
const PartitionId  root,
const int  allvals[] 
) const [virtual]

Implements lama::Communicator.

References scatterImpl().

void lama::MPICommunicator::scatter ( double  myvals[],
const IndexType  n,
const PartitionId  root,
const double  allvals[],
const IndexType  sizes[] 
) const [virtual]

Scatter of an array of values from root to all other processors.

Parameters:
[out]myvalsvalues that I receive
[in]nnumber of elements in vector val
[in]rootprocessor with values for all processors
[in]allvalsvalues for all processors (size must be sum(sizes) )
[in]sizesnumber of total values for all processors

Implements lama::Communicator.

References scatterImpl().

void lama::MPICommunicator::scatter ( float  myvals[],
const IndexType  n,
const PartitionId  root,
const float  allvals[],
const IndexType  sizes[] 
) const [virtual]

Implements lama::Communicator.

References scatterImpl().

void lama::MPICommunicator::scatter ( int  myvals[],
const IndexType  n,
const PartitionId  root,
const int  allvals[],
const IndexType  sizes[] 
) const [virtual]

Implements lama::Communicator.

References scatterImpl().

template<typename T >
void lama::MPICommunicator::scatterImpl ( myvals[],
const IndexType  n,
const PartitionId  root,
const T  allvals[] 
) const [private]
template<typename T >
void lama::MPICommunicator::scatterImpl ( myvals[],
const IndexType  n,
const PartitionId  root,
const T  allvals[],
const IndexType  sizes[] 
) const [private]
template<typename T >
void lama::MPICommunicator::send ( const T *  buffer,
int  count,
int  target 
) const [inline, private]

References defaultTag, LAMA_MPICALL, and selectMPIComm().

Referenced by exchangeByPlanImpl().

IndexType lama::MPICommunicator::shift ( double  newVals[],
const IndexType  newSize,
const double  oldVals[],
const IndexType  oldSize,
const int  direction 
) const [virtual]

This routine shifts data between neighbored processors.

Parameters:
[out]newValsarray with data this partition get from neighbored partition
[in]newSizeallocated size of array newVals
[in]oldValsarray with data this partition sends to neighbored partition
[in]oldSizenumber of elements of array oldVals that will be sent
[in]directionspecifies the neighbored partitions to send and receive
Returns:
number of values received in newVals (newSize must have been larger before)

Each partition sends to rank() + direction and receives from rank() - direction.

Implements lama::Communicator.

References lama::Communicator::getNeighbor(), getSize(), lama::Communicator::shift0(), and shiftImpl().

IndexType lama::MPICommunicator::shift ( float  newVals[],
const IndexType  newSize,
const float  oldVals[],
const IndexType  oldSize,
const int  direction 
) const [virtual]
IndexType lama::MPICommunicator::shift ( int  newVals[],
const IndexType  newSize,
const int  oldVals[],
const IndexType  oldSize,
const int  direction 
) const [virtual]
template<typename T >
void lama::Communicator::shift ( LAMAArray< T > &  recv,
const LAMAArray< T > &  send,
const int  direction 
) const [inherited]

Shift on LAMA arrays.

Parameters:
[in]recvarray to receive for this partition
[out]sendarray to send from this partition
[in]directionnumber of positions to shift, e.g. 1 or -1

Note: The recv array must have a capacity that is sufficent to receive all the data.

References lama::WriteAccess< T >::capacity(), lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::Communicator::getSize(), LAMA_ASSERT_ERROR, lama::WriteAccess< T >::resize(), and lama::ReadAccess< T >::size().

Referenced by lama::Communicator::computeOwners(), lama::Communicator::defaultShiftAsync(), lama::DenseMatrix< T >::matrixTimesVectorImpl(), lama::Distribution::replicate(), and lama::Distribution::replicateN().

template<typename T >
template LAMA_DLL_IMPORTEXPORT IndexType lama::Communicator::shift0 ( newVals[],
const IndexType  newSize,
const T  oldVals[],
const IndexType  oldSize 
) const [protected, inherited]

Shift implementation for direction == 0, just copies values.

References LAMA_ASSERT_ERROR.

Referenced by lama::NoCommunicator::shift(), lama::PGASCommunicator::shift(), and shift().

auto_ptr< SyncToken > lama::MPICommunicator::shiftAsync ( double  newVals[],
const double  oldVals[],
const IndexType  size,
const int  direction 
) const [virtual]

Asynchronous version of shift.

As there is no information about the received size this routine can only be called for arrays that have the same size on all partitions.

A default implementation is provided that returns a NoSyncToken. Derived classes should override this method if there is a benefit of using asynchronous transfers.

Reimplemented from lama::Communicator.

References lama::Communicator::defaultShiftAsync(), lama::Communicator::getNeighbor(), getSize(), and shiftAsyncImpl().

auto_ptr< SyncToken > lama::MPICommunicator::shiftAsync ( float  newVals[],
const float  oldVals[],
const IndexType  size,
const int  direction 
) const [virtual]
auto_ptr< SyncToken > lama::MPICommunicator::shiftAsync ( int  newVals[],
const int  oldVals[],
const IndexType  size,
const int  direction 
) const [virtual]
template<typename T >
auto_ptr< SyncToken > lama::Communicator::shiftAsync ( LAMAArray< T > &  recvArray,
const LAMAArray< T > &  sendArray,
const int  direction 
) const [inherited]

Asychronous shift on LAMA arrays.

Parameters:
[out]recvArrayarray to receive for this partition
[in]sendArrayarray to send from this partition
[in]directionnumber of positions to shift, e.g. 1 or -1

Note: All partitions must have the same size for send/recv array

References lama::LAMAArray< T >::clear(), LAMA_ASSERT_DEBUG, and LAMA_ASSERT_ERROR.

Referenced by lama::DenseMatrix< T >::matrixTimesVectorImpl().

template<typename T >
auto_ptr< SyncToken > lama::MPICommunicator::shiftAsyncImpl ( newvals[],
const PartitionId  source,
const T  oldVals[],
const PartitionId  dest,
const IndexType  size 
) const [private]

References getRank(), LAMA_ASSERT_ERROR, startrecv(), and startsend().

Referenced by shiftAsync().

template<typename T >
IndexType lama::MPICommunicator::shiftImpl ( newvals[],
const IndexType  newSize,
const PartitionId  source,
const T  oldVals[],
const IndexType  oldSize,
const PartitionId  dest 
) const [private]

References getRank(), LAMA_ASSERT_ERROR, LAMA_MPICALL, and selectMPIComm().

Referenced by shift().

template<typename T >
MPI_Request lama::MPICommunicator::startrecv ( T *  buffer,
int  count,
int  source 
) const
template<typename T >
MPI_Request lama::MPICommunicator::startsend ( const T *  buffer,
int  count,
int  target 
) const
float lama::MPICommunicator::sum ( const float  value) const [virtual]

Sum operations sum up one single value from each partition to a global value.

Parameters:
[in]valuevalue on the calling partition
Returns:
global value, available for all partitions.

Implements lama::Communicator.

References sumImpl().

Referenced by sumImpl().

double lama::MPICommunicator::sum ( const double  value) const [virtual]

Implements lama::Communicator.

References sumImpl().

int lama::MPICommunicator::sum ( const int  value) const [virtual]

Implements lama::Communicator.

References sumImpl().

size_t lama::MPICommunicator::sum ( const size_t  value) const [virtual]

Implements lama::Communicator.

template<typename T >
T lama::MPICommunicator::sumImpl ( myVal) const [private]

References LAMA_MPICALL, selectMPIComm(), and sum().

Referenced by sum().

void lama::MPICommunicator::swap ( double  val[],
const IndexType  n,
const PartitionId  partner 
) const [virtual]

This routine swaps an array with a partner processor.

Implements lama::Communicator.

References swapImpl().

void lama::MPICommunicator::swap ( float  val[],
const IndexType  n,
const PartitionId  partner 
) const [virtual]

Implements lama::Communicator.

References swapImpl().

void lama::MPICommunicator::swap ( int  val[],
const IndexType  n,
const PartitionId  partner 
) const [virtual]

Implements lama::Communicator.

References swapImpl().

template<typename T >
void lama::MPICommunicator::swapImpl ( val[],
const IndexType  n,
PartitionId  partner 
) const [private]
void lama::MPICommunicator::synchronize ( ) const [virtual]

Barrier synchronization between all processors.

Implements lama::Communicator.

References LAMA_MPICALL, and selectMPIComm().

template<typename T >
template LAMA_DLL_IMPORTEXPORT void lama::Communicator::updateHalo ( LAMAArray< T > &  haloValues,
const LAMAArray< T > &  localValues,
const Halo halo 
) const [inherited]

Update of halo array via Halo object.

Parameters:
[out]haloValueswill contain the non-local values from other processors
[in]localValuesis the local part of the array on each processor
[in]halois the Halo object containing all information about exchange

This method is not virtual but will use the pure virtual methods of base classes.

< temporary array for send communication

References lama::CommunicationPlan::allocated(), lama::Communicator::exchangeByPlan(), lama::Communicator::gather(), lama::Halo::getProvidesIndexes(), lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), lama::Communicator::getSize(), LAMA_ASSERT_ERROR, LAMA_REGION, and lama::CommunicationPlan::size().

void lama::MPICommunicator::writeAt ( std::ostream &  stream) const [virtual]

Override virtual method of base class Printable.

Reimplemented from lama::Communicator.

References mRank, and mSize.


Friends And Related Function Documentation

friend class MPICommunicatorManager [friend]

Field Documentation

const int lama::MPICommunicator::defaultTag = 1 [static, private]

Referenced by send(), startrecv(), startsend(), and swapImpl().

Referenced by MPICommunicator(), and selectMPIComm().

std::string lama::Communicator::mCommunicatorType [protected, inherited]

Referenced by MPICommunicator().

const boost::thread lama::MPICommunicator::mMainThread [private]

Referenced by selectMPIComm().


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