Zoltan2 Version of the Day

A PartitioningSolution is a solution to a partitioning problem. More...
#include <Zoltan2_PartitioningSolution.hpp>
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 parttoprocess distribution is onetoone.  
const int *  getPartDistribution () const 
Return a distribution by part.  
const partId_t *  getProcDistribution () 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.  
void  RemapParts () 
Remap a new partition for maximum overlap with an input partition.  
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_t *  getPartList () 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.  
void  setPartBoxes (RCP< vector< Zoltan2::coordinateModelPartBox< scalar_t, partId_t > > > outPartBoxes) 
set the Part Box boundaries as a result of geometric partitioning algorithm.  
RCP< vector < Zoltan2::coordinateModelPartBox < scalar_t, partId_t > > >  getPartBoxes () 
returns the part box boundary list.  
void  getCommunicationGraph (const Teuchos::Comm< int > *comm, ArrayRCP< partId_t > &comXAdj, ArrayRCP< partId_t > &comAdj) 
returns the communication graph as a result of geometric partitioning algorithm.  
RCP< vector < Zoltan2::coordinateModelPartBox < scalar_t, partId_t > > >  getGlobalBoxBoundaries (const Teuchos::Comm< int > *comm) 
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. 
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.
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.
Definition at line 123 of file Zoltan2_PartitioningSolution.hpp.
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.
env  the environment for the application 
comm  the communicator for the problem associated with this solution 
idMap  the IdentifierMap corresponding to the solution 
userWeightDim  the 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 722 of file Zoltan2_PartitioningSolution.hpp.
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.
env  the environment for the application 
comm  the communicator for the problem associated with this solution 
idMap  the IdentifierMap corresponding to the solution 
userWeightDim  the number of weights supplied by the application 
reqPartIds  reqPartIds[i] is a list of of part numbers for weight dimension i. 
reqPartSizes  reqPartSizes[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.
Definition at line 754 of file Zoltan2_PartitioningSolution.hpp.
size_t Zoltan2::PartitioningSolution< Adapter >::getTargetGlobalNumberOfParts  (  )  const [inline] 
Returns the global number of parts desired in the solution.
Definition at line 197 of file Zoltan2_PartitioningSolution.hpp.
size_t Zoltan2::PartitioningSolution< Adapter >::getActualGlobalNumberOfParts  (  )  const [inline] 
Returns the actual global number of parts provided in setParts().
Definition at line 201 of file Zoltan2_PartitioningSolution.hpp.
size_t Zoltan2::PartitioningSolution< Adapter >::getLocalNumberOfParts  (  )  const [inline] 
Returns the number of parts to be assigned to this process.
Definition at line 205 of file Zoltan2_PartitioningSolution.hpp.
scalar_t Zoltan2::PartitioningSolution< Adapter >::getLocalFractionOfPart  (  )  const [inline] 
If parts are divided across processes, return the fraction of a part on this process.
Definition at line 214 of file Zoltan2_PartitioningSolution.hpp.
bool Zoltan2::PartitioningSolution< Adapter >::oneToOnePartDistribution  (  )  const [inline] 
Is the parttoprocess distribution is onetoone.
If this is true, then getPartDistribution() and getProcDistribution() return NULL pointers. If either of the latter two methods is nonNULL, then this method returns false.
Definition at line 225 of file Zoltan2_PartitioningSolution.hpp.
const int* Zoltan2::PartitioningSolution< Adapter >::getPartDistribution  (  )  const [inline] 
Return a distribution by part.
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 divided across processes only 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 nonNULL, then this method returns a NULL pointer. The three are mutually exclusive and collective exhaustive.
Definition at line 246 of file Zoltan2_PartitioningSolution.hpp.
const partId_t* Zoltan2::PartitioningSolution< Adapter >::getProcDistribution  (  )  const [inline] 
Return a distribution by process.
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 onetoone, or if parts are divided across processes, then this method returns NULL pointer, and either oneToOnePartDistribution() or getPartDistribution() describes the mapping.
Definition at line 267 of file Zoltan2_PartitioningSolution.hpp.
int Zoltan2::PartitioningSolution< Adapter >::getNumberOfCriteria  (  )  const [inline] 
Get the number of criteria (the weight dimension).
Definition at line 275 of file Zoltan2_PartitioningSolution.hpp.
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.)
idx  A value from 0 to one less than the number of weights per object. 
Definition at line 284 of file Zoltan2_PartitioningSolution.hpp.
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.
idx  A value from 0 to one less than the number of weights per object. 
part  A value from 0 to one less than the global number of parts to be computed 
Definition at line 298 of file Zoltan2_PartitioningSolution.hpp.
bool Zoltan2::PartitioningSolution< Adapter >::criteriaHaveSamePartSizes  (  int  c1, 
int  c2  
)  const 
Return true if the two weight dimensions have the same part size information.
c1  A value from 0 through one less than the number of weights. 
c2  A value from 0 through one less than the number of weights. 
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 1749 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::setParts  (  ArrayRCP< const gno_t > &  gnoList, 
ArrayRCP< partId_t > &  partList,  
bool  dataDidNotMove  
) 
The algorithm uses setParts to set the solution.
gnoList  A list of global numbers. 
partList  The part assigned to gnoList[i] by the algorithm should be in partList[i]. The partList is allocated and written by the algorithm. 
dataDidNotMove  The 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 1319 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::RemapParts  (  ) 
Remap a new partition for maximum overlap with an input partition.
Assumptions for this version: input part assignment == processor rank for every local object. assuming nGlobalParts <= num ranks TODO: Write a version that takes the input part number as input; this change requires input parts in adapters to be provided in the Adapter. TODO: For repartitioning, compare to old remapping results; see Zoltan1.
Definition at line 1990 of file Zoltan2_PartitioningSolution.hpp.
const RCP<const Comm<int> >& Zoltan2::PartitioningSolution< Adapter >::getCommunicator  (  )  const [inline] 
Return the communicator associated with the solution.
Definition at line 377 of file Zoltan2_PartitioningSolution.hpp.
size_t Zoltan2::PartitioningSolution< Adapter >::getLocalNumberOfIds  (  )  const [inline] 
Returns the local number of Ids.
Definition at line 381 of file Zoltan2_PartitioningSolution.hpp.
const gid_t* Zoltan2::PartitioningSolution< Adapter >::getIdList  (  )  const [inline] 
Returns the user's global ID list.
Definition at line 385 of file Zoltan2_PartitioningSolution.hpp.
const zoltan2_partId_t* Zoltan2::PartitioningSolution< Adapter >::getPartList  (  )  const [inline] 
Returns the part list corresponding to the global ID list.
Definition at line 389 of file Zoltan2_PartitioningSolution.hpp.
const int* Zoltan2::PartitioningSolution< Adapter >::getProcList  (  )  const [inline] 
Returns the process list corresponding to the global ID list.
Definition at line 395 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::setPartBoxes  (  RCP< vector< Zoltan2::coordinateModelPartBox< scalar_t, partId_t > > >  outPartBoxes  )  [inline] 
set the Part Box boundaries as a result of geometric partitioning algorithm.
Definition at line 400 of file Zoltan2_PartitioningSolution.hpp.
RCP< vector <Zoltan2::coordinateModelPartBox <scalar_t, partId_t> > > Zoltan2::PartitioningSolution< Adapter >::getPartBoxes  (  )  [inline] 
returns the part box boundary list.
Definition at line 406 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::getCommunicationGraph  (  const Teuchos::Comm< int > *  comm, 
ArrayRCP< partId_t > &  comXAdj,  
ArrayRCP< partId_t > &  comAdj  
)  [inline] 
returns the communication graph as a result of geometric partitioning algorithm.
Definition at line 412 of file Zoltan2_PartitioningSolution.hpp.
RCP< vector <Zoltan2::coordinateModelPartBox <scalar_t, partId_t> > > Zoltan2::PartitioningSolution< Adapter >::getGlobalBoxBoundaries  (  const Teuchos::Comm< int > *  comm  )  [inline] 
Definition at line 437 of file Zoltan2_PartitioningSolution.hpp.
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.
numExtra  The amount of related information of type Extra that you would like to associate with the data. 
xtraInfo  The extra information related to your global Ids. The information for the kth global ID would begin at xtraInfo[k*numExtra] and end before xtraInfo[(k+1)*numExtra] . 
imports  on return is the list of global Ids assigned to this process under the Solution. 
newXtraInfo  on 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.
Definition at line 1606 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::getPartsForProc  (  int  procId, 
double &  numParts,  
partId_t &  partMin,  
partId_t &  partMax  
)  const [inline] 
Get the parts belonging to a process.
procId  a process rank 
numParts  on return will be set the number of parts belonging to the process. 
partMin  on return will be set to minimum part number 
partMax  on 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 nonzero 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 565 of file Zoltan2_PartitioningSolution.hpp.
void Zoltan2::PartitioningSolution< Adapter >::getProcsForPart  (  partId_t  partId, 
int &  procMin,  
int &  procMax  
)  const [inline] 
Get the processes containing a part.
partId  a part number from 0 to one less than the global number of parts. 
procMin  on return will be set to minimum proc number 
procMax  on 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 585 of file Zoltan2_PartitioningSolution.hpp.