Zoltan 2 Version 0.5
Public Member Functions
Zoltan2::PartitioningSolution< Adapter > Class Template Reference

A PartitioningSolution is a solution to a partitioning problem. More...

#include <Zoltan2_PartitioningSolution.hpp>

Inheritance diagram for Zoltan2::PartitioningSolution< Adapter >:
Inheritance graph
[legend]
Collaboration diagram for Zoltan2::PartitioningSolution< Adapter >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PartitioningSolution (RCP< const Environment > &env, RCP< const Comm< int > > &comm, RCP< const IdentifierMap< user_t > > &idMap, int userWeightDim)
 Constructor when part sizes are not supplied.
 PartitioningSolution (RCP< const Environment > &env, RCP< const Comm< int > > &comm, RCP< const IdentifierMap< user_t > > &idMap, int userWeightDim, ArrayView< ArrayRCP< partId_t > > reqPartIds, ArrayView< ArrayRCP< scalar_t > > reqPartSizes)
 Constructor when part sizes are supplied.
size_t getTargetGlobalNumberOfParts () const
 Returns the global number of parts desired in the solution.
size_t getActualGlobalNumberOfParts () const
 Returns the actual global number of parts provided in setParts().
size_t getLocalNumberOfParts () const
 Returns the number of parts to be assigned to this process.
scalar_t getLocalFractionOfPart () const
 If parts are divided across processes, return the fraction of a part on this process.
bool oneToOnePartDistribution () const
 Is the part-to-process distribution is one-to-one.
const int * getPartDistribution () const
 Return a distribution by part.
const partId_tgetProcDistribution () const
 Return a distribution by process.
int getNumberOfCriteria () const
 Get the number of criteria (the weight dimension).
bool criteriaHasUniformPartSizes (int idx) const
 Determine if balancing criteria (weight dimension) has uniform part sizes. (User can specify differing part sizes.)
scalar_t getCriteriaPartSize (int idx, partId_t part) const
 Get the size for a given weight dimension and a given part.
bool criteriaHaveSamePartSizes (int c1, int c2) const
 Return true if the two weight dimensions have the same part size information.
void setParts (ArrayRCP< const gno_t > &gnoList, ArrayRCP< partId_t > &partList, bool dataDidNotMove)
 The algorithm uses setParts to set the solution.
const RCP< const Comm< int > > & getCommunicator () const
 Return the communicator associated with the solution.
size_t getLocalNumberOfIds () const
 Returns the local number of Ids.
const gid_t * getIdList () const
 Returns the user's global ID list.
const zoltan2_partId_tgetPartList () const
 Returns the part list corresponding to the global ID list.
const int * getProcList () const
 Returns the process list corresponding to the global ID list.
template<typename Extra >
size_t convertSolutionToImportList (int numExtra, ArrayRCP< Extra > &xtraInfo, ArrayRCP< typename Adapter::gid_t > &imports, ArrayRCP< Extra > &newXtraInfo) const
 Create an import list from the export list.
void getPartsForProc (int procId, double &numParts, partId_t &partMin, partId_t &partMax) const
 Get the parts belonging to a process.
void getProcsForPart (partId_t partId, int &procMin, int &procMax) const
 Get the processes containing a part.

Detailed Description

template<typename Adapter>
class Zoltan2::PartitioningSolution< Adapter >

A PartitioningSolution is a solution to a partitioning problem.

It is initialized by a PartitioningProblem, written to by an algorithm, and may be read by the user or by a data migration routine in an input adapter.

Todo:

Problem computes metrics using the Solution. Should Solution have a pointer to the metrics, since it may persist after the Problem is gone?

save an RCB tree, so it can be used in repartitioning, and supplied to the caller.

doxyfy the comments in this file.

Examples:

rcb_C.cpp.

Definition at line 77 of file Zoltan2_PartitioningSolution.hpp.


Constructor & Destructor Documentation

template<typename Adapter >
Zoltan2::PartitioningSolution< Adapter >::PartitioningSolution ( RCP< const Environment > &  env,
RCP< const Comm< int > > &  comm,
RCP< const IdentifierMap< user_t > > &  idMap,
int  userWeightDim 
)

Constructor when part sizes are not supplied.

The Solution constructor may require global communication. The rest of the Solution methods do not.

Parameters:
envthe environment for the application
commthe communicator for the problem associated with this solution
idMapthe IdentifierMap corresponding to the solution
userWeightDimthe number of weights supplied by the application for each object.

It is possible that part sizes were supplied on other processes, so this constructor does do a check to see if part sizes need to be globally calculated.

Definition at line 534 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter >
Zoltan2::PartitioningSolution< Adapter >::PartitioningSolution ( RCP< const Environment > &  env,
RCP< const Comm< int > > &  comm,
RCP< const IdentifierMap< user_t > > &  idMap,
int  userWeightDim,
ArrayView< ArrayRCP< partId_t > >  reqPartIds,
ArrayView< ArrayRCP< scalar_t > >  reqPartSizes 
)

Constructor when part sizes are supplied.

The Solution constructor may require global communication. The rest of the Solution methods do not.

Parameters:
envthe environment for the application
commthe communicator for the problem associated with this solution
idMapthe IdentifierMap corresponding to the solution
userWeightDimthe number of weights supplied by the application
reqPartIdsreqPartIds[i] is a list of of part numbers for weight dimension i.
reqPartSizesreqPartSizes[i] is the list of part sizes for weight i corresponding to parts in reqPartIds[i]

If reqPartIds[i].size() and reqPartSizes[i].size() are zero for all processes, it is assumed that part sizes for weight dimension "i" are uniform.

If across the application there are some part numbers that are not included in the reqPartIds lists, then those part sizes are assumed to be 1.0.

Todo:
handle errors that may arise - like duplicate part numbers

Definition at line 565 of file Zoltan2_PartitioningSolution.hpp.


Member Function Documentation

template<typename Adapter>
size_t Zoltan2::PartitioningSolution< Adapter >::getTargetGlobalNumberOfParts ( ) const [inline]

Returns the global number of parts desired in the solution.

Definition at line 151 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
size_t Zoltan2::PartitioningSolution< Adapter >::getActualGlobalNumberOfParts ( ) const [inline]

Returns the actual global number of parts provided in setParts().

Definition at line 155 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
size_t Zoltan2::PartitioningSolution< Adapter >::getLocalNumberOfParts ( ) const [inline]

Returns the number of parts to be assigned to this process.

Definition at line 159 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
scalar_t Zoltan2::PartitioningSolution< Adapter >::getLocalFractionOfPart ( ) const [inline]

If parts are divided across processes, return the fraction of a part on this process.

Returns:
zero if parts are not split across processes, approximate fraction of the part otherwise.
Todo:
More useful to get number of processes owning part? Or not useful at all - remove this?

Definition at line 168 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
bool Zoltan2::PartitioningSolution< Adapter >::oneToOnePartDistribution ( ) const [inline]

Is the part-to-process distribution is one-to-one.

Returns:
true if Process p owns part p for all p, and false if the part to process distribution is more complex.

If this is true, then getPartDistribution() and getProcDistribution() return NULL pointers. If either of the latter two methods is non-NULL, then this method returns false.

Definition at line 179 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const int* Zoltan2::PartitioningSolution< Adapter >::getPartDistribution ( ) const [inline]

Return a distribution by part.

Returns:
If any parts are divided across processes, then a mapping A is returned. A such that A[i] is the lowest numbered process owning part i. The length of the array is one greater than the global number of parts. The value of the last element is the global number of processes.

Parts are only divided across processes if there are fewer parts than processes and the caller did not define "num_local_parts" for each process. In this case, parts are divided somewhat evenly across the processes. This situation is more likely to arise in Zoltan2 algorithms than in user applications.

If either oneToOnePartDistribution() is true or getProcDistribution() is non-NULL, then this method returns a NULL pointer. The three are mutually exclusive and collective exhaustive.

Definition at line 200 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const partId_t* Zoltan2::PartitioningSolution< Adapter >::getProcDistribution ( ) const [inline]

Return a distribution by process.

Returns:
If the mapping of parts to processes is not one-to-one, and if parts are not divided across processes, then the mapping A is returned. A such that A[i] is the first part assigned to process i. (Parts are assigned sequentially to processes.) However if A[i+1] is equal to A[i], there are no parts assigned to process i. The length of the array is one greater than the number of processes. The last element of the array is the global number of parts.

If the mapping is one-to-one, or if parts are divided across processes, then this method returns NULL pointer, and either oneToOnePartDistribution() or getPartDistribution() describes the mapping.

Definition at line 218 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
int Zoltan2::PartitioningSolution< Adapter >::getNumberOfCriteria ( ) const [inline]

Get the number of criteria (the weight dimension).

Returns:
the number of criteria for which the solution has part sizes.

Definition at line 223 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
bool Zoltan2::PartitioningSolution< Adapter >::criteriaHasUniformPartSizes ( int  idx) const [inline]

Determine if balancing criteria (weight dimension) has uniform part sizes. (User can specify differing part sizes.)

Parameters:
idxA value from 0 to one less than the number of weights per object.
Returns:
true if part sizes are uniform for this criteria.

Definition at line 232 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
scalar_t Zoltan2::PartitioningSolution< Adapter >::getCriteriaPartSize ( int  idx,
partId_t  part 
) const [inline]

Get the size for a given weight dimension and a given part.

Parameters:
idxA value from 0 to one less than the number of weights per object.
partA value from 0 to one less than the global number of parts to be computed
Returns:
The size for that part. Part sizes for a given weight dimension sum to 1.0.
Todo:
It would be useful to algorithms to get the sum of part sizes from a to b, or the sum or a list of parts.

Definition at line 246 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter >
bool Zoltan2::PartitioningSolution< Adapter >::criteriaHaveSamePartSizes ( int  c1,
int  c2 
) const

Return true if the two weight dimensions have the same part size information.

Parameters:
c1A value from 0 through one less than the number of weights.
c2A value from 0 through one less than the number of weights.
Returns:
If weight dimension c1 and weight dimension c2 have the same part size information, the true is returned, otherwise false is returned.

It may be a problem for some algorithms if there are multiple weight dimensions with differing part size constraints to be satisfied.

Definition at line 1552 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter >
void Zoltan2::PartitioningSolution< Adapter >::setParts ( ArrayRCP< const gno_t > &  gnoList,
ArrayRCP< partId_t > &  partList,
bool  dataDidNotMove 
)

The algorithm uses setParts to set the solution.

Parameters:
gnoListA list of global numbers.
partListThe part assigned to gnoList[i] by the algorithm should be in partList[i]. The partList is allocated and written by the algorithm.
dataDidNotMoveThe algorithm did not change the order of the data provided by the model; that is, it did not move the data to other processes or reorganize within the process. Thus, the gnoList and partList are ordered in the same way as the array provided by the model. Setting this flag to true avoids processing to remap the data to the original process that provided the data.

The global numbers supplied by the algorithm do not need to be those representing the global Ids of that process. But all global numbers should be assigned a part by exactly one process.

setParts() must be called by all processes in the problem, as the part for each global identifier supplied by each process in its InputAdapter is found and saved in this PartitioningSolution.

Definition at line 1128 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const RCP<const Comm<int> >& Zoltan2::PartitioningSolution< Adapter >::getCommunicator ( ) const [inline]

Return the communicator associated with the solution.

Definition at line 310 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
size_t Zoltan2::PartitioningSolution< Adapter >::getLocalNumberOfIds ( ) const [inline]

Returns the local number of Ids.

Definition at line 314 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const gid_t* Zoltan2::PartitioningSolution< Adapter >::getIdList ( ) const [inline]

Returns the user's global ID list.

Definition at line 318 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const zoltan2_partId_t* Zoltan2::PartitioningSolution< Adapter >::getPartList ( ) const [inline]

Returns the part list corresponding to the global ID list.

Definition at line 322 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
const int* Zoltan2::PartitioningSolution< Adapter >::getProcList ( ) const [inline]

Returns the process list corresponding to the global ID list.

Returns:
The return value is a NULL pointer if part IDs are synonomous with process IDs.

Definition at line 328 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter >
template<typename Extra >
size_t Zoltan2::PartitioningSolution< Adapter >::convertSolutionToImportList ( int  numExtra,
ArrayRCP< Extra > &  xtraInfo,
ArrayRCP< typename Adapter::gid_t > &  imports,
ArrayRCP< Extra > &  newXtraInfo 
) const

Create an import list from the export list.

Parameters:
numExtraThe amount of related information of type Extra that you would like to associate with the data.
xtraInfoThe extra information related to your global Ids. The information for the k-th global ID would begin at xtraInfo[k*numExtra] and end before xtraInfo[(k+1)*numExtra].
importson return is the list of global Ids assigned to this process under the Solution.
newXtraInfoon return is the extra information associated with the global Ids in the import list.

The list returned in getPartList() is an export list, detailing to which part each object should be moved. This method provides a new list, listing the global IDs of the objects to be imported to my part or parts.

Because this method does global communication, it can also send useful data related to the global IDs. For example, if the global IDs represent matrix rows, the extra data could be the number of non zeros in the row.

Todo:
A version which takes the export part numbers and returns the import part numbers in addition to the global IDs. Although this can be done with the extra data, it might be better to do it explicitly.

Definition at line 1409 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
void Zoltan2::PartitioningSolution< Adapter >::getPartsForProc ( int  procId,
double &  numParts,
partId_t partMin,
partId_t partMax 
) const [inline]

Get the parts belonging to a process.

Parameters:
procIda process rank
numPartson return will be set the number of parts belonging to the process.
partMinon return will be set to minimum part number
partMaxon return will be set to maximum part number

Normally numParts is at least one. But if there are more processes than parts, one of two things can happen. Either there are processes with no parts, and so numParts will be zero, or a part may be split across more than one process, in which numParts will be non-zero but less than 1.

In the latter case, numParts is 1.0 divided by the number of processes that share the part.

Definition at line 383 of file Zoltan2_PartitioningSolution.hpp.

template<typename Adapter>
void Zoltan2::PartitioningSolution< Adapter >::getProcsForPart ( partId_t  partId,
int &  procMin,
int &  procMax 
) const [inline]

Get the processes containing a part.

Parameters:
partIda part number from 0 to one less than the global number of parts.
procMinon return will be set to minimum proc number
procMaxon return will be set to maximum proc number

Normally procMin and procMax are the same value and a part is assigned to one process. But if there are more processes than parts, it's possible that a part will be divided across more than one process.

Definition at line 403 of file Zoltan2_PartitioningSolution.hpp.


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