LAMA
|
Communicator class that implements communication and data exchange via MPI. More...
#include <MPICommunicator.hpp>
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< SyncToken > | exchangeByPlanAsync (int *const recvData, const CommunicationPlan &recvPlan, const int *const sendData, const CommunicationPlan &sendPlan) const |
virtual std::auto_ptr< SyncToken > | exchangeByPlanAsync (float *const recvData, const CommunicationPlan &recvPlan, const float *const sendData, const CommunicationPlan &sendPlan) const |
Exchange of float values. | |
virtual std::auto_ptr< SyncToken > | exchangeByPlanAsync (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< SyncToken > | shiftAsync (double newVals[], const double oldVals[], const IndexType size, const int direction) const |
Asynchronous version of shift. | |
virtual std::auto_ptr< SyncToken > | shiftAsync (float newVals[], const float oldVals[], const IndexType size, const int direction) const |
virtual std::auto_ptr< SyncToken > | shiftAsync (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< SyncToken > | exchangeByPlanAsync (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< SyncToken > | updateHaloAsync (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< SyncToken > | shiftAsync (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< SyncToken > | defaultShiftAsync (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 > | |
T | sumImpl (T myVal) const |
template<typename T > | |
T | maxval (T myVal) const |
template<typename T > | |
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< SyncToken > | shiftAsyncImpl (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< SyncToken > | exchangeByPlanAsyncImpl (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 |
Communicator class that implements communication and data exchange via MPI.
MPI_Init is called in the constructor, MPI_Finalize is called in the destructor.
enum lama::Communicator::ThreadSafetyLevel [inherited] |
Enumeration type for supported thread safety levels.
lama::MPICommunicator::~MPICommunicator | ( | ) | [virtual] |
References LAMA_MPICALL, and mExternInitialization.
lama::MPICommunicator::MPICommunicator | ( | int & | argc, |
char **& | argv | ||
) | [private] |
void lama::MPICommunicator::all2all | ( | int * | recvValues, |
const int * | sendValues | ||
) | const [virtual] |
All-to-all exchange of an integer value between all processors.
[out] | recvValues | will contain one value from each processor |
[in] | sendValues | must 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 LAMA_DLL_IMPORTEXPORT auto_ptr< SyncToken > lama::Communicator::defaultShiftAsync | ( | T | 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.
[out] | recvData | buffer for data received from other processors |
[in] | recvPlan | number of elements and offsets for receiving |
[in] | sendData | buffer for data to send to other processors |
[in] | sendPlan | contains 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] |
void lama::MPICommunicator::exchangeByPlan | ( | double *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const double *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [virtual] |
void lama::Communicator::exchangeByPlan | ( | LAMAArray< T > & | recvArray, |
const CommunicationPlan & | recvPlan, | ||
const LAMAArray< T > & | sendArray, | ||
const CommunicationPlan & | sendPlan | ||
) | const [inherited] |
References lama::WriteAccess< T >::clear(), lama::Communicator::exchangeByPlan(), lama::ReadAccess< T >::get(), lama::WriteAccess< T >::get(), lama::Communicator::getCommunicationContext(), LAMA_ASSERT_ERROR, lama::WriteAccess< T >::resize(), lama::_LAMAArray::size(), and lama::CommunicationPlan::totalQuantity().
std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync | ( | int *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const int *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [virtual] |
Implements lama::Communicator.
References exchangeByPlanAsyncImpl().
std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync | ( | float *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const float *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [virtual] |
std::auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsync | ( | double *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const double *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [virtual] |
std::auto_ptr< SyncToken > lama::Communicator::exchangeByPlanAsync | ( | LAMAArray< T > & | recvArray, |
const CommunicationPlan & | recvPlan, | ||
const LAMAArray< T > & | sendArray, | ||
const CommunicationPlan & | sendPlan | ||
) | const [inherited] |
auto_ptr< SyncToken > lama::MPICommunicator::exchangeByPlanAsyncImpl | ( | T *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const T *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [private] |
References lama::CommunicationPlan::allocated(), LAMA_ASSERT_DEBUG, LAMA_ASSERT_ERROR, mRank, lama::MPISyncToken::pushRequest(), lama::CommunicationPlan::size(), startrecv(), and startsend().
Referenced by exchangeByPlanAsync().
void lama::MPICommunicator::exchangeByPlanImpl | ( | T *const | recvData, |
const CommunicationPlan & | recvPlan, | ||
const T *const | sendData, | ||
const CommunicationPlan & | sendPlan | ||
) | const [private] |
References lama::CommunicationPlan::allocated(), LAMA_ASSERT_DEBUG, LAMA_ASSERT_ERROR, LAMA_MPICALL, LAMA_REGION, mRank, send(), lama::CommunicationPlan::size(), and startrecv().
Referenced by exchangeByPlan().
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] |
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.
[out] | allvals | values that I receive (size must be sum(sizes) ) |
[in] | n | number of elements in vector val |
[in] | root | processor with values for all processors |
[in] | myvals | values for all processors |
[in] | sizes | number 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().
void lama::MPICommunicator::gatherImpl | ( | T | allvals[], |
const IndexType | n, | ||
const PartitionId | root, | ||
const T | myvals[] | ||
) | const [private] |
References getSize(), LAMA_ASSERT_DEBUG, LAMA_MPICALL, and selectMPIComm().
Referenced by gather().
void lama::MPICommunicator::gatherImpl | ( | T | allvals[], |
const IndexType | n, | ||
const PartitionId | root, | ||
const T | myvals[], | ||
const IndexType | sizes[] | ||
) | const [private] |
References getRank(), getSize(), LAMA_ASSERT_ERROR, LAMA_MPICALL, and selectMPIComm().
ContextPtr lama::MPICommunicator::getCommunicationContext | ( | ) | const [protected, virtual] |
getter for Context needed for Communication
Implements lama::Communicator.
References lama::ContextFactory::getContext(), and lama::Context::Host.
int lama::MPICommunicator::getCount | ( | MPI_Status & | status | ) | const [inline, private] |
References LAMA_MPICALL.
void lama::Communicator::getGrid2Rank | ( | PartitionId | pos[2], |
const PartitionId | procgrid[2] | ||
) | const [inherited] |
References lama::Communicator::getRank(), lama::Communicator::getSize(), and LAMA_ASSERT_ERROR.
void lama::Communicator::getGrid3Rank | ( | PartitionId | pos[3], |
const PartitionId | procgrid[3] | ||
) | const [inherited] |
References lama::Communicator::getRank(), lama::Communicator::getSize(), and LAMA_ASSERT_ERROR.
MPI_Datatype lama::MPICommunicator::getMPI2Type< int, int > | ( | ) | [inline, static, private] |
References LAMA_THROWEXCEPTION.
MPI_Comm lama::MPICommunicator::getMPIComm | ( | ) | const |
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.
[in] | pos | is the distance to the neighbor (also negative) |
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().
PartitionId lama::MPICommunicator::getRank | ( | ) | const [virtual] |
Id of this partitinon.
Implements lama::Communicator.
References mRank.
Referenced by gatherImpl(), scatterImpl(), shiftAsyncImpl(), and shiftImpl().
PartitionId lama::MPICommunicator::getSize | ( | ) | const [virtual] |
Number of partitions.
Implements lama::Communicator.
References mSize.
Referenced by gatherImpl(), scatterImpl(), shift(), and shiftAsync().
Communicator::ThreadSafetyLevel lama::MPICommunicator::getThreadSafetyLevel | ( | ) | const [virtual] |
Implements lama::Communicator.
References mThreadSafetyLevel.
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.
[out] | userProcArray | specifies the user processor array. |
Referenced by lama::Communicator::factorize2(), and lama::Communicator::factorize3().
bool lama::MPICommunicator::isEqual | ( | const Communicator & | other | ) | const [virtual] |
lama::MPICommunicator::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
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.
[in,out] | val | is a value on each processor, only out for root with maximal value |
[in,out] | location | is 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().
void lama::MPICommunicator::maxlocImpl | ( | T & | val, |
int & | location, | ||
PartitionId | root | ||
) | const [private] |
References mRank, and selectMPIComm().
Referenced by maxloc().
T lama::MPICommunicator::maxval | ( | T | 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().
T lama::MPICommunicator::minval | ( | T | myVal | ) | const [private] |
References LAMA_MPICALL, and selectMPIComm().
Referenced by min().
bool lama::Communicator::operator!= | ( | const Communicator & | other | ) | const [inherited] |
References lama::Communicator::isEqual().
bool lama::Communicator::operator== | ( | const Communicator & | other | ) | const [inherited] |
Equality operator for two communicators.
[in] | other | communicator for comparison |
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] |
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.
[out] | myvals | values that I receive |
[in] | n | number of elements in vector val |
[in] | root | processor with values for all processors |
[in] | allvals | values for all processors (size must be sum(sizes) ) |
[in] | sizes | number 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().
void lama::MPICommunicator::scatterImpl | ( | T | myvals[], |
const IndexType | n, | ||
const PartitionId | root, | ||
const T | allvals[] | ||
) | const [private] |
References getSize(), LAMA_ASSERT_DEBUG, LAMA_MPICALL, and selectMPIComm().
Referenced by scatter().
void lama::MPICommunicator::scatterImpl | ( | T | myvals[], |
const IndexType | n, | ||
const PartitionId | root, | ||
const T | allvals[], | ||
const IndexType | sizes[] | ||
) | const [private] |
References getRank(), getSize(), LAMA_ASSERT_ERROR, LAMA_MPICALL, and selectMPIComm().
MPI_Comm lama::MPICommunicator::selectMPIComm | ( | ) | const [inline, private] |
References mComm, mCommTask, mMainThread, mThreadSafetyLevel, and lama::Communicator::Multiple.
Referenced by all2all(), bcast(), gather(), gatherImpl(), maxlocImpl(), maxval(), minval(), scatterImpl(), send(), shiftImpl(), startrecv(), startsend(), sumImpl(), swapImpl(), and synchronize().
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.
[out] | newVals | array with data this partition get from neighbored partition |
[in] | newSize | allocated size of array newVals |
[in] | oldVals | array with data this partition sends to neighbored partition |
[in] | oldSize | number of elements of array oldVals that will be sent |
[in] | direction | specifies the neighbored partitions to send and receive |
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] |
Implements lama::Communicator.
References lama::Communicator::getNeighbor(), getSize(), lama::Communicator::shift0(), and shiftImpl().
IndexType lama::MPICommunicator::shift | ( | int | newVals[], |
const IndexType | newSize, | ||
const int | oldVals[], | ||
const IndexType | oldSize, | ||
const int | direction | ||
) | const [virtual] |
Implements lama::Communicator.
References lama::Communicator::getNeighbor(), getSize(), lama::Communicator::shift0(), and shiftImpl().
void lama::Communicator::shift | ( | LAMAArray< T > & | recv, |
const LAMAArray< T > & | send, | ||
const int | direction | ||
) | const [inherited] |
Shift on LAMA arrays.
[in] | recv | array to receive for this partition |
[out] | send | array to send from this partition |
[in] | direction | number 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 LAMA_DLL_IMPORTEXPORT IndexType lama::Communicator::shift0 | ( | T | 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] |
Reimplemented from lama::Communicator.
References lama::Communicator::defaultShiftAsync(), lama::Communicator::getNeighbor(), getSize(), and shiftAsyncImpl().
auto_ptr< SyncToken > lama::MPICommunicator::shiftAsync | ( | int | newVals[], |
const int | oldVals[], | ||
const IndexType | size, | ||
const int | direction | ||
) | const [virtual] |
Reimplemented from lama::Communicator.
References lama::Communicator::defaultShiftAsync(), lama::Communicator::getNeighbor(), getSize(), and shiftAsyncImpl().
auto_ptr< SyncToken > lama::Communicator::shiftAsync | ( | LAMAArray< T > & | recvArray, |
const LAMAArray< T > & | sendArray, | ||
const int | direction | ||
) | const [inherited] |
Asychronous shift on LAMA arrays.
[out] | recvArray | array to receive for this partition |
[in] | sendArray | array to send from this partition |
[in] | direction | number 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().
auto_ptr< SyncToken > lama::MPICommunicator::shiftAsyncImpl | ( | T | 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().
IndexType lama::MPICommunicator::shiftImpl | ( | T | 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().
MPI_Request lama::MPICommunicator::startrecv | ( | T * | buffer, |
int | count, | ||
int | source | ||
) | const |
References defaultTag, LAMA_MPICALL, and selectMPIComm().
Referenced by exchangeByPlanAsyncImpl(), exchangeByPlanImpl(), and shiftAsyncImpl().
MPI_Request lama::MPICommunicator::startsend | ( | const T * | buffer, |
int | count, | ||
int | target | ||
) | const |
References defaultTag, LAMA_MPICALL, and selectMPIComm().
Referenced by exchangeByPlanAsyncImpl(), and shiftAsyncImpl().
float lama::MPICommunicator::sum | ( | const float | value | ) | const [virtual] |
Sum operations sum up one single value from each partition to a global value.
[in] | value | value on the calling partition |
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.
T lama::MPICommunicator::sumImpl | ( | T | 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().
void lama::MPICommunicator::swapImpl | ( | T | val[], |
const IndexType | n, | ||
PartitionId | partner | ||
) | const [private] |
References defaultTag, LAMA_ASSERT_ERROR, LAMA_MPICALL, mRank, and selectMPIComm().
Referenced by swap().
void lama::MPICommunicator::synchronize | ( | ) | const [virtual] |
Barrier synchronization between all processors.
Implements lama::Communicator.
References LAMA_MPICALL, and selectMPIComm().
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.
[out] | haloValues | will contain the non-local values from other processors |
[in] | localValues | is the local part of the array on each processor |
[in] | halo | is 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().
template LAMA_DLL_IMPORTEXPORT auto_ptr< SyncToken > lama::Communicator::updateHaloAsync | ( | LAMAArray< T > & | haloValues, |
const LAMAArray< T > & | localValues, | ||
const Halo & | halo | ||
) | const [inherited] |
Asynchronous update of halo array via Halo object.
References lama::CommunicationPlan::allocated(), lama::Communicator::exchangeByPlanAsync(), 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.
friend class MPICommunicatorManager [friend] |
const int lama::MPICommunicator::defaultTag = 1 [static, private] |
Referenced by send(), startrecv(), startsend(), and swapImpl().
MPI_Comm lama::MPICommunicator::mComm [private] |
Referenced by getMPIComm(), isEqual(), MPICommunicator(), and selectMPIComm().
MPI_Comm lama::MPICommunicator::mCommTask [private] |
Referenced by MPICommunicator(), and selectMPIComm().
std::string lama::Communicator::mCommunicatorType [protected, inherited] |
MPI_Comm lama::MPICommunicator::mCommWorld [private] |
Referenced by MPICommunicator().
bool lama::MPICommunicator::mExternInitialization [private] |
Referenced by MPICommunicator(), and ~MPICommunicator().
const boost::thread lama::MPICommunicator::mMainThread [private] |
Referenced by selectMPIComm().
int lama::MPICommunicator::mRank [private] |
Referenced by exchangeByPlanAsyncImpl(), exchangeByPlanImpl(), getRank(), maxlocImpl(), MPICommunicator(), swapImpl(), and writeAt().
int lama::MPICommunicator::mSize [private] |
Referenced by gather(), getSize(), MPICommunicator(), and writeAt().
Referenced by getThreadSafetyLevel(), MPICommunicator(), and selectMPIComm().