15#include <Partitionneur_Parmetis.h>
17#include <Static_Int_Lists.h>
18#include <parmetis++.h>
21#include <communications.h>
22#include <Poly_geom_base.h>
23#include <Matrix_tools.h>
24#include <Matrice_Morse.h>
25#include <Array_tools.h>
26#include <Comm_Group_MPI.h>
28#include <Domain_Graph.h>
29#include <MD_Vector_tools.h>
31inline void not_implemented(
const Nom& chaine)
33 Cerr << chaine <<
" is not implemented yet to the PARMETIS API." << finl;
39Implemente_instanciable_sans_constructeur(
Partitionneur_Parmetis,
"Partitionneur_Parmetis",Partitionneur_base);
41Partitionneur_Parmetis::Partitionneur_Parmetis()
47 Cerr <<
"Partitionneur_Parmetis::printOn invalid\n" << finl;
62 if (nb_parties_ < 1 || nb_parties_ > 100000)
64 Process::exit(
"Partitionneur_Parmetis::validate_params: The following condition must be satisfied : 1 <= nb_parts <= 100000");
75 ref_domaine_ = domaine;
84 Cerr <<
"PARMETIS is not compiled with this version. Use another partition tool like Tranche." << finl;
90 Cerr <<
"Error in Partitionneur_Parmetis::construire_partition\n";
91 Cerr <<
" The domain has not been associated" << finl;
96 Cerr <<
"Error in Partitionneur_Parmetis::construire_partition\n";
97 Cerr <<
" The parts number has not been initialized" << finl;
103 if (nb_parties_ == 1)
106 int nb_elem = ref_domaine_->nb_elem();
112 if (ref_domaine_->nb_elem() == 0)
115 Cerr <<
"Partitionneur_Parmetis::construire_partition" << finl;
116 Cerr <<
" Construction of graph connectivity..." << finl;
117 Static_Int_Lists graph_elements_perio;
122 graph_elements_perio);
125 std::vector<idx_t> partition(graph.
nvtxs);
127 idx_t int_parts = nb_parties_;
129 Cerr <<
" Call for PARMETIS" << finl;
132 options[1] = 111111111;
136 real_t ubvec = 1.05f;
138 std::vector<real_t> tpwgts(ncon*int_parts, (real_t)(1.0/nb_parties_));
139 MPI_Comm comm = Comm_Group_MPI::get_trio_u_world();
142 &numflag, &ncon, &int_parts, tpwgts.data(), &ubvec, options ,
143 &edgecut, partition.data(), &comm);
144 if (status != METIS_OK)
146 Cerr <<
"Call to PARMETIS failed." << finl;
147 if (status == METIS_ERROR) Cerr <<
"It seems there is a PARMETIS internal error." << finl;
148 Cerr <<
"Contact TRUST support." << finl;
152 Cerr <<
"Partitioning quality : edgecut = " << edgecut << finl;
153 Cerr <<
"-> It is roughly the total number of edges (faces) which will be shared by the processors." << finl;
154 Cerr <<
"-> The lesser this number is, the lesser the total volume of communication between processors." << finl;
155 Cerr <<
"-> You can increase nb_essais option (default 1) to try to reduce (but at a higher CPU cost) this number." << finl;
156 Cerr <<
"===============" << finl;
159 const int n = ref_domaine_->nb_elem();
160 for (
int i = 0; i < n; i++)
161 elem_part[i] =
static_cast<int>(partition[i]);
166 Cerr <<
"Correction of the partition for the periodicity" << finl;
170 Cerr <<
" If this number is high, we can improve the splitting with the option use_weights\n"
171 <<
" but it takes more memory)" << finl;
174 Cerr <<
"Correction elem0 on processor 0" << finl;
Build the graph of the domain that the METIS/PARMETIS/PTSCOTCH libraries need.
void construire_graph_elem_elem(const Domaine_32_64< _SIZE_ > &dom, bool use_weights, Static_Int_Lists_32_64< _SIZE_ > &graph_elements_perio)
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
virtual void set_param(Param &) const
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Helper class to factorize the readOn method of Objet_U classes.
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Partition of a domain into nb_parties balanced parts using the PARMETIS library.
void associer_domaine(const Domaine &domaine) override
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Computes the connectivity graph for parmetis, calls the partitioner and fills elem_part (for each ele...
void validate_params() const override
Called in the readOn of Objet_U_With_Params, after reading the params.
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
int lire_motcle_non_standard(const Motcle &, Entree &) override
static void corriger_bords_avec_liste(const Domaine_t &dom, const int_t my_offset, BigIntVect_ &elem_part)
static void corriger_elem0_sur_proc0(BigIntVect_ &elem_part)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
int_t get_nb_lists() const
Returns the number of stored lists.
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")