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;
86 Cerr <<
"PARMETIS is not compiled with this version. Use another partition tool like Tranche." << finl;
92 Cerr <<
"Error in Partitionneur_Parmetis::construire_partition\n";
93 Cerr <<
" The domain has not been associated" << finl;
98 Cerr <<
"Error in Partitionneur_Parmetis::construire_partition\n";
99 Cerr <<
" The parts number has not been initialized" << finl;
105 if (nb_parties_ == 1)
108 int nb_elem = ref_domaine_->nb_elem();
114 if (ref_domaine_->nb_elem() == 0)
117 Cerr <<
"Partitionneur_Parmetis::construire_partition" << finl;
118 Cerr <<
" Construction of graph connectivity..." << finl;
119 Static_Int_Lists graph_elements_perio;
124 graph_elements_perio);
127 std::vector<idx_t> partition(graph.
nvtxs);
129 idx_t int_parts = nb_parties_;
131 Cerr <<
" Call for PARMETIS" << finl;
134 options[1] = 111111111;
138 real_t ubvec = 1.05f;
140 std::vector<real_t> tpwgts(ncon*int_parts, (real_t)(1.0/nb_parties_));
141 MPI_Comm comm = Comm_Group_MPI::get_trio_u_world();
144 &numflag, &ncon, &int_parts, tpwgts.data(), &ubvec, options ,
145 &edgecut, partition.data(), &comm);
146 if (status != METIS_OK)
148 Cerr <<
"Call to PARMETIS failed." << finl;
149 if (status == METIS_ERROR) Cerr <<
"It seems there is a PARMETIS internal error." << finl;
150 Cerr <<
"Contact TRUST support." << finl;
154 Cerr <<
"Partitioning quality : edgecut = " << edgecut << finl;
155 Cerr <<
"-> It is roughly the total number of edges (faces) which will be shared by the processors." << finl;
156 Cerr <<
"-> The lesser this number is, the lesser the total volume of communication between processors." << finl;
157 Cerr <<
"-> You can increase nb_essais option (default 1) to try to reduce (but at a higher CPU cost) this number." << finl;
158 Cerr <<
"===============" << finl;
161 const int n = ref_domaine_->nb_elem();
162 for (
int i = 0; i < n; i++)
163 elem_part[i] =
static_cast<int>(partition[i]);
168 Cerr <<
"Correction of the partition for the periodicity" << finl;
172 Cerr <<
" If this number is high, we can improve the splitting with the option use_weights\n"
173 <<
" but it takes more memory)" << finl;
176 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)
Une chaine de caractere (Nom) en majuscules.
class Nom Une chaine de caractere pour nommer les objets de TRUST
virtual void set_param(Param &) const
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
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 d'un domaine en nb_parties parties equilibrees en utilisant la librairie PARMETIS.
void associer_domaine(const Domaine &domaine) override
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Calcule le graphe de connectivite pour parmetis, appelle le partitionneur et remplit elem_part (pour ...
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
Lecture des parametres de type non simple d'un objet_U a partir d'un flot d'entree.
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)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
int_t get_nb_lists() const
renvoie le nombre de listes stockees
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")