LAMA
|
Abstract base class for a one-dimensional distribution. More...
#include <Distribution.hpp>
Public Member Functions | |
Distribution (const IndexType globalSize, const CommunicatorPtr communicator) | |
Constructor for a distribution. | |
Distribution (const IndexType globalSize) | |
Same as Distribution( globalSize, NoCommunicator() ) | |
virtual | ~Distribution () |
Destructor of distribution. | |
const Communicator & | getCommunicator () const |
Getter routine for the communicator of the distribution. | |
CommunicatorPtr | getCommunicatorPtr () const |
Getter routine for the communicator as shared pointer. | |
PartitionId | getNumPartitions () const |
Query for the number of partitions onto which the distribution is done. | |
bool | isReplicated () const |
Query whether the distribution is a replication. | |
virtual bool | isLocal (const IndexType index) const =0 |
Query if the given global index is local for the calling rank (e.g. | |
IndexType | getGlobalSize () const |
Getter for the global number of elements that are distributed. | |
virtual IndexType | getLocalSize () const =0 |
This method returns the number of local elements on the calling processor. | |
virtual IndexType | local2global (const IndexType localIndex) const =0 |
Abstract method that translates a local index back to a global index. | |
virtual IndexType | global2local (const IndexType globalIndex) const =0 |
Abstract method that translates a global index into a local index. | |
virtual void | computeOwners (const std::vector< IndexType > &requiredIndexes, std::vector< PartitionId > &owners) const |
Compute ownership for required indexes. | |
virtual bool | isEqual (const Distribution &other) const =0 |
virtual void | writeAt (std::ostream &stream) const |
This method writes info about the distribution into an output stream. | |
bool | operator== (const Distribution &other) const |
Check for equality of two distributions. | |
bool | operator!= (const Distribution &other) const |
Check for inequality. | |
template<typename T1 , typename T2 > | |
void | replicate (T1 *allValues, const T2 *localValues) const |
template<typename T1 , typename T2 > | |
void | replicateN (T1 *allValues, const T2 *localValues, const IndexType n) const |
template<typename T > | |
void | replicate (T *allValues, const IndexType *allOffsets, const T *localValues) const |
virtual void | printDistributionVector (std::string name) const =0 |
Master process prints out the distribution vector to file named "name.part". | |
Protected Attributes | |
IndexType | mGlobalSize |
CommunicatorPtr | mCommunicator |
Private Member Functions | |
Distribution () | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) |
Abstract base class for a one-dimensional distribution.
A distribution specifies a mapping from a global range to the partitions of a Communicator.
Default and copy constructor are not available for this class (noncopyable).
lama::Distribution::Distribution | ( | const IndexType | globalSize, |
const CommunicatorPtr | communicator | ||
) |
Constructor for a distribution.
[in] | globalSize | is the number of elements to distribute |
[in] | communicator | specifies the partitions onto which the elements are distributed |
References LAMA_THROWEXCEPTION, and mCommunicator.
lama::Distribution::Distribution | ( | const IndexType | globalSize | ) |
Same as Distribution( globalSize, NoCommunicator() )
[in] | globalSize | is the number of elements to distribute |
References mGlobalSize.
lama::Distribution::~Distribution | ( | ) | [virtual] |
Destructor of distribution.
References mCommunicator, and mGlobalSize.
lama::Distribution::Distribution | ( | ) | [private] |
void lama::Distribution::computeOwners | ( | const std::vector< IndexType > & | requiredIndexes, |
std::vector< PartitionId > & | owners | ||
) | const [virtual] |
Compute ownership for required indexes.
The default solution is to communicate required indexes around all partitions and each partition marks indexes with its id if it is local. If ownership can be computed without communication, this routine might be implemented more efficiently.
Reimplemented in lama::GenBlockDistribution, lama::CyclicDistribution, and lama::BlockDistribution.
References mCommunicator.
Referenced by lama::DenseMatrix< T >::computeOwners().
const Communicator & lama::Distribution::getCommunicator | ( | ) | const |
Getter routine for the communicator of the distribution.
References mCommunicator.
Referenced by lama::HaloBuilder::build(), lama::Communicator::computeOwners(), lama::DenseMatrix< T >::DenseMatrix(), lama::MatrixCreator< T >::fillRandom(), lama::DenseMatrix< T >::getValue(), lama::SparseMatrix< T >::getValue(), lama::GenBlockDistribution::isEqual(), lama::SpecializedJacobi::iterateTyped(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), lama::DenseMatrix< T >::matrixTimesVectorImpl(), lama::Redistributor::Redistributor(), replicate(), lama::StorageMethods< T >::replicateCSR(), and replicateN().
Getter routine for the communicator as shared pointer.
References mCommunicator.
Referenced by lama::DenseMatrix< T >::invert().
IndexType lama::Distribution::getGlobalSize | ( | ) | const [inline] |
Getter for the global number of elements that are distributed.
References mGlobalSize.
Referenced by lama::BlockDistribution::BlockDistribution(), lama::MatrixStorage< T >::buildHalo(), lama::GenBlockDistribution::GenBlockDistribution(), lama::GeneralDistribution::GeneralDistribution(), lama::NoDistribution::isEqual(), lama::BlockDistribution::isEqual(), lama::CyclicDistribution::isEqual(), lama::MatrixStorage< T >::joinHalo(), lama::_MatrixStorage::localize(), lama::DenseMatrix< T >::localize(), lama::MatrixStorage< T >::localize(), lama::StorageMethods< T >::localizeCSR(), operator==(), lama::Redistributor::Redistributor(), replicate(), lama::MatrixStorage< T >::replicate(), lama::replicate(), lama::StorageMethods< T >::replicateCSR(), replicateN(), lama::GenBlockDistribution::setOffsets(), lama::MatrixStorage< T >::splitHalo(), and lama::Vector::Vector().
virtual IndexType lama::Distribution::getLocalSize | ( | ) | const [pure virtual] |
This method returns the number of local elements on the calling processor.
Implemented in lama::GenBlockDistribution, lama::GeneralDistribution, lama::BlockDistribution, lama::CyclicDistribution, and lama::NoDistribution.
Referenced by lama::DenseMatrix< T >::DenseMatrix(), lama::MatrixCreator< T >::fillRandom(), lama::DenseMatrix< T >::localize(), lama::MatrixStorage< T >::localize(), lama::StorageMethods< T >::localizeCSR(), lama::MatrixStorage< T >::redistribute(), lama::Redistributor::Redistributor(), replicate(), lama::MatrixStorage< T >::replicate(), lama::replicate(), lama::StorageMethods< T >::replicateCSR(), replicateN(), lama::StorageMethods< T >::splitCSR(), and lama::MatrixStorage< T >::splitHalo().
Query for the number of partitions onto which the distribution is done.
References LAMA_ASSERT, and mCommunicator.
Referenced by lama::HaloBuilder::build(), lama::DenseMatrix< T >::DenseMatrix(), lama::MatrixCreator< T >::fillRandom(), lama::DenseMatrix< T >::getValue(), lama::DenseMatrix< T >::matrixTimesVectorImpl(), and lama::LUSolver::solve().
virtual IndexType lama::Distribution::global2local | ( | const IndexType | globalIndex | ) | const [pure virtual] |
Abstract method that translates a global index into a local index.
[in] | globalIndex | with 0 <= globalIndex < getGlobalSize |
This method must be implemented by all base classes. It should throw an exception if the argument is not in the valid range.
Implemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
Referenced by lama::HaloBuilder::build(), lama::GeneralDistribution::GeneralDistribution(), lama::DenseMatrix< T >::getValue(), lama::SparseMatrix< T >::getValue(), lama::Redistributor::Redistributor(), and lama::StorageMethods< T >::splitCSR().
virtual bool lama::Distribution::isEqual | ( | const Distribution & | other | ) | const [pure virtual] |
Implemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
Referenced by operator==().
virtual bool lama::Distribution::isLocal | ( | const IndexType | index | ) | const [pure virtual] |
Query if the given global index is local for the calling rank (e.g.
process for an MPI Communicator
[in] | index | the global index to query for locality to the calling rank |
Implemented in lama::GenBlockDistribution, lama::GeneralDistribution, lama::BlockDistribution, lama::CyclicDistribution, and lama::NoDistribution.
Referenced by lama::Communicator::computeOwners(), lama::GeneralDistribution::GeneralDistribution(), lama::DenseMatrix< T >::getValue(), lama::Redistributor::Redistributor(), and lama::StorageMethods< T >::splitCSR().
bool lama::Distribution::isReplicated | ( | ) | const [inline] |
Query whether the distribution is a replication.
Referenced by lama::DenseMatrix< T >::assignSparse(), lama::SparseMatrix< T >::getRow(), lama::DenseMatrix< T >::getRow(), lama::MatrixStorage< T >::localize(), lama::DenseMatrix< T >::matrixTimesMatrix(), lama::SparseMatrix< T >::matrixTimesMatrixImpl(), lama::SparseMatrix< T >::maxDiffNorm(), lama::SparseMatrix< T >::maxDiffNormImpl(), operator==(), lama::MatrixStorage< T >::redistribute(), lama::MatrixStorage< T >::replicate(), and lama::MatrixStorage< T >::splitHalo().
lama::Distribution::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
Reimplemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
virtual IndexType lama::Distribution::local2global | ( | const IndexType | localIndex | ) | const [pure virtual] |
Abstract method that translates a local index back to a global index.
[in] | localIndex | is the local index, 0 <= localIndex < getLocalSize() |
This method must be implemented by all base classes. It should throw an exception if the argument is not in the valid range.
Implemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
Referenced by lama::SparseMatrix< T >::assignTransposeImpl(), lama::MatrixStorage< T >::joinHalo(), lama::DenseMatrix< T >::localize(), lama::StorageMethods< T >::localizeCSR(), lama::Redistributor::Redistributor(), replicate(), replicateN(), and lama::StorageMethods< T >::splitCSR().
bool lama::Distribution::operator!= | ( | const Distribution & | other | ) | const |
Check for inequality.
Even if two distributions are not equal it might be the case that the mapping of elements to partititons is the same.
bool lama::Distribution::operator== | ( | const Distribution & | other | ) | const |
Check for equality of two distributions.
As verification of same distribution can be rather expensive, the operator might return false.
Attention: The operator must be conservative and only return true if the distributions are really equal.
References getGlobalSize(), isEqual(), and isReplicated().
virtual void lama::Distribution::printDistributionVector | ( | std::string | name | ) | const [pure virtual] |
Master process prints out the distribution vector to file named "name.part".
Every row contains a single number: the index of the process, where the row is local.
Implemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
void lama::Distribution::replicate | ( | T1 * | allValues, |
const T2 * | localValues | ||
) | const |
void lama::Distribution::replicate | ( | T * | allValues, |
const IndexType * | allOffsets, | ||
const T * | localValues | ||
) | const |
template LAMA_DLL_IMPORTEXPORT void lama::Distribution::replicateN | ( | T1 * | allValues, |
const T2 * | localValues, | ||
const IndexType | n | ||
) | const |
References getCommunicator(), getGlobalSize(), getLocalSize(), lama::Communicator::getSize(), LAMA_ASSERT_EQUAL_DEBUG, local2global(), lama::Communicator::max(), and lama::Communicator::shift().
Referenced by lama::replicate().
void lama::Distribution::writeAt | ( | std::ostream & | stream | ) | const [virtual] |
This method writes info about the distribution into an output stream.
The method should be overwritten by base classes to give more specific information about the object.
Reimplemented from Printable.
Reimplemented in lama::GenBlockDistribution, lama::CyclicDistribution, lama::GeneralDistribution, lama::BlockDistribution, and lama::NoDistribution.
Referenced by lama::operator<<().
CommunicatorPtr lama::Distribution::mCommunicator [protected] |
Referenced by lama::CyclicDistribution::allGlobal2local(), lama::BlockDistribution::BlockDistribution(), lama::CyclicDistribution::computeOwners(), computeOwners(), Distribution(), lama::GenBlockDistribution::GenBlockDistribution(), lama::CyclicDistribution::getChunkInfo(), getCommunicator(), getCommunicatorPtr(), lama::GeneralDistribution::getDistributionVector(), lama::CyclicDistribution::getLocalSize(), lama::CyclicDistribution::getNumLocalChunks(), getNumPartitions(), lama::CyclicDistribution::getOwner(), lama::GenBlockDistribution::getOwner(), lama::GenBlockDistribution::isEqual(), lama::CyclicDistribution::isLocal(), lama::CyclicDistribution::local2global(), lama::NoDistribution::printDistributionVector(), lama::BlockDistribution::printDistributionVector(), lama::GeneralDistribution::printDistributionVector(), lama::CyclicDistribution::printDistributionVector(), lama::GenBlockDistribution::printDistributionVector(), lama::GenBlockDistribution::setOffsets(), lama::GeneralDistribution::writeAt(), and ~Distribution().
IndexType lama::Distribution::mGlobalSize [protected] |
Referenced by lama::CyclicDistribution::CyclicDistribution(), Distribution(), lama::GeneralDistribution::GeneralDistribution(), lama::CyclicDistribution::getChunkInfo(), lama::GeneralDistribution::getDistributionVector(), getGlobalSize(), lama::NoDistribution::getLocalSize(), lama::CyclicDistribution::getNumTotalChunks(), lama::BlockDistribution::isEqual(), lama::CyclicDistribution::isEqual(), lama::GeneralDistribution::printDistributionVector(), lama::NoDistribution::writeAt(), lama::BlockDistribution::writeAt(), lama::GeneralDistribution::writeAt(), lama::CyclicDistribution::writeAt(), lama::GenBlockDistribution::writeAt(), and ~Distribution().