LAMA
lama::CommunicationPlan Class Reference

A communication plan describes a schedule of data to send or data to receive from other processors. More...

#include <CommunicationPlan.hpp>

Inheritance diagram for lama::CommunicationPlan:

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 Entryoperator[] (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< EntrymEntries
 vector of entries
IndexType mQuantity
 sum of quantities for all entries

Detailed Description

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.


Constructor & Destructor Documentation

lama::CommunicationPlan::CommunicationPlan ( const LAMAArray< IndexType > &  quantities,
bool  compressFlag = true 
)

Construct a communication plan by quantity for each partition.

Parameters:
quantitiesvector of non-negative values, size is number of partitions
compressFlagif 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().

Construct a communication plan by an existing one where each entry is multiplied by same factor.

Parameters:
[in]otheris the original communication plan
[in]nis 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.


Member Function Documentation

void lama::CommunicationPlan::allocate ( const LAMAArray< IndexType > &  quantities,
bool  compressFlag = true 
)

Allocate a communication plan by quantity for each partition.

Parameters:
quantitiesvector of non-negative values, size is number of partitions
compressFlagif 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 
)

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().

Clear an existing object for communication plan.

References mAllocated, mCompressed, mEntries, and mQuantity.

Referenced by lama::Halo::clear().

Compress a communication plan to remove all entries where quantity is zero.

References mCompressed, mEntries, mQuantity, and size().

Referenced by allocate().

Predicate to ask whether a communication plan is already compressed.

References mCompressed.

Referenced by CommunicationPlan().

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]

Index operator.

Parameters:
[in]idis an index value, 0 <= id < size()

Attention: keep in mind that size() might be smaller than the number of partitions involved.

Query the number of entries.

Returns:
number of entries stored in the communication plan.

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().

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

Override default implementation of base class Printable.

Reimplemented from Printable.

References mEntries, and mQuantity.


Field Documentation

true, if plan has been allocated

Referenced by allocate(), allocated(), clear(), and CommunicationPlan().

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().

sum of quantities for all entries

Referenced by allocate(), clear(), CommunicationPlan(), compress(), totalQuantity(), and writeAt().


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