#include <DistributionMapping.H>
Public Types | |
enum | Strategy { ROUNDROBIN, KNAPSACK } |
The distribution strategy: ROUNDROBIN or KNAPSACK. More... | |
Public Member Functions | |
DistributionMapping () | |
The default constructor. | |
DistributionMapping (const BoxArray &boxes, int nprocs) | |
Build mapping out of BoxArray over nprocs processors. | |
DistributionMapping (const DistributionMapping &d1, const DistributionMapping &d2) | |
DistributionMapping (const BoxArray &boxes, int nprocs, int *procmapping) | |
~DistributionMapping () | |
The destructor. | |
void | define (const BoxArray &boxes, int nprocs) |
Build mapping out of BoxArray over nprocs processors. | |
const Array< int > & | ProcessorMap () const |
Returns a constant reference to the mapping of boxes in the underlying BoxArray to the CPU that holds the FAB on that Box. | |
int | operator[] (int index) const |
Equivalent to ProcessorMap()[index]. | |
bool | operator== (const DistributionMapping &rhs) const |
Are the distributions equal? | |
bool | operator!= (const DistributionMapping &rhs) const |
Are the distributions different? | |
void | RoundRobinProcessorMap (int nboxes, int nprocs) |
void | KnapSackProcessorMap (const std::vector< long > &boxes, int nprocs) |
Static Public Member Functions | |
static void | strategy (Strategy how) |
Set distribution strategy. | |
static Strategy | strategy () |
Returns the distribution strategy. | |
static void | FlushCache () |
Flush the cache of processor maps. | |
static int | CacheSize () |
The size of the cache. | |
static void | AddToCache (const DistributionMapping &dm) |
Append the ProcMap to the Cache. Checks for consistency. | |
static void | CacheStats (std::ostream &os) |
Output some simple cache statistics. | |
static void | Initialize () |
static void | Finalize () |
This class calculates the distribution of FABs to processors in a FabArray in a multi-processor environment. By distribution is meant what CPU in the multi-processor environment owns what FAB. Only the BoxArray on which the FabArray is built is used in determining the distribution. The two types of distributions supported are round-robin and knapsack. In the round-robin distribution FAB `i' is owned by CPU `iN' where N is total number of CPUs. In the knapsack distribution the FABs are partitioned across CPUs such that the total volume of the Boxes in the underlying BoxArray are as equal across CPUs as is possible.
DistributionMapping::DistributionMapping | ( | ) |
The default constructor.
DistributionMapping::DistributionMapping | ( | const BoxArray & | boxes, | |
int | nprocs | |||
) |
DistributionMapping::DistributionMapping | ( | const DistributionMapping & | d1, | |
const DistributionMapping & | d2 | |||
) |
References ParallelDescriptor::MyProc(), ProcessorMap(), and Array< T >::size().
DistributionMapping::DistributionMapping | ( | const BoxArray & | boxes, | |
int | nprocs, | |||
int * | procmapping | |||
) |
References ParallelDescriptor::MyProc(), and BoxArray::size().
DistributionMapping::~DistributionMapping | ( | ) |
The destructor.
void DistributionMapping::define | ( | const BoxArray & | boxes, | |
int | nprocs | |||
) |
Build mapping out of BoxArray over nprocs processors.
You need to call this if you built your DistributionMapping with the default constructor.
References ROUNDROBIN, BoxArray::size(), and Array< T >::size().
Referenced by FabArray< FAB >::define(), and DistributionMapping().
const Array< int > & DistributionMapping::ProcessorMap | ( | ) | const |
Returns a constant reference to the mapping of boxes in the underlying BoxArray to the CPU that holds the FAB on that Box.
ProcessorMap()[i] is an integer in the interval [0, NCPU) where NCPU is the number of CPUs being used.
Referenced by AddToCache(), DistributionMapping(), VisMF::Header::Header(), operator<<(), and VisMF::Write().
int DistributionMapping::operator[] | ( | int | index | ) | const |
Equivalent to ProcessorMap()[index].
void DistributionMapping::strategy | ( | DistributionMapping::Strategy | how | ) | [static] |
Set distribution strategy.
References BoxLib::Error(), KNAPSACK, KnapSackProcessorMap(), ROUNDROBIN, and RoundRobinProcessorMap().
DistributionMapping::Strategy DistributionMapping::strategy | ( | ) | [static] |
void DistributionMapping::FlushCache | ( | ) | [static] |
Flush the cache of processor maps.
The processor map cache is only flushed manually. Only call this after a regridding before new MultiFabs are alloc()d.
int DistributionMapping::CacheSize | ( | ) | [static] |
The size of the cache.
void DistributionMapping::AddToCache | ( | const DistributionMapping & | dm | ) | [static] |
Append the ProcMap to the Cache. Checks for consistency.
References BL_ASSERT, ParallelDescriptor::MyProc(), ProcessorMap(), and Array< T >::size().
void DistributionMapping::CacheStats | ( | std::ostream & | os | ) | [static] |
Output some simple cache statistics.
bool DistributionMapping::operator== | ( | const DistributionMapping & | rhs | ) | const |
bool DistributionMapping::operator!= | ( | const DistributionMapping & | rhs | ) | const |
void DistributionMapping::RoundRobinProcessorMap | ( | int | nboxes, | |
int | nprocs | |||
) |
References BL_ASSERT, and ParallelDescriptor::MyProc().
Referenced by KnapSackProcessorMap(), and strategy().
void DistributionMapping::KnapSackProcessorMap | ( | const std::vector< long > & | boxes, | |
int | nprocs | |||
) |
References BL_ASSERT, knapsack(), ParallelDescriptor::MyProc(), and RoundRobinProcessorMap().
Referenced by strategy().
void DistributionMapping::Initialize | ( | ) | [static] |
References KNAPSACK, ParmParse::query(), ROUNDROBIN, strategy(), and BoxLib::Warning().
Referenced by BoxLib::Initialize().
void DistributionMapping::Finalize | ( | ) | [static] |
Referenced by BoxLib::Finalize().