LAMA
|
A communication plan describes a schedule of data to send or data to receive from other processors. More...
#include <CommunicationPlan.hpp>
Data Structures | |
struct | Entry |
Record that is used for the entries of the communication plan. More... | |
Public Member Functions | |
CommunicationPlan () | |
void | clear () |
Clear an existing object for communication plan. | |
CommunicationPlan (const LAMAArray< IndexType > &quantities, bool compressFlag=true) | |
Construct a communication plan by quantity for each partition. | |
CommunicationPlan (const PartitionId noPartitions, const std::vector< PartitionId > &owners, bool compressFlag=true) | |
Construct a communication plan by array of owners; quantity is computed by counting values for each partition. | |
CommunicationPlan (const CommunicationPlan &other, const IndexType quantities[]) | |
Construct a communication plan by an existing one. | |
CommunicationPlan (const CommunicationPlan &other, const IndexType n) | |
Construct a communication plan by an existing one where each entry is multiplied by same factor. | |
virtual | ~CommunicationPlan () |
Destructor. | |
void | allocate (const LAMAArray< IndexType > &quantities, bool compressFlag=true) |
Allocate a communication plan by quantity for each partition. | |
void | allocate (const PartitionId noPartitions, const std::vector< PartitionId > &owners, bool compressFlag=true) |
void | allocateTranspose (const CommunicationPlan &plan, const Communicator &comm) |
Allocate a communication plan as the transposed plan of another communication plan. | |
bool | allocated () const |
void | compress () |
Compress a communication plan to remove all entries where quantity is zero. | |
bool | compressed () const |
Predicate to ask whether a communication plan is already compressed. | |
PartitionId | size () const |
Query the number of entries. | |
IndexType | totalQuantity () const |
Get the sum of all quantities, is total amount of data to send or receive. | |
IndexType | maxQuantity () const |
Get the maximal quantity of any partition. | |
const Entry & | operator[] (const PartitionId index) const |
Index operator. | |
void | writeAt (std::ostream &stream) const |
Override default implementation of base class Printable. | |
Private Member Functions | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
bool | mAllocated |
true, if plan has been allocated | |
bool | mCompressed |
true, if no entry has quantity 0 | |
std::vector< Entry > | mEntries |
vector of entries | |
IndexType | mQuantity |
sum of quantities for all entries |
A communication plan describes a schedule of data to send or data to receive from other processors.
A communication plan contains a certain number of entries where one entry contains the partner (source or target) of the communication and the number of elements to send or to receive.
Note: the number of entries can be smaller than the number of available partitions/processors. A compressed plan will not contain any entry where the number of elements is zero.
lama::CommunicationPlan::CommunicationPlan | ( | const LAMAArray< IndexType > & | quantities, |
bool | compressFlag = true |
||
) |
Construct a communication plan by quantity for each partition.
quantities | vector of non-negative values, size is number of partitions |
compressFlag | if true zero entries are removed |
std:vector<IndexType> quantities; quantities.push_back(0); quantities.push_back(3); quantities.push_back(4); CommunicationPlan plan( quantities );
References allocate().
lama::CommunicationPlan::CommunicationPlan | ( | const PartitionId | noPartitions, |
const std::vector< PartitionId > & | owners, | ||
bool | compressFlag = true |
||
) |
Construct a communication plan by array of owners; quantity is computed by counting values for each partition.
References allocate().
lama::CommunicationPlan::CommunicationPlan | ( | const CommunicationPlan & | other, |
const IndexType | quantities[] | ||
) |
Construct a communication plan by an existing one.
References allocated(), compressed(), LAMA_ASSERT_ERROR, mAllocated, mCompressed, mEntries, mQuantity, lama::CommunicationPlan::Entry::offset, and lama::CommunicationPlan::Entry::quantity.
lama::CommunicationPlan::CommunicationPlan | ( | const CommunicationPlan & | other, |
const IndexType | n | ||
) |
Construct a communication plan by an existing one where each entry is multiplied by same factor.
[in] | other | is the original communication plan |
[in] | n | is the multiplicator (n >= 1) |
The new communication plan can be used to send / receive whole arrays of size n instead of single values.
References allocated(), compressed(), LAMA_ASSERT_EQUAL_DEBUG, LAMA_ASSERT_ERROR, mAllocated, mCompressed, mEntries, mQuantity, lama::CommunicationPlan::Entry::offset, and lama::CommunicationPlan::Entry::quantity.
lama::CommunicationPlan::~CommunicationPlan | ( | ) | [virtual] |
Destructor.
void lama::CommunicationPlan::allocate | ( | const LAMAArray< IndexType > & | quantities, |
bool | compressFlag = true |
||
) |
Allocate a communication plan by quantity for each partition.
quantities | vector of non-negative values, size is number of partitions |
compressFlag | if true zero-entries are removed. |
CommunicationPlan plan; std:vector<IndexType> quantities; quantities.push_back( 0 ); quantities.push_back( 3 ); quantities.push_back( 4 ); plan.allocate( quantities );
References compress(), mAllocated, mEntries, mQuantity, lama::CommunicationPlan::Entry::offset, lama::CommunicationPlan::Entry::partitionId, lama::CommunicationPlan::Entry::quantity, and lama::_LAMAArray::size().
Referenced by allocateTranspose(), lama::HaloBuilder::build(), and CommunicationPlan().
void lama::CommunicationPlan::allocate | ( | const PartitionId | noPartitions, |
const std::vector< PartitionId > & | owners, | ||
bool | compressFlag = true |
||
) |
References compress(), LAMA_ASSERT, mAllocated, mEntries, and mQuantity.
bool lama::CommunicationPlan::allocated | ( | ) | const |
References mAllocated.
Referenced by allocateTranspose(), CommunicationPlan(), lama::PGASCommunicator::exchangeByPlanAsyncImpl(), lama::MPICommunicator::exchangeByPlanAsyncImpl(), lama::MPICommunicator::exchangeByPlanImpl(), maxQuantity(), lama::Communicator::updateHalo(), and lama::Communicator::updateHaloAsync().
void lama::CommunicationPlan::allocateTranspose | ( | const CommunicationPlan & | plan, |
const Communicator & | comm | ||
) |
Allocate a communication plan as the transposed plan of another communication plan.
processor[p].plan->entry[q].quantity = processor[q].entry[p].quantity
References lama::Communicator::all2all(), allocate(), allocated(), lama::WriteAccess< T >::get(), lama::Communicator::getSize(), LAMA_ASSERT, lama::WriteAccess< T >::release(), size(), and lama::Communicator::synchronize().
Referenced by lama::HaloBuilder::build().
void lama::CommunicationPlan::clear | ( | ) |
Clear an existing object for communication plan.
References mAllocated, mCompressed, mEntries, and mQuantity.
Referenced by lama::Halo::clear().
void lama::CommunicationPlan::compress | ( | ) |
Compress a communication plan to remove all entries where quantity is zero.
References mCompressed, mEntries, mQuantity, and size().
Referenced by allocate().
bool lama::CommunicationPlan::compressed | ( | ) | const |
Predicate to ask whether a communication plan is already compressed.
References mCompressed.
Referenced by CommunicationPlan().
lama::CommunicationPlan::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
Get the maximal quantity of any partition.
This method is useful for the allocation of send or receive buffers that will be used for all communications.
References allocated(), LAMA_ASSERT, lama::max(), mEntries, and size().
const CommunicationPlan::Entry & lama::CommunicationPlan::operator[] | ( | const PartitionId | index | ) | const [inline] |
PartitionId lama::CommunicationPlan::size | ( | ) | const [inline] |
Query the number of entries.
Attention: keep in mind that entries with a zero quantity are deleted and that this method returns a value that might be smaller than the original number of partitions.
References mEntries.
Referenced by allocateTranspose(), lama::HaloBuilder::build(), compress(), lama::PGASCommunicator::exchangeByPlanAsyncImpl(), lama::MPICommunicator::exchangeByPlanAsyncImpl(), lama::NoCommunicator::exchangeByPlanImpl(), lama::MPICommunicator::exchangeByPlanImpl(), maxQuantity(), lama::Communicator::updateHalo(), and lama::Communicator::updateHaloAsync().
IndexType lama::CommunicationPlan::totalQuantity | ( | ) | const [inline] |
Get the sum of all quantities, is total amount of data to send or receive.
References mQuantity.
Referenced by lama::HaloBuilder::build(), lama::Redistributor::buildRowPlans(), lama::Redistributor::buildVPlans(), lama::Communicator::exchangeByPlan(), lama::Communicator::exchangeByPlanAsync(), lama::StorageMethods< T >::exchangeHaloCSR(), lama::Halo::getHaloSize(), lama::Halo::isEmpty(), and lama::Redistributor::Redistributor().
void lama::CommunicationPlan::writeAt | ( | std::ostream & | stream | ) | const [virtual] |
bool lama::CommunicationPlan::mAllocated [private] |
true, if plan has been allocated
Referenced by allocate(), allocated(), clear(), and CommunicationPlan().
bool lama::CommunicationPlan::mCompressed [private] |
true, if no entry has quantity 0
Referenced by clear(), CommunicationPlan(), compress(), and compressed().
std::vector<Entry> lama::CommunicationPlan::mEntries [private] |
vector of entries
Referenced by allocate(), clear(), CommunicationPlan(), compress(), maxQuantity(), size(), and writeAt().
IndexType lama::CommunicationPlan::mQuantity [private] |
sum of quantities for all entries
Referenced by allocate(), clear(), CommunicationPlan(), compress(), totalQuantity(), and writeAt().