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);
: This class describes a group of processors on which
virtual void mp_collective_op(const double *x, double *resu, int n, Collective_Op op) const =0
int get_number_of_nodes() const
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
const char * getChar() const
int longueur() const
Returns the number of characters in the Nom string, including the null terminator.
const std::string & getString() const
static int enter_group(const Comm_Group &group)
If the local processor belongs to the group, the current group for this processor becomes "group" and...
static void create_group(const ArrOfInt &liste_pe, OWN_PTR(Comm_Group) &group, int force_Comm_Group_NoParallel=0)
Creates a new processor group (can be called anywhere in the code).
static const Comm_Group & get_node_group()
Returns a reference to the node-level communicator group.
static void exit_group()
Returns to the group that was active before the last successful enter_group() call (which returned 1)...
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static int me()
Returns the rank of the local processor in the current communication group. See Comm_Group::rank() an...
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
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)