16#include <Schema_Comm_Vecteurs.h>
17#include <MD_Vector_composite.h>
18#include <Echange_EV_Options.h>
19#include <MD_Vector_tools.h>
20#include <MD_Vector_seq.h>
21#include <communications.h>
22#include <Schema_Comm.h>
24#include <Perf_counters.h>
30static std::type_index last_type_idx(
typeid(
void *));
31int MD_Vector_tools::last_linesize = 0;
53template <
typename _SIZE_,
typename _TYPE_>
57 TAB* vv =
dynamic_cast<TAB*
>(&v);
61 const _SIZE_ n = t.dimension_tot(0);
62 if (n == sz_r || n == 0) t.resize_dim0(sz, opt);
69 if (n == sz_r || n == 0) { v.
resize(sz, opt); }
78template <
class VECT,
class TAB>
79static void creer_tableau_distribue_(
const MD_Vector& md, VECT& v, RESIZE_OPTIONS opt)
81 if (v.get_md_vector())
88 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_distribue:\n"
89 <<
" Vector already has a parallel vector structure" << finl;
96 bool err = ::resize_tab_or_vect(v, sz, sz_r, opt);
100 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_distribue:\n"
101 <<
" Input vector has wrong size or dimension(0): expected 0 or size_reele=" << sz_r << finl;
107template <
typename _TYPE_,
typename _SIZE_>
111 assert(md_seq !=
nullptr);
117 bool err = ::resize_tab_or_vect(v, sz, -1, opt);
120 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_seq_:\n"
121 <<
" Input vector has wrong size or dimension(0)" << finl;
144 Cerr <<
"Error in MD_Vector_tools::creer_tableau_distribue(): MD_Vector is null" << finl;
148 IntVect* intV =
dynamic_cast<IntVect*
>(&v);
149 DoubleVect* doubleV =
dynamic_cast<DoubleVect*
>(&v);
150 FloatVect* floatV =
dynamic_cast<FloatVect*
>(&v);
152 BigIntVect* bintV =
dynamic_cast<BigIntVect*
>(&v);
153 TIDVect* tidV =
dynamic_cast<TIDVect*
>(&v);
154 BigTIDVect* btidV =
dynamic_cast<BigTIDVect*
>(&v);
155 BigDoubleVect* bdoubleV =
dynamic_cast<BigDoubleVect*
>(&v);
165 if (intV) creer_tableau_seq_<int, int>(md, *intV, opt);
166 else if (doubleV) creer_tableau_seq_<double, int>(md, *doubleV, opt);
167 else if (floatV) creer_tableau_seq_<float, int>(md, *floatV, opt);
169 else if (bintV) creer_tableau_seq_<int, trustIdType>(md, *bintV, opt);
170 else if (tidV) creer_tableau_seq_<trustIdType, int>(md, *tidV, opt);
171 else if (btidV) creer_tableau_seq_<trustIdType, trustIdType>(md, *btidV, opt);
172 else if (bdoubleV) creer_tableau_seq_<double, trustIdType>(md, *bdoubleV, opt);
176 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_seq():\n"
178 <<
"\n Array must be a subtype of IntVect or DoubleVect or FloatVect" << finl;
184 if (intV) creer_tableau_distribue_<IntVect, IntTab>(md, *intV, opt);
185 else if (doubleV) creer_tableau_distribue_<DoubleVect, DoubleTab>(md, *doubleV, opt);
186 else if (floatV) creer_tableau_distribue_<FloatVect, FloatTab>(md, *floatV, opt);
188 else if (tidV) creer_tableau_distribue_<TIDVect, TIDTab>(md, *tidV, opt);
189 else if (bintV || btidV || bdoubleV)
191 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_distribue(const MD_Vector & md, Array_base & v):" << finl
192 <<
" -> Trying to create a distributed array for a 'big' array (greater than 32b) - shoud never be necessary." << finl;
198 Cerr <<
"Internal error in MD_Vector_tools::creer_tableau_distribue(const MD_Vector & md, Array_base & v):\n"
200 <<
"\n Array must be a subtype of IntVect or DoubleVect or FloatVect" << finl;
207template <
typename _TYPE_>
211 const std::type_index type_idx(
typeid(_TYPE_));
213 if ((is_exchange_blocking == IsExchangeBlocking::DefaultBlocking)||(is_exchange_blocking == IsExchangeBlocking::NonBlockingStart))
216 if (md == last_md && v.
line_size() == last_linesize && last_type_idx == type_idx && last_opt == opt)
224 last_type_idx = type_idx;
231 comm.begin_comm(bufferOnDevice);
234 comm.exchange(is_exchange_blocking, kernel_name);
235 if ((is_exchange_blocking == IsExchangeBlocking::DefaultBlocking)||(is_exchange_blocking == IsExchangeBlocking::NonBlockingFinish))
242template<
typename _TYPE_>
248 perform_virtual_exchange(md, v, echange_ev_opt_default,is_exchange_blocking, kernel_name);
255 perform_virtual_exchange(md, v, echange_ev_opt_default);
264 Cerr <<
"select_virtual_exchange_operation operation not implemented" << finl;
269template<
typename _TYPE_>
277 if (sub_type(MD_Vector_seq, md.
valeur()))
return;
279 if (is_exchange_blocking == IsExchangeBlocking::DefaultBlocking) statistics().
begin_count(STD_COUNTERS::virtual_swap);
280 select_virtual_exchange_operation(v.
get_md_vector(), v, opt,is_exchange_blocking, kernel_name);
281 if (is_exchange_blocking == IsExchangeBlocking::DefaultBlocking) statistics().
end_count(STD_COUNTERS::virtual_swap);
288void MD_Vector_tools::echange_espace_virtuel(TIDVect& v, Operations_echange opt, IsExchangeBlocking is_exchange_blocking,
const std::string kernel_name) { call_virtual_exchange<trustIdType>(v,opt,is_exchange_blocking, kernel_name); }
295 Cerr <<
"MD_Vector_tools::compute_sequential_items_index" << finl;
314 Cerr <<
"Internal error in MD_Vector_tools::creer_md_vect_renum: descripteur nul !" << finl;
319 Cerr <<
"Internal error in MD_Vector_tools::creer_md_vect_renum: line_size != 1" << finl;
339 for (
int i = 0; i < n; i++)
341 int x = flags_renum[i];
343 flags_renum[i] = count++;
381 md_ptr.typer(md_type);
382 is >> md_ptr.valeur();
386 md.
copy(md_ptr.valeur());
389 toto.
resize(md_ptr->get_nb_items_tot(), RESIZE_OPTIONS::NOCOPY_NOINIT);
Empty class used as a base for all the arrays.
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int get(int *ob, std::streamsize n)
Base class for distributed vectors parallel descriptors.
virtual void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
virtual void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
virtual void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
virtual int get_nb_items_tot() const
virtual int get_nb_items_reels() const
virtual void fill_md_vect_renum(const IntVect &renum, MD_Vector &md_vect) const =0
Dummy parallel descriptor used for sequential computations.
trustIdType get_nb_items() const
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
void copy(const MD_Vector_base &)
construction d'un objet MD_Vector par copie d'un objet existant.
const MD_Vector_base & valeur() const
class Nom Une chaine de caractere pour nommer les objets de TRUST
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
void begin_count(const STD_COUNTERS &std_cnt, int counter_lvl=-100000)
void end_count(const std::string &custom_count_name, int count_increment=1, long int quantity_increment=0)
End the count of a counter and update the counter values.
static int check_int_overflow(trustIdType)
static bool is_parallel()
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Classe de base des flux de sortie.
virtual int put(const unsigned *ob, std::streamsize n, std::streamsize nb_colonnes=1)
_SIZE_ size_array() const
bool isDataOnDevice() const
: Tableau a n entrees pour n<= 4.
_SIZE_ size_totale() const
virtual void set_md_vector(const MD_Vector &)
void reset() override
met l'objet dans l'etat obtenu par le constructeur par defaut.
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual const MD_Vector & get_md_vector() const
virtual void ref(const TRUSTVect &)