16#include <MD_Vector_std.h>
18#include <Array_tools.h>
56 assert(nb_items_tot >= 0);
57 assert(nb_items_reels >= -1 && nb_items_reels <= nb_items_tot);
60 const int nb_voisins =
pe_voisins.size_array();
67 ArrOfInt tmp, selection;
71 for (i = 0; i < nb_voisins; i++)
82 ArrsOfInt tmpbis(nb_voisins2);
84 for (i = 0; i < nb_voisins2; i++)
88 for (i = 0; i < nb_voisins2; i++)
92 for (i = 0; i < nb_voisins2; i++)
102 for (i = 0; i < nb_voisins2; i++)
105 envoyer_all_to_all(tmp, tmp);
106 for (i = 0; i < nb_voisins2; i++)
116 for (i = 0; i < nb_voisins2; i++)
120 for (
int j = 0; j < nblocs; j++)
131 tmp.
resize_array(nb_items_tot, RESIZE_OPTIONS::NOCOPY_NOINIT);
137 for (i = 0; i < n; i++)
139 assert(tmp[items[i]] == 1);
145 for (i = 0; i < n; i++)
147 const int start = items2[i * 2];
148 const int end = items2[i * 2 + 1];
149 for (
int j = start; j < end; j++)
160 for (i = 0; i < nb_items_tot; i++)
164 if (nb_items_reels >= 0 && i >= nb_items_reels)
167 Cerr <<
"Error in MD_Vector_std::MD_Vector_std(...) [pe " <<
me() <<
"]\n "
168 "an item i(" << i <<
") > nb_items_reels(" << nb_items_reels <<
") is not received from any other processor" << finl;
207 ArrOfInt items_send_index, items_send_data, items_index, items_data, blocs_index, blocs_data;
209 p.ajouter(
"items_to_send_index", &items_send_index);
210 p.ajouter(
"items_to_send_data", &items_send_data);
212 p.ajouter(
"items_to_recv_index", &items_index);
213 p.ajouter(
"items_to_recv_data", &items_data);
214 p.ajouter(
"blocs_to_recv_index", &blocs_index);
215 p.ajouter(
"blocs_to_recv_data", &blocs_data);
217 p.lire_avec_accolades(is);
236 os <<
"pe_voisins" << tspace <<
pe_voisins_ << finl;
237 os <<
"items_to_send_index" << tspace <<
items_to_send_.get_index() << finl;
238 os <<
"items_to_send_data" << tspace <<
items_to_send_.get_data() << finl;
240 os <<
"items_to_recv_index" << tspace <<
items_to_recv_.get_index();
241 os <<
"items_to_recv_data" << tspace <<
items_to_recv_.get_data();
242 os <<
"blocs_to_recv_index" << tspace <<
blocs_to_recv_.get_index() << finl;
243 os <<
"blocs_to_recv_data" << tspace <<
blocs_to_recv_.get_data();
254int find_in_array(
const ArrOfInt& a,
int x)
265int extract_blocs(
const ArrOfInt src,
const ArrOfInt& renum, ArrOfInt& dest)
270 int end_last_bloc = -1;
272 for (
int i = 0; i < nblocs_src; i++)
274 const int deb = src[i*2];
275 const int fin = src[i*2+1];
276 for (
int j = deb; j < fin; j++)
278 const int rj = renum[j];
283 assert(rj >= end_last_bloc);
284 if (rj == end_last_bloc)
313 ArrOfInt x_sz, y_sz, z_sz;
315 ArrOfInt x_data, y_data, z_data;
316 ArrOfInt new_blocs_items_count, new_nb_items_to_items;
321 array_trier_retirer_doublons(pe_list);
327 for (
int i = 0; i < np; i++)
330 int nx = 0, ny = 0, nz = 0;
338 const int pe = pe_list[i];
345 nx += count_items_single;
349 for (
int k = 0; k < count_items_single; k++)
363 nx += count_items_single * multiplier;
367 for (
int k = 0; k < count_items_single; k++)
375 const int single_items_count = nx;
382 nx += count_items_tot - count_items_single;
385 for (
int k = count_items_single; k < count_items_tot; k++)
401 nx += (count_items_tot - count_items_single) * multiplier;
404 for (
int k = count_items_single; k < count_items_tot; k++)
418 new_blocs_items_count[i] = blocs_count;
419 new_nb_items_to_items[i] = single_items_count;
445 for (
int i = 0; i < src_size; i++)
473 const int nb_pe_voisins =
pe_voisins_.size_array();
481 ArrOfInt dest_items_recv_index;
482 ArrOfInt dest_items_recv_data;
483 ArrOfInt dest_blocs_recv_index;
484 ArrOfInt dest_blocs_recv_data;
489 dest_items_recv_index.
resize_array(nb_pe_voisins + 1, RESIZE_OPTIONS::NOCOPY_NOINIT);
490 dest_items_recv_index[0] = 0;
491 dest_blocs_recv_index.
resize_array(nb_pe_voisins + 1, RESIZE_OPTIONS::NOCOPY_NOINIT);
492 dest_blocs_recv_index[0] = 0;
501 for (
int i_pe = 0; i_pe < nb_pe_voisins; i_pe++)
508 for (
int i = 0; i < n; i++)
511 const int rj = renum[j];
522 dest_items_recv_index[i_pe+1] = dest_items_recv_data.
size_array();
527 int received_count = 0;
528 for (
int ibloc = 0; ibloc < nblocs; ibloc++)
534 for (
int j = jdeb; j < jfin; j++)
536 const int rj = renum[j];
539 if (rj <= last_added)
544 Cerr <<
"Error in creer_md_vect_renum: renum array is not sorted: cannot extract blocs to recv" << finl;
548 if (last_added == rj-1)
551 const int k = dest_blocs_recv_data.
size_array();
553 dest_blocs_recv_data[k-1] = rj+1;
570 dest_blocs_recv_index[i_pe+1] = dest_blocs_recv_data.
size_array();
583 ArrOfInt dest_items_send_index;
584 dest_items_send_index.
resize_array(nb_pe_voisins + 1, RESIZE_OPTIONS::NOCOPY_NOINIT);
585 ArrOfInt dest_items_send_data;
586 ArrOfInt nb_items_to_items(nb_pe_voisins);
590 dest_items_send_index[0] = 0;
594 for (
int i_pe = 0; i_pe < nb_pe_voisins; i_pe++)
600 for (
int i = 0; i < n; i++)
606 int renum_k = renum[k];
612 dest_items_send_data[count++] = renum_k;
614 dest_items_send_index[i_pe+1] = count;
618 Cerr <<
"Internal error in MD_Vector_tools::creer_md_vect_renum:\n"
620 <<
" received a request for distant items that are not in the new vector" << finl;
631 for (
int i_pe = 0; i_pe < nb_pe_voisins; i_pe++)
632 schema_comm.
send_buffer(
pe_voisins_[i_pe]) << dest_items_recv_index(i_pe + 1) - dest_items_recv_index(i_pe);
634 for (
int i_pe = 0; i_pe < nb_pe_voisins; i_pe++)
645 for (
int i_pe = 0; i_pe < nb_pe_voisins; i_pe++)
648 if (dest_items_recv_index[i_pe+1] - dest_items_recv_index[i_pe] > 0)
650 if (dest_blocs_recv_index[i_pe+1] - dest_blocs_recv_index[i_pe] > 0)
652 if (dest_items_send_index[i_pe+1] - dest_items_send_index[i_pe] > 0)
657 dest_items_recv_index[pe_count+1] = dest_items_recv_index[i_pe+1];
658 dest_blocs_recv_index[pe_count+1] = dest_blocs_recv_index[i_pe+1];
659 dest_items_send_index[pe_count+1] = dest_items_send_index[i_pe+1];
Class defining operators and methods for all reading operation in an input flow (file,...
static void append_blocs(ArrOfInt &dest, const ArrOfInt &src, int offset=0, int multiplier=1)
trustIdType nb_items_seq_tot_
static void append_items(ArrOfInt &dest, const ArrOfInt &src, int offset=0, int multiplier=1)
virtual int get_nb_items_tot() const
virtual int get_nb_items_reels() const
static void append_item_to_blocs(ArrOfInt &blocs, int item)
Helper method to append an item to a "blocs"-type array containing series of blocks.
Generic class for all mono-block MD_Vectors (i.e. non compoosite).
ArrOfInt blocs_items_to_sum_
ArrOfInt blocs_items_to_compute_
This is the simplest descriptor, used for arrays of values at vertices, elements, faces,...
Static_Int_Lists items_to_send_
ArrOfInt blocs_items_count_
const Static_Int_Lists & items_to_recv() const
void fill_md_vect_renum(const IntVect &renum, MD_Vector &md_vect) const override
const ArrOfInt & pe_voisins() const
Static_Int_Lists items_to_recv_
MD_Vector_std(int n)
Stupid ctor.
const Static_Int_Lists & items_to_send() const
const Static_Int_Lists & blocs_to_recv() const
void append_from_other_std(const MD_Vector_std &src, int offset, int multiplier) override
Static_Int_Lists blocs_to_recv_
ArrOfInt nb_items_to_items_
void copy(const MD_Vector_base &)
Constructs an MD_Vector object by copying an existing object.
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
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.
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
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.
void echange_taille_et_messages() const
Launches the data exchange between all processors.
Sortie & send_buffer(int num_PE) const
Returns the buffer corresponding to processor num_PE to stack data to send.
void end_comm() const
Clears the buffers and releases resources: reading of received data from buffers is complete.
Entree & recv_buffer(int num_PE) const
Returns the buffer corresponding to processor num_PE to read received data.
void begin_comm() const
Reserves communication buffers for a new communication.
void set_send_recv_pe_list(const ArrOfInt &send_pe_list, const ArrOfInt &recv_pe_list, const int me_to_me=0)
Defines the list of processors to send data to and receive data from.
Base class for output streams.
void copy_list_to_array(int_t i_liste, ArrOfInt_t &array) const
Copies the i-th list into the provided array. The array must be resizable.
void set_index_data(const ArrOfInt_t &index, const ArrOfInt_t &data)
Replaces index and data arrays.
int_t get_list_size(int_t i_liste) const
Returns the number of elements in list i.
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)