LAMA
|
This class allows to create objects that handle redistributions of vector and matrices from one distribution into another distribution. More...
#include <Redistributor.hpp>
Public Member Functions | |
Redistributor (DistributionPtr targetDistribution, DistributionPtr sourceDistribution) | |
Build an object by the source and target distribution. | |
DistributionPtr | getTargetDistributionPtr () const |
Getter needed for distributions. | |
DistributionPtr | getSourceDistributionPtr () const |
IndexType | getSourceLocalSize () const |
IndexType | getTargetLocalSize () const |
template<typename ValueType > | |
void | redistribute (LAMAArray< ValueType > &targetArray, const LAMAArray< ValueType > &sourceArray) const |
Redistribution of a distributed vector as LAMAArrays. | |
template<typename ValueType > | |
void | redistributeN (LAMAArray< ValueType > &targetArray, const LAMAArray< ValueType > &sourceArray, IndexType n) const |
Redistribution of a distributed vector as LAMAArrays. | |
template<typename ValueType > | |
void | redistributeV (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetOffsets, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceOffsets) const |
Redistribution of ragged arrays. | |
IndexType | getHaloSourceSize () const |
IndexType | getHaloTargetSize () const |
template<typename ValueType > | |
void | exchangeHalo (LAMAArray< ValueType > &targetHalo, const LAMAArray< ValueType > &sourceHalo) const |
template<typename ValueType > | |
void | exchangeHaloN (LAMAArray< ValueType > &targetHalo, const LAMAArray< ValueType > &sourceHalo, const IndexType n) const |
void | buildVPlans (const IndexType haloSourceSizes[], const IndexType haloTargetSizes[]) const |
void | buildRowPlans (const LAMAArray< IndexType > &targetSizes, const LAMAArray< IndexType > &sourceSizes) const |
The redistributor can also be used to exchange rows of distributed sparse matrices instead of distributed vector elements. | |
IndexType | getVHaloSourceSize () const |
IndexType | getVHaloTargetSize () const |
template<typename ValueType > | |
void | exchangeVHalo (LAMAArray< ValueType > &targetHalo, const LAMAArray< ValueType > &sourceHalo) const |
const LAMAArray< IndexType > & | getLocalSourceIndexes () const |
const LAMAArray< IndexType > & | getLocalTargetIndexes () const |
const LAMAArray< IndexType > & | getHaloSourceIndexes () const |
const LAMAArray< IndexType > & | getHaloTargetIndexes () const |
Static Public Member Functions | |
template<typename ValueType > | |
static void | gather (LAMAArray< ValueType > &targetArray, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceIndexes) |
template<typename ValueType > | |
static void | gatherN (LAMAArray< ValueType > &targetArray, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceIndexes, const IndexType n) |
template<typename ValueType > | |
static void | gatherV (LAMAArray< ValueType > &targetArray, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceOffsets, const LAMAArray< IndexType > &sourceIndexes) |
template<typename ValueType > | |
static void | scatter (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray) |
template<typename ValueType > | |
static void | scatterN (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray, const IndexType n) |
template<typename ValueType > | |
static void | scatterV (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetOffsets, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray) |
template<typename ValueType > | |
static void | copy (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceIndexes) |
template<typename ValueType > | |
static void | copyN (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceIndexes, IndexType n) |
template<typename ValueType > | |
static void | copyV (LAMAArray< ValueType > &targetArray, const LAMAArray< IndexType > &targetOffsets, const LAMAArray< IndexType > &targetIndexes, const LAMAArray< ValueType > &sourceArray, const LAMAArray< IndexType > &sourceOffsets, const LAMAArray< IndexType > &sourceIndexes) |
Private Member Functions | |
virtual void | writeAt (std::ostream &stream) const |
Method to write info about a Redistributor into a stream. | |
LAMA_LOG_DECL_STATIC_LOGGER (logger) | |
Private Attributes | |
DistributionPtr | mSourceDistribution |
DistributionPtr | mTargetDistribution |
IndexType | mSourceSize |
IndexType | mTargetSize |
LAMAArray< IndexType > | mLocalSourceIndexes |
LAMAArray< IndexType > | mLocalTargetIndexes |
LAMAArray< IndexType > | mHaloSourceIndexes |
LAMAArray< IndexType > | mHaloTargetIndexes |
IndexType | mNumLocalValues |
Halo | mHalo |
std::auto_ptr< CommunicationPlan > | mProvidesPlan |
std::auto_ptr< CommunicationPlan > | mRequiredPlan |
This class allows to create objects that handle redistributions of vector and matrices from one distribution into another distribution.
Once created, it has built internal data structures like communicaton plans that restrict the redistribution just to the transfer of the corresponding data.
lama::Redistributor::Redistributor | ( | DistributionPtr | targetDistribution, |
DistributionPtr | sourceDistribution | ||
) |
Build an object by the source and target distribution.
[in] | targetDistribution | the new distribution |
[in] | sourceDistribution | the old distribution |
The global size of both distributions must be the same.
References lama::HaloBuilder::build(), lama::Distribution::getCommunicator(), lama::Distribution::getGlobalSize(), lama::Halo::getHaloSize(), lama::Distribution::getLocalSize(), lama::Halo::getProvidesIndexes(), lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), lama::Halo::global2halo(), lama::Distribution::global2local(), lama::Distribution::isLocal(), LAMA_ASSERT_EQUAL_ERROR, LAMA_ASSERT_ERROR, lama::Distribution::local2global(), mHalo, mHaloSourceIndexes, mHaloTargetIndexes, mLocalSourceIndexes, mLocalTargetIndexes, mNumLocalValues, mSourceSize, mTargetSize, lama::WriteAccess< T >::resize(), lama::WriteAccess< T >::size(), and lama::CommunicationPlan::totalQuantity().
void lama::Redistributor::buildRowPlans | ( | const LAMAArray< IndexType > & | targetSizes, |
const LAMAArray< IndexType > & | sourceSizes | ||
) | const |
The redistributor can also be used to exchange rows of distributed sparse matrices instead of distributed vector elements.
This method will build the corresponding exchange schedule.
References lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), mHalo, mHaloSourceIndexes, mHaloTargetIndexes, mProvidesPlan, mRequiredPlan, and lama::CommunicationPlan::totalQuantity().
Referenced by lama::StorageMethods< T >::redistributeCSR().
void lama::Redistributor::buildVPlans | ( | const IndexType | haloSourceSizes[], |
const IndexType | haloTargetSizes[] | ||
) | const |
static void lama::Redistributor::copy | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceIndexes | ||
) | [inline, static] |
References LAMA_ASSERT_ERROR, and lama::ReadAccess< T >::size().
Referenced by redistribute().
static void lama::Redistributor::copyN | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceIndexes, | ||
IndexType | n | ||
) | [inline, static] |
References LAMA_ASSERT_ERROR, and lama::ReadAccess< T >::size().
Referenced by redistributeN().
void lama::Redistributor::copyV | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetOffsets, | ||
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceOffsets, | ||
const LAMAArray< IndexType > & | sourceIndexes | ||
) | [static] |
References LAMA_ASSERT_EQUAL_DEBUG, LAMA_ASSERT_EQUAL_ERROR, and lama::_LAMAArray::size().
Referenced by redistributeV().
void lama::Redistributor::exchangeHalo | ( | LAMAArray< ValueType > & | targetHalo, |
const LAMAArray< ValueType > & | sourceHalo | ||
) | const |
References lama::Communicator::exchangeByPlanAsync(), lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), mHalo, and mSourceDistribution.
Referenced by redistribute().
void lama::Redistributor::exchangeHaloN | ( | LAMAArray< ValueType > & | targetHalo, |
const LAMAArray< ValueType > & | sourceHalo, | ||
const IndexType | n | ||
) | const |
References lama::Communicator::exchangeByPlan(), lama::Halo::getProvidesPlan(), lama::Halo::getRequiredPlan(), mHalo, and mSourceDistribution.
Referenced by redistributeN().
void lama::Redistributor::exchangeVHalo | ( | LAMAArray< ValueType > & | targetHalo, |
const LAMAArray< ValueType > & | sourceHalo | ||
) | const |
References lama::Communicator::exchangeByPlanAsync(), LAMA_ASSERT_ERROR, mProvidesPlan, mRequiredPlan, and mSourceDistribution.
Referenced by redistributeV().
static void lama::Redistributor::gather | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceIndexes | ||
) | [inline, static] |
References lama::ReadAccess< T >::size().
Referenced by redistribute().
static void lama::Redistributor::gatherN | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceIndexes, | ||
const IndexType | n | ||
) | [inline, static] |
References lama::ReadAccess< T >::size().
Referenced by redistributeN().
void lama::Redistributor::gatherV | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceOffsets, | ||
const LAMAArray< IndexType > & | sourceIndexes | ||
) | [static] |
References lama::_LAMAArray::size().
Referenced by lama::StorageMethods< T >::exchangeHaloCSR(), and redistributeV().
const LAMAArray<IndexType>& lama::Redistributor::getHaloSourceIndexes | ( | ) | const [inline] |
Referenced by redistributeV().
IndexType lama::Redistributor::getHaloSourceSize | ( | ) | const [inline] |
Referenced by redistribute(), redistributeN(), lama::SparseMatrix< T >::set(), and writeAt().
const LAMAArray<IndexType>& lama::Redistributor::getHaloTargetIndexes | ( | ) | const [inline] |
IndexType lama::Redistributor::getHaloTargetSize | ( | ) | const [inline] |
Referenced by redistribute(), redistributeN(), lama::SparseMatrix< T >::set(), and writeAt().
const LAMAArray<IndexType>& lama::Redistributor::getLocalSourceIndexes | ( | ) | const [inline] |
const LAMAArray<IndexType>& lama::Redistributor::getLocalTargetIndexes | ( | ) | const [inline] |
References mSourceDistribution.
Referenced by lama::MatrixStorage< T >::redistribute().
IndexType lama::Redistributor::getSourceLocalSize | ( | ) | const [inline] |
Referenced by lama::StorageMethods< T >::redistributeCSR().
Getter needed for distributions.
References mTargetDistribution.
Referenced by lama::MatrixStorage< T >::redistribute().
IndexType lama::Redistributor::getTargetLocalSize | ( | ) | const [inline] |
Referenced by lama::StorageMethods< T >::redistributeCSR().
IndexType lama::Redistributor::getVHaloSourceSize | ( | ) | const [inline] |
Referenced by redistributeV().
IndexType lama::Redistributor::getVHaloTargetSize | ( | ) | const [inline] |
Referenced by redistributeV().
lama::Redistributor::LAMA_LOG_DECL_STATIC_LOGGER | ( | logger | ) | [private] |
void lama::Redistributor::redistribute | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< ValueType > & | sourceArray | ||
) | const |
Redistribution of a distributed vector as LAMAArrays.
[in] | sourceArray | vector in source distribution |
[out] | targetArray | vector in target distribution |
Size of sourceArray must be at least sourceDistribution->getLocalSize() Size of targetArray must be at least targetDistribution->getLocalSize()
This routine is a simple straightforward solution. More efficient implementations are possible: overlapping local copies and communication.
References copy(), exchangeHalo(), gather(), getHaloSourceSize(), getHaloTargetSize(), mHaloSourceIndexes, mHaloTargetIndexes, mLocalSourceIndexes, mLocalTargetIndexes, mTargetSize, scatter(), and lama::_LAMAArray::size().
Referenced by lama::StorageMethods< T >::redistributeCSR().
void lama::Redistributor::redistributeN | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< ValueType > & | sourceArray, | ||
IndexType | n | ||
) | const |
Redistribution of a distributed vector as LAMAArrays.
[out] | targetArray | vector in target distribution |
[in] | sourceArray | vector in source distribution |
Size of sourceArray must be at least sourceDistribution->getLocalSize() Size of targetArray must be at least targetDistribution->getLocalSize()
This code only demonstrates how the redistributor schedule works. More efficient implementations are possible: overlapping local copies and communication.
References copyN(), exchangeHaloN(), gatherN(), getHaloSourceSize(), getHaloTargetSize(), mHaloSourceIndexes, mHaloTargetIndexes, mLocalSourceIndexes, mLocalTargetIndexes, mTargetSize, scatterN(), and lama::_LAMAArray::size().
void lama::Redistributor::redistributeV | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetOffsets, | ||
const LAMAArray< ValueType > & | sourceArray, | ||
const LAMAArray< IndexType > & | sourceOffsets | ||
) | const |
Redistribution of ragged arrays.
References copyV(), exchangeVHalo(), gatherV(), getHaloSourceIndexes(), getVHaloSourceSize(), getVHaloTargetSize(), mHaloTargetIndexes, mLocalSourceIndexes, mLocalTargetIndexes, and scatterV().
Referenced by lama::StorageMethods< T >::redistributeCSR().
static void lama::Redistributor::scatter | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray | ||
) | [inline, static] |
References lama::ReadAccess< T >::size().
Referenced by redistribute().
static void lama::Redistributor::scatterN | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray, | ||
const IndexType | n | ||
) | [inline, static] |
References lama::ReadAccess< T >::size().
Referenced by redistributeN().
void lama::Redistributor::scatterV | ( | LAMAArray< ValueType > & | targetArray, |
const LAMAArray< IndexType > & | targetOffsets, | ||
const LAMAArray< IndexType > & | targetIndexes, | ||
const LAMAArray< ValueType > & | sourceArray | ||
) | [static] |
References lama::_LAMAArray::size().
Referenced by redistributeV().
void lama::Redistributor::writeAt | ( | std::ostream & | stream | ) | const [private, virtual] |
Method to write info about a Redistributor into a stream.
Reimplemented from Printable.
References getHaloSourceSize(), getHaloTargetSize(), mNumLocalValues, mSourceDistribution, mSourceSize, mTargetDistribution, and mTargetSize.
Halo lama::Redistributor::mHalo [private] |
Referenced by buildRowPlans(), buildVPlans(), exchangeHalo(), exchangeHaloN(), and Redistributor().
Referenced by buildRowPlans(), redistribute(), redistributeN(), and Redistributor().
Referenced by buildRowPlans(), redistribute(), redistributeN(), redistributeV(), and Redistributor().
Referenced by redistribute(), redistributeN(), redistributeV(), and Redistributor().
Referenced by redistribute(), redistributeN(), redistributeV(), and Redistributor().
Referenced by Redistributor(), and writeAt().
std::auto_ptr<CommunicationPlan> lama::Redistributor::mProvidesPlan [mutable, private] |
Referenced by buildRowPlans(), buildVPlans(), and exchangeVHalo().
std::auto_ptr<CommunicationPlan> lama::Redistributor::mRequiredPlan [mutable, private] |
Referenced by buildRowPlans(), buildVPlans(), and exchangeVHalo().
Referenced by exchangeHalo(), exchangeHaloN(), exchangeVHalo(), getSourceDistributionPtr(), and writeAt().
IndexType lama::Redistributor::mSourceSize [private] |
Referenced by Redistributor(), and writeAt().
Referenced by getTargetDistributionPtr(), and writeAt().
IndexType lama::Redistributor::mTargetSize [private] |
Referenced by redistribute(), redistributeN(), Redistributor(), and writeAt().