LAMA
lama::Redistributor Class Reference

This class allows to create objects that handle redistributions of vector and matrices from one distribution into another distribution. More...

#include <Redistributor.hpp>

Inheritance diagram for lama::Redistributor:

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< IndexTypemLocalSourceIndexes
LAMAArray< IndexTypemLocalTargetIndexes
LAMAArray< IndexTypemHaloSourceIndexes
LAMAArray< IndexTypemHaloTargetIndexes
IndexType mNumLocalValues
Halo mHalo
std::auto_ptr< CommunicationPlanmProvidesPlan
std::auto_ptr< CommunicationPlanmRequiredPlan

Detailed Description

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.


Constructor & Destructor Documentation


Member Function Documentation

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

template<typename ValueType >
static void lama::Redistributor::copy ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< IndexType > &  targetIndexes,
const LAMAArray< ValueType > &  sourceArray,
const LAMAArray< IndexType > &  sourceIndexes 
) [inline, static]
template<typename ValueType >
static void lama::Redistributor::copyN ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< IndexType > &  targetIndexes,
const LAMAArray< ValueType > &  sourceArray,
const LAMAArray< IndexType > &  sourceIndexes,
IndexType  n 
) [inline, static]
template<typename ValueType >
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]
template<typename ValueType >
void lama::Redistributor::exchangeHalo ( LAMAArray< ValueType > &  targetHalo,
const LAMAArray< ValueType > &  sourceHalo 
) const
template<typename ValueType >
void lama::Redistributor::exchangeHaloN ( LAMAArray< ValueType > &  targetHalo,
const LAMAArray< ValueType > &  sourceHalo,
const IndexType  n 
) const
template<typename ValueType >
void lama::Redistributor::exchangeVHalo ( LAMAArray< ValueType > &  targetHalo,
const LAMAArray< ValueType > &  sourceHalo 
) const
template<typename ValueType >
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().

template<typename ValueType >
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().

template<typename ValueType >
void lama::Redistributor::gatherV ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< ValueType > &  sourceArray,
const LAMAArray< IndexType > &  sourceOffsets,
const LAMAArray< IndexType > &  sourceIndexes 
) [static]
template<typename ValueType >
void lama::Redistributor::redistribute ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< ValueType > &  sourceArray 
) const

Redistribution of a distributed vector as LAMAArrays.

Parameters:
[in]sourceArrayvector in source distribution
[out]targetArrayvector 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().

template<typename ValueType >
void lama::Redistributor::redistributeN ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< ValueType > &  sourceArray,
IndexType  n 
) const

Redistribution of a distributed vector as LAMAArrays.

Parameters:
[out]targetArrayvector in target distribution
[in]sourceArrayvector 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().

template<typename ValueType >
void lama::Redistributor::redistributeV ( LAMAArray< ValueType > &  targetArray,
const LAMAArray< IndexType > &  targetOffsets,
const LAMAArray< ValueType > &  sourceArray,
const LAMAArray< IndexType > &  sourceOffsets 
) const
template<typename ValueType >
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().

template<typename ValueType >
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().

template<typename ValueType >
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.


Field Documentation


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