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. More... | |
Graph_CSR< nm_v, nm_e > & | getGraph () |
Get the current graph (main) More... | |
void | decompose () |
Create the decomposition. More... | |
void | refine () |
Refine current decomposition. More... | |
void | redecompose () |
Redecompose current decomposition. More... | |
float | getUnbalance () |
Compute the unbalance of the processor compared to the optimal balance. More... | |
void | getSubSubDomainPosition (size_t id, T(&pos)[dim]) |
function that return the position of the vertex in the space More... | |
void | setComputationCost (size_t id, size_t weight) |
Function that set the weight of the vertex. More... | |
bool | weightsAreUsed () |
Checks if weights are used on the vertices. More... | |
size_t | getSubSubDomainComputationCost (size_t id) |
function that get the weight of the vertex More... | |
size_t | getProcessorLoad () |
Compute the processor load counting the total weights of its vertices. More... | |
void | setMigrationCost (size_t id, size_t migration) |
Set migration cost of the vertex id. More... | |
void | setCommunicationCost (size_t v_id, size_t e, size_t communication) |
Set communication cost of the edge id. More... | |
size_t | getNSubSubDomains () const |
Returns total number of sub-sub-domains in the distribution graph. More... | |
size_t | getNOwnerSubSubDomains () const |
Return the total number of sub-sub-domains this processor own. More... | |
size_t | getOwnerSubSubDomain (size_t id) const |
Return the global id of the owned sub-sub-domain. More... | |
size_t | getNSubSubDomainNeighbors (size_t id) |
Returns total number of neighbors of the sub-sub-domain id. More... | |
void | write (const std::string &file) |
Print the current distribution and save it to VTK file. More... | |
const ParMetisDistribution < dim, T > & | operator= (const ParMetisDistribution< dim, T > &dist) |
const ParMetisDistribution < dim, T > & | operator= (ParMetisDistribution< dim, T > &&dist) |
size_t | get_ndec () |
Get the decomposition counter. More... | |
void | setDistTol (double tol) |
Set the tolerance for each partition. More... | |
Private Member Functions | |
void | updateGraphs () |
Update main graph ad subgraph with the received data of the partitions from the other processors. More... | |
auto | vertexByMapId (rid id) -> decltype(gp.vertex(m2g.find(id) ->second.id)) |
operator to access the vertex by mapped position More... | |
void | setMapId (rid n, gid g) |
operator to remap vertex to a new position More... | |
gid | getVertexGlobalId (rid n) |
Get the global id of the vertex given the re-mapped one. More... | |
void | initLocalToGlobalMap () |
operator to init ids vector More... | |
void | postDecomposition () |
It update the full decomposition. More... | |
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, void *ptr) |
Callback of the sendrecv to set the size of the array received. More... | |
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, nm_e > | gp |
Global sub-sub-domain graph. | |
Parmetis< Graph_CSR< nm_v, 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 286 of file ParMetisDistribution.hpp.
|
inline |
Copy constructor
pm | Distribution to copy |
Definition at line 296 of file ParMetisDistribution.hpp.
|
inline |
Copy constructor
pm | Distribution to copy |
Definition at line 307 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 318 of file ParMetisDistribution.hpp.
|
inline |
|
inline |
Get the decomposition counter.
Definition at line 671 of file ParMetisDistribution.hpp.
|
inline |
Get the current graph (main)
Definition at line 369 of file ParMetisDistribution.hpp.
|
inline |
Return the total number of sub-sub-domains this processor own.
Definition at line 586 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 610 of file ParMetisDistribution.hpp.
|
inline |
Returns total number of sub-sub-domains in the distribution graph.
Definition at line 576 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 598 of file ParMetisDistribution.hpp.
|
inline |
Compute the processor load counting the total weights of its vertices.
Definition at line 522 of file ParMetisDistribution.hpp.
|
inline |
function that get the weight of the vertex
id | vertex id |
Definition at line 508 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 460 of file ParMetisDistribution.hpp.
|
inline |
Compute the unbalance of the processor compared to the optimal balance.
Definition at line 431 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.
|
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 416 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 399 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 558 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 480 of file ParMetisDistribution.hpp.
|
inline |
Set the tolerance for each partition.
tol | tolerance |
Definition at line 681 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 542 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 498 of file ParMetisDistribution.hpp.
|
inline |
Print the current distribution and save it to VTK file.
file | filename |
Definition at line 625 of file ParMetisDistribution.hpp.