16#include <TRUST_2_PDI.h>
19int TRUST_2_PDI::PDI_checkpoint_=0;
20int TRUST_2_PDI::PDI_restart_=0;
21int TRUST_2_PDI::PDI_initialized_=0;
22std::vector<std::string> TRUST_2_PDI::shared_data_;
34 ArrOfInt dimensions(nb_dim);
35 for(
int i=0; i< nb_dim; i++)
44 std::string dim_str =
"dim_" + name_str;
45 std::string glob_dim_str =
"glob_dim_" + name_str;
48 PDI_multi_expose(
"dimensions", dim_str.c_str(), dimensions.
addr(), PDI_OUT, glob_dim_str.c_str(), &glob_dim_0, PDI_OUT,
nullptr);
50 PDI_multi_expose(
"dimensions", dim_str.c_str(), dimensions.
addr(), PDI_INOUT, glob_dim_str.c_str(), &glob_dim_0, PDI_INOUT,
nullptr);
62 std::string tname =
"TYPE_" + uname.
getString();
63 char* t =
const_cast<char*
>(type.
getChar());
65 std::string size =
"size_TYPE_" + uname.
getString();
82 PDI_share(
"TYPES", &tmp, PDI_INOUT);
85 std::string size =
"size_TYPE_" + uname.
getString();
87 PDI_share(size.c_str(), &sz, PDI_INOUT);
89 PDI_reclaim(size.c_str());
94 std::string tname =
"TYPE_" + uname.
getString();
95 char* t =
const_cast<char*
>(type.
getChar());
96 PDI_share(tname.c_str(), t, PDI_INOUT);
98 PDI_reclaim(tname.c_str());
100 PDI_reclaim(
"TYPES");
113 int prev_nb_proc = -1;
114 int prev_nb_nodes = -1;
118 PDI_multi_expose(
"ReadConfig",
"nb_proc", &prev_nb_proc, PDI_INOUT,
"nb_nodes", &prev_nb_nodes, PDI_INOUT,
nullptr);
121 envoyer_broadcast(prev_nb_proc,0);
122 envoyer_broadcast(prev_nb_nodes,0);
127 if(nb_proc != prev_nb_proc)
129 Cerr <<
"TRUST_2_PDI::prepareRestart():: PDI Restart Error !" << finl;
130 Cerr <<
"The backup file has been generated with " << prev_nb_proc <<
" processors." << finl;
131 Cerr <<
"The current computation is launched with " << nb_proc <<
" processors." << finl;
132 Cerr <<
"With PDI, you need to restart your computation with the same number of processors used for previous computation." << finl;
135 bool samePartition = nb_nodes == prev_nb_nodes;
143 ArrOfInt nodeRanks(nb_proc);
149 PDI_multi_expose(
"ReadNodeRanks",
"nodeRanks", nodeRanks.
data(), PDI_INOUT,
nullptr);
153 envoyer_broadcast_array(nodeRanks.
data(), nb_proc, 0);
158 for(
int p=0; p<nb_proc; p++)
160 if(nodeRanks[p] == nodeId)
174 read(
"iter", &nb_sauv);
175 std::vector<double> temps(nb_sauv+1);
176 read(
"temps_sauvegardes", temps.data());
179 if (resume_last_time)
182 tinit = temps.back();
183 last_iteration = nb_sauv;
188 auto it = std::find_if(temps.begin(), temps.end(), [&](
const double &t) { return std::fabs(t-tinit) < 1.e-8 ; } );
189 if(it == temps.end())
191 Cerr <<
"------------------------------------------------------------------------------------" << finl;
192 Cerr <<
"Time " << tinit <<
" not found in backup file. Please adjust tinit in your datafile " << finl;
193 Cerr <<
"Available times are:" << finl;
196 Cerr << finl <<
"------------------------------------------------------------------------------------" << finl;
199 last_iteration = (int)std::distance(temps.begin(),it);
203 write(
"iter", &last_iteration);
204 write(
"temps", &tinit);
: Cette classe decrit un groupe de processeurs sur lesquels
virtual void mp_collective_op(const double *x, double *resu, int n, Collective_Op op) const =0
int get_number_of_nodes() const
Une chaine de caractere (Nom) en majuscules.
class Nom Une chaine de caractere pour nommer les objets de TRUST
const char * getChar() const
int longueur() const
Renvoie le nombre de caracteres de la chaine du Nom y compris le caractere zero de fin de chaine.
const std::string & getString() const
static int enter_group(const Comm_Group &group)
Si le processeur local appartient au groupe, le groupe courant pour ce processeur devient "group" et ...
static void create_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel=0)
Creation d'un nouveau groupe de processeurs (utilisation possible n'importe ou dans le code).
static const Comm_Group & get_node_group()
Renvoie une reference au groupe sur les noeuds.
static void exit_group()
Retourne dans le groupe ou l'on etait avant le dernier enter_group() reussi (dont le resultat a ete 1...
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
void append_array(_TYPE_ valeur)
_SIZE_ dimension_tot(int) const override
void share_type(const Nom &name, const Nom &type)
Generic method to share the type of a TRUST object.
void read(const std::string &name, void *data)
void write(const std::string &name, const void *data)
void prepareRestart(OWN_PTR(Comm_Group)&nodeGroup, int &last_iteration, double &tinit, int resume_last_time)
Generic method to prepare the restart of a computation.
void get_type(const Nom &name, Nom &type)
Generic method to read the type of a TRUST object in the HDF5 file.
void share_TRUSTTab_dimensions(const DoubleTab &tab, const Nom &name, int write)
Generic method to share the dimensions of a TRUST DoubleTab with PDI.
static void share_parallelism(const Comm_Group &grp, int group_rank)
void trigger(const std::string &event)