Class that distribute sub-sub-domains across processors using ParMetis Library. More...
Class that distribute sub-sub-domains across processors using ParMetis Library.
Given a graph and setting Computational cost, Communication cost (on the edge) and Migration cost or total Communication costs, it produce the optimal balanced distribution
In addition to Metis it provide the functionality to refine the previously computed decomposition
Definition at line 36 of file ParMetisDistribution.hpp.
#include <ParMetisDistribution.hpp>
Public Member Functions | |
ParMetisDistribution (Vcluster<> &v_cl) | |
ParMetisDistribution (const ParMetisDistribution< dim, T > &pm) | |
ParMetisDistribution (ParMetisDistribution< dim, T > &&pm) | |
void | createCartGraph (grid_sm< dim, void > &grid, Box< dim, T > &dom) |
Create the Cartesian graph. | |
Graph_CSR< nm_v< dim >, nm_e > & | getGraph () |
Get the current graph (main) | |
void | decompose () |
Create the decomposition. | |
void | refine () |
Refine current decomposition. | |
void | redecompose () |
Redecompose current decomposition. | |
float | getUnbalance () |
Compute the unbalance of the processor compared to the optimal balance. | |
void | getSubSubDomainPosition (size_t id, T(&pos)[dim]) |
function that return the position of the vertex in the space | |
void | setComputationCost (size_t id, size_t weight) |
Function that set the weight of the vertex. | |
bool | weightsAreUsed () |
Checks if weights are used on the vertices. | |
size_t | getSubSubDomainComputationCost (size_t id) |
function that get the weight of the vertex | |
size_t | getProcessorLoad () |
Compute the processor load counting the total weights of its vertices. | |
void | setMigrationCost (size_t id, size_t migration) |
Set migration cost of the vertex id. | |
void | setCommunicationCost (size_t v_id, size_t e, size_t communication) |
Set communication cost of the edge id. | |
size_t | getNSubSubDomains () const |
Returns total number of sub-sub-domains in the distribution graph. | |
size_t | getNOwnerSubSubDomains () const |
Return the total number of sub-sub-domains this processor own. | |
size_t | getOwnerSubSubDomain (size_t id) const |
Return the global id of the owned sub-sub-domain. | |
size_t | getNSubSubDomainNeighbors (size_t id) |
Returns total number of neighbors of the sub-sub-domain id. | |
void | destroy_internal_graph () |
In case we do not do Dynamic load balancing this this data-structure it is safe to eliminate the full internal graph. | |
void | write (const std::string &file) |
Print the current distribution and save it to VTK file. | |
const ParMetisDistribution< dim, T > & | operator= (const ParMetisDistribution< dim, T > &dist) |
const ParMetisDistribution< dim, T > & | operator= (ParMetisDistribution< dim, T > &&dist) |
void | getSubSubDomainPos (size_t j, Point< dim, T > &p) |
return the the position of the sub-sub-domain | |
size_t | get_ndec () |
Get the decomposition counter. | |
void | setDistTol (double tol) |
Set the tolerance for each partition. | |
Private Member Functions | |
void | updateGraphs () |
Update main graph ad subgraph with the received data of the partitions from the other processors. | |
auto | vertexByMapId (rid id) -> decltype(gp.vertex(m2g.find(id) ->second.id)) |
operator to access the vertex by mapped position | |
void | setMapId (rid n, gid g) |
operator to remap vertex to a new position | |
gid | getVertexGlobalId (rid n) |
Get the global id of the vertex given the re-mapped one. | |
void | initLocalToGlobalMap () |
operator to init ids vector | |
void | postDecomposition () |
It update the full decomposition. | |
Static Private Member Functions | |
static void * | message_receive (size_t msg_i, size_t total_msg, size_t total_p, size_t i, size_t ri, size_t tag, void *ptr) |
Callback of the sendrecv to set the size of the array received. | |
Private Attributes | |
bool | is_distributed = false |
Is distributed. | |
Vcluster & | v_cl |
Vcluster. | |
grid_sm< dim, void > | gr |
Structure that store the cartesian grid information. | |
Box< dim, T > | domain |
rectangular domain to decompose | |
Graph_CSR< nm_v< dim >, nm_e > | gp |
Global sub-sub-domain graph. | |
Parmetis< Graph_CSR< nm_v< dim >, nm_e > > | parmetis_graph |
Convert the graph to parmetis format. | |
openfpm::vector< size_t > | sub_sub_owner |
Id of the sub-sub-domain where we set the costs. | |
openfpm::vector< rid > | vtxdist |
Init vtxdist needed for Parmetis. | |
openfpm::vector< openfpm::vector< idx_t > > | partitions |
partitions | |
openfpm::vector< openfpm::vector< gid > > | v_per_proc |
Init data structure to keep trace of new vertices distribution in processors (needed to update main graph) | |
std::unordered_map< rid, gid > | m2g |
Hashmap to access to the global position given the re-mapped one (needed for access the map) | |
bool | verticesGotWeights = false |
Flag to check if weights are used on vertices. | |
|
inline |
Constructor for the ParMetis class
v_cl | Vcluster to use as communication object in this class |
Definition at line 287 of file ParMetisDistribution.hpp.
|
inline |
Copy constructor
pm | Distribution to copy |
Definition at line 297 of file ParMetisDistribution.hpp.
|
inline |
Copy constructor
pm | Distribution to copy |
Definition at line 308 of file ParMetisDistribution.hpp.
|
inline |
Create the Cartesian graph.
grid | info |
dom | domain |
Get the number of processing units
Division of vertices in Np graphs Put (div+1) vertices in mod graphs Put div vertices in the rest of the graphs
Definition at line 319 of file ParMetisDistribution.hpp.
|
inline |
|
inline |
In case we do not do Dynamic load balancing this this data-structure it is safe to eliminate the full internal graph.
Definition at line 626 of file ParMetisDistribution.hpp.
|
inline |
Get the decomposition counter.
Definition at line 699 of file ParMetisDistribution.hpp.
|
inline |
Get the current graph (main)
Definition at line 370 of file ParMetisDistribution.hpp.
|
inline |
Return the total number of sub-sub-domains this processor own.
Definition at line 587 of file ParMetisDistribution.hpp.
|
inline |
Returns total number of neighbors of the sub-sub-domain id.
id | id of the sub-sub-domain |
Definition at line 611 of file ParMetisDistribution.hpp.
|
inline |
Returns total number of sub-sub-domains in the distribution graph.
Definition at line 577 of file ParMetisDistribution.hpp.
|
inline |
Return the global id of the owned sub-sub-domain.
id | in the list of owned sub-sub-domains |
Definition at line 599 of file ParMetisDistribution.hpp.
|
inline |
Compute the processor load counting the total weights of its vertices.
Definition at line 523 of file ParMetisDistribution.hpp.
|
inline |
function that get the weight of the vertex
id | vertex id |
Definition at line 509 of file ParMetisDistribution.hpp.
|
inline |
return the the position of the sub-sub-domain
i | sub-sub-domain id |
p | point |
Definition at line 688 of file ParMetisDistribution.hpp.
|
inline |
function that return the position of the vertex in the space
id | vertex id |
pos | vector that will contain x, y, z |
Definition at line 461 of file ParMetisDistribution.hpp.
|
inline |
Compute the unbalance of the processor compared to the optimal balance.
Definition at line 432 of file ParMetisDistribution.hpp.
|
inlineprivate |
Get the global id of the vertex given the re-mapped one.
remapped | id |
Definition at line 182 of file ParMetisDistribution.hpp.
|
inlineprivate |
operator to init ids vector
operator to init ids vector
Definition at line 192 of file ParMetisDistribution.hpp.
|
inlinestaticprivate |
Callback of the sendrecv to set the size of the array received.
msg_i | Index of the message |
total_msg | Total numeber of messages |
total_p | Total number of processors to comunicate with |
i | Processor id |
ri | Request id |
ptr | Void pointer parameter for additional data to pass to the call-back |
Definition at line 216 of file ParMetisDistribution.hpp.
|
inline |
Definition at line 648 of file ParMetisDistribution.hpp.
|
inline |
Definition at line 665 of file ParMetisDistribution.hpp.
|
inlineprivate |
It update the full decomposition.
Get the processor id
Get the number of processing units
Get result partition for this processors
Prepare vector of arrays to contain all partitions
Definition at line 229 of file ParMetisDistribution.hpp.
|
inline |
Redecompose current decomposition.
It makes a redecomposition using Parmetis taking into consideration also migration cost
Definition at line 417 of file ParMetisDistribution.hpp.
|
inline |
Refine current decomposition.
It makes a refinement of the current decomposition using Parmetis function RefineKWay After that it also does the remapping of the graph
Definition at line 400 of file ParMetisDistribution.hpp.
|
inline |
Set communication cost of the edge id.
v_id | Id of the source vertex of the edge |
e | i child of the vertex |
communication | Communication value |
Definition at line 559 of file ParMetisDistribution.hpp.
|
inline |
Function that set the weight of the vertex.
id | vertex id |
weight | to give to the vertex |
Definition at line 481 of file ParMetisDistribution.hpp.
|
inline |
Set the tolerance for each partition.
tol | tolerance |
Definition at line 709 of file ParMetisDistribution.hpp.
|
inlineprivate |
operator to remap vertex to a new position
n | re-mapped position |
g | global position |
Definition at line 171 of file ParMetisDistribution.hpp.
|
inline |
Set migration cost of the vertex id.
id | of the vertex to update |
migration | cost of the migration |
Definition at line 543 of file ParMetisDistribution.hpp.
|
inlineprivate |
Update main graph ad subgraph with the received data of the partitions from the other processors.
Definition at line 91 of file ParMetisDistribution.hpp.
|
inlineprivate |
operator to access the vertex by mapped position
operator to access the vertex
id | re-mapped id of the vertex to access |
Definition at line 160 of file ParMetisDistribution.hpp.
|
inline |
Checks if weights are used on the vertices.
Definition at line 499 of file ParMetisDistribution.hpp.
|
inline |
Print the current distribution and save it to VTK file.
file | filename |
Definition at line 642 of file ParMetisDistribution.hpp.
|
private |
rectangular domain to decompose
Definition at line 48 of file ParMetisDistribution.hpp.
|
private |
Global sub-sub-domain graph.
Definition at line 51 of file ParMetisDistribution.hpp.
|
private |
Structure that store the cartesian grid information.
Definition at line 45 of file ParMetisDistribution.hpp.
|
private |
Is distributed.
Definition at line 39 of file ParMetisDistribution.hpp.
|
private |
Hashmap to access to the global position given the re-mapped one (needed for access the map)
Definition at line 83 of file ParMetisDistribution.hpp.
|
private |
Convert the graph to parmetis format.
Definition at line 54 of file ParMetisDistribution.hpp.
|
private |
partitions
Definition at line 77 of file ParMetisDistribution.hpp.
|
private |
Id of the sub-sub-domain where we set the costs.
Definition at line 57 of file ParMetisDistribution.hpp.
|
private |
Definition at line 42 of file ParMetisDistribution.hpp.
|
private |
Init data structure to keep trace of new vertices distribution in processors (needed to update main graph)
Definition at line 80 of file ParMetisDistribution.hpp.
|
private |
Flag to check if weights are used on vertices.
Definition at line 86 of file ParMetisDistribution.hpp.
|
private |
Init vtxdist needed for Parmetis.
Definition at line 74 of file ParMetisDistribution.hpp.