Ice Sheet System Model  4.18
Code documentation
IssmMpiVec.h
Go to the documentation of this file.
1 
9 #ifndef _ISSM_MPI_VEC_H_
10 #define _ISSM_MPI_VEC_H_
11 
12 /*Headers:*/
13 /*{{{*/
14 #ifdef HAVE_CONFIG_H
15  #include <config.h>
16 #else
17 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
18 #endif
19 
20 #include "../../shared/Exceptions/exceptions.h"
21 #include "../../shared/MemOps/MemOps.h"
22 #include "../../shared/io/io.h"
23 #include "../mpi/issmmpi.h"
24 #include <math.h>
25 
26 /*}}}*/
27 
28 /*We need to template this class, in case we want to create vectors that hold IssmDouble* vector or IssmPDouble* vector.
29  Such vectors would be useful for use without or with the matlab or python interface (which do not care for IssmDouble types,
30  but only rely on IssmPDouble types)*/
31 template <class doubletype> class IssmAbsVec;
32 
33 template <class doubletype>
34 class IssmMpiVec:public IssmAbsVec<doubletype>{
35 
36  public:
37 
38  int M; //global size
39  int m; //local number of rows
40  doubletype* vector; /*here, doubletype is either IssmDouble or IssmPDouble*/
41  DataSet* buckets; /*here, we store buckets of values that we will Assemble into a global vector.*/
42 
43  /*IssmMpiVec constructors, destructors*/
44  IssmMpiVec(){/*{{{*/
45 
46  this->M=0;
47  this->m=0;
48  this->vector=NULL;
49  this->buckets=new DataSet();
50  }
51  /*}}}*/
52  IssmMpiVec(int Min){/*{{{*/
53  this->Init(Min,false);
54  }
55  /*}}}*/
56  IssmMpiVec(int min, int Min){/*{{{*/
57  this->Init(min,true);
58  }
59  /*}}}*/
60  IssmMpiVec(int Min, bool fromlocalsize){/*{{{*/
61  this->Init(Min,fromlocalsize);
62  }
63  /*}}}*/
64  IssmMpiVec(doubletype* buffer,int Min){/*{{{*/
65 
66  this->Init(Min,false);
67 
68  if(this->M){
69 // AD performance is sensitive to calls to ensurecontiguous.
70 // Providing "t" will cause ensurecontiguous to be called.
71 #ifdef _HAVE_AD_
72  this->vector=xNew<doubletype>(this->m,"t");
73 #else
74  this->vector=xNew<doubletype>(this->m);
75 #endif
76 
77  xMemCpy<doubletype>(this->vector,buffer,this->m);
78  }
79  }
80  /*}}}*/
81  IssmMpiVec(doubletype* buffer,int Min,int min){/*{{{*/
82 
83  this->vector=NULL;
84  this->buckets=new DataSet();
85  this->M=Min;
86  this->m=min;
87 
88  if(this->m){
89 // AD performance is sensitive to calls to ensurecontiguous.
90 // Providing "t" will cause ensurecontiguous to be called.
91 #ifdef _HAVE_AD_
92  this->vector=xNew<doubletype>(this->m,"t");
93 #else
94  this->vector=xNew<doubletype>(this->m);
95 #endif
96 
97  xMemCpy<doubletype>(this->vector,buffer,this->m);
98  }
99  }
100  /*}}}*/
101  void Init(int Min,bool fromlocalsize){/*{{{*/
102 
103  this->buckets=new DataSet();
104 
105  if(fromlocalsize){
106  this->m=Min;
107  this->M=DetermineGlobalSize(this->m,IssmComm::GetComm());
108  }
109  else{
110  this->M=Min;
111  this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
112  }
113 
114  /*Initialize pointer: */
115  this->vector=NULL;
116 
117  /*Allocate: */
118 // AD performance is sensitive to calls to ensurecontiguous.
119 // Providing "t" will cause ensurecontiguous to be called.
120 #ifdef _HAVE_AD_
121  if (m)this->vector=xNewZeroInit<doubletype>(this->m,"t");
122 #else
123  if (m)this->vector=xNewZeroInit<doubletype>(this->m);
124 #endif
125 
126  }
127  /*}}}*/
128  ~IssmMpiVec(){/*{{{*/
129  xDelete<doubletype>(this->vector);
130  this->M=0;
131  this->m=0;
132  delete buckets;
133  }
134  /*}}}*/
135 
136  /*IssmMpiVec specific routines*/
137  void Echo(void){/*{{{*/
138 
139  int i,j;
140 
141  /*Do a synchronized dump across all the rows: */
142  for(i=0;i<IssmComm::GetSize();i++){
144  }
145  }
146  /*}}}*/
147  void Assemble(){/*{{{*/
148 
149  int i,j;
150 
151  int *RowRank = NULL;
152  int num_procs;
153 
154  int *row_indices_forcpu = NULL;
155  int *modes_forcpu = NULL;
156  doubletype *values_forcpu = NULL;
157  int *numvalues_forcpu = NULL;
158  DataSet **bucketsforcpu = NULL;
159 
160  int **row_indices_fromcpu = NULL;
161  int **col_indices_fromcpu = NULL;
162  int **modes_fromcpu = NULL;
163  doubletype **values_fromcpu = NULL;
164  int *numvalues_fromcpu = NULL;
165 
166  int lower_row;
167  int upper_row;
168  int* sendcnts = NULL;
169  int* displs = NULL;
170  int count = 0;
171 
172  /*some communicator info: */
173  num_procs=IssmComm::GetSize();
175 
176  /*First, make a vector of size M, which for each row between 0 and M-1, tells which cpu this row belongs to: */
177  RowRank=DetermineRowRankFromLocalSize(M,m,comm);
178 
179  /*Now, sort out our dataset of buckets according to cpu ownership of rows: {{{*/
180  bucketsforcpu=xNew<DataSet*>(num_procs);
181 
182  for(i=0;i<num_procs;i++){
183  DataSet* bucketsofcpu_i=new DataSet();
184  for (j=0;j<buckets->Size();j++){
186  bucket->SpawnBucketsPerCpu(bucketsofcpu_i,i,RowRank);
187  }
188  bucketsforcpu[i]=bucketsofcpu_i;
189  }
190  /*}}}*/
191 
192  /*Recap, each cpu has num_procs datasets of buckets. For a certain cpu j, for a given dataset i, the buckets this {{{
193  * dataset owns correspond to rows that are owned by cpu i, not j!. Out of all the buckets we own, make row,col,value,insert_mode
194  * vectors that will be shipped around the cluster: */
195  this->BucketsBuildScatterBuffers(&numvalues_forcpu,&row_indices_forcpu,&values_forcpu,&modes_forcpu,bucketsforcpu,num_procs);
196  /*}}}*/
197 
198  /*Now, we need to allocate on each cpu arrays to receive data from all the other cpus. To know what we need to allocate, we need {{{
199  *some scatter calls: */
200  numvalues_fromcpu = xNew<int>(num_procs);
201  for(i=0;i<num_procs;i++){
202  ISSM_MPI_Scatter(numvalues_forcpu,1,ISSM_MPI_INT,numvalues_fromcpu+i,1,ISSM_MPI_INT,i,comm);
203  }
204 
205  row_indices_fromcpu=xNew<int*>(num_procs);
206  values_fromcpu=xNew<doubletype*>(num_procs);
207  modes_fromcpu=xNew<int*>(num_procs);
208  for(i=0;i<num_procs;i++){
209  int size=numvalues_fromcpu[i];
210  if(size){
211  row_indices_fromcpu[i]=xNew<int>(size);
212 // AD performance is sensitive to calls to ensurecontiguous.
213 // Providing "t" will cause ensurecontiguous to be called.
214 #ifdef _HAVE_AD_
215  values_fromcpu[i]=xNew<doubletype>(size,"t");
216 #else
217  values_fromcpu[i]=xNew<doubletype>(size);
218 #endif
219 
220  modes_fromcpu[i]=xNew<int>(size);
221  }
222  else{
223  row_indices_fromcpu[i]=NULL;
224  values_fromcpu[i]=NULL;
225  modes_fromcpu[i]=NULL;
226  }
227  }
228  /*}}}*/
229 
230  /*Scatter values around: {{{*/
231  /*Now, to scatter values across the cluster, we need sendcnts and displs. Our sendbufs have been built by BucketsBuildScatterBuffers, with a stride given
232  * by numvalues_forcpu. Get this ready to go before starting the scatter itslef. For reference, here is the ISSM_MPI_Scatterv prototype:
233  * int ISSM_MPI_Scatterv( void *sendbuf, int *sendcnts, int *displs, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm) :*/
234  sendcnts=xNew<int>(num_procs);
235  displs=xNew<int>(num_procs);
236  count=0;
237  for(i=0;i<num_procs;i++){
238  sendcnts[i]=numvalues_forcpu[i];
239  displs[i]=count;
240  count+=numvalues_forcpu[i];
241  }
242 
243  for(i=0;i<num_procs;i++){
244  ISSM_MPI_Scatterv( row_indices_forcpu, sendcnts, displs, ISSM_MPI_INT, row_indices_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
245  ISSM_MPI_Scatterv( values_forcpu, sendcnts, displs, TypeToMPIType<doubletype>(), values_fromcpu[i], numvalues_fromcpu[i], TypeToMPIType<doubletype>(), i, comm);
246  ISSM_MPI_Scatterv( modes_forcpu, sendcnts, displs, ISSM_MPI_INT, modes_fromcpu[i], numvalues_fromcpu[i], ISSM_MPI_INT, i, comm);
247  }
248  /*}}}*/
249 
250  /*Plug values into global vector: {{{*/
251  GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,comm);
252  for(i=0;i<num_procs;i++){
253  int numvalues=numvalues_fromcpu[i];
254  int* rows=row_indices_fromcpu[i];
255  doubletype* values=values_fromcpu[i];
256  int* mods=modes_fromcpu[i];
257 
258  for(j=0;j<numvalues;j++){
259  if(mods[j]==ADD_VAL) *(vector+(rows[j]-lower_row))+=values[j];
260  else *(vector+(rows[j]-lower_row))=values[j];
261  }
262  }
263  /*}}}*/
264 
265  /*Free ressources:{{{*/
266  xDelete<int>(RowRank);
267  xDelete<int>(row_indices_forcpu);
268  xDelete<int>(modes_forcpu);
269  xDelete<doubletype>(values_forcpu);
270  xDelete<int>(numvalues_forcpu);
271 
272  for(i=0;i<num_procs;i++){
273  DataSet* bucketsn=bucketsforcpu[i];
274  delete bucketsn;
275  }
276  xDelete<DataSet*>(bucketsforcpu);
277 
278  for(i=0;i<num_procs;i++){
279  int* rows=row_indices_fromcpu[i];
280  int* modes=modes_fromcpu[i];
281  doubletype* values=values_fromcpu[i];
282 
283  xDelete<int>(rows);
284  xDelete<int>(modes);
285  xDelete<doubletype>(values);
286  }
287  xDelete<int*>(row_indices_fromcpu);
288  xDelete<int*>(modes_fromcpu);
289  xDelete<doubletype*>(values_fromcpu);
290  xDelete<int>(numvalues_fromcpu);
291 
292  xDelete<int>(sendcnts);
293  xDelete<int>(displs);
294 
295  /*Get rid of all buckets, as we have already added them to the matrix!: */
296  delete this->buckets;
297  this->buckets=new DataSet();
298  /*}}}*/
299 
300  }
301  /*}}}*/
302  void SetValues(int ssize, int* list, doubletype* values, InsMode mode){/*{{{*/
303 
304  /*we need to store all the values we collect here in order to Assemble later.
305  * Indeed, the values we are collecting here most of the time will not belong
306  * to us, but to another part of the vector on another cpu: */
307  _assert_(buckets);
308 
309  buckets->AddObject(new Bucket<doubletype>(ssize, list, values, mode));
310 
311  }
312  /*}}}*/
313  void SetValue(int dof, doubletype value, InsMode mode){/*{{{*/
314 
315  /*we need to store the value we collect here in order to Assemble later.
316  * Indeed, the value we are collecting here most of the time will not belong
317  * to us, but to another part of the vector on another cpu: */
318  _assert_(buckets);
319 
320  buckets->AddObject(new Bucket<doubletype>(1,&dof,&value, mode));
321  }
322  /*}}}*/
323  void GetValue(doubletype* pvalue,int dof){/*{{{*/
324  _error_("Get value on a MpiVec vector not implemented yet!");
325  }
326  /*}}}*/
327  void GetSize(int* pM){/*{{{*/
328 
329  *pM=this->M;
330 
331  }
332  /*}}}*/
333  void GetLocalSize(int* pM){/*{{{*/
334 
335  *pM=this->m;
336 
337  }
338  /*}}}*/
339  void GetLocalVector(doubletype** pvector,int** pindices){/*{{{*/
340 
341  /*First, check that vector size is not 0*/
342  int vector_size;
343  this->GetSize(&vector_size);
344  if(vector_size==0){
345  *pvector=NULL;
346  *pindices=NULL;
347  return;
348  }
349 
350  /*Get Ownership range*/
351  int lower_row,upper_row;
352  GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,IssmComm::GetComm());
353  int range=upper_row-lower_row;
354 
355  /*return NULL if no range*/
356  if(range==0){
357  *pvector=NULL;
358  *pindices=NULL;
359  return;
360  }
361 
362  /*Build indices*/
363  int* indices=xNew<int>(range);
364  for(int i=0;i<range;i++) indices[i]=lower_row+i;
365 
366  /*Get vector*/
367  _assert_(range==this->m);
368  doubletype* values =xNew<doubletype>(range);
369  xMemCpy<doubletype>(values,this->vector,this->m);
370 
371  *pvector = values;
372  *pindices = indices;
373  } /*}}}*/
375 
376  return new IssmMpiVec<doubletype>(this->vector,this->M,this->m);
377 
378  }
379  /*}}}*/
380  void Set(doubletype value){/*{{{*/
381 
382  for(int i=0;i<this->m;i++)this->vector[i]=value;
383 
384  }
385  /*}}}*/
386  void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){/*{{{*/
387 
388  int i;
389 
390  /*Assume X is of the correct type, and downcast: */
391  IssmMpiVec* X=NULL;
392 
393  X=(IssmMpiVec<doubletype>*)Xin;
394 
395  /*y=a*x+y where this->vector is y*/
396  for(i=0;i<this->m;i++)this->vector[i]=a*X->vector[i]+this->vector[i];
397 
398  }
399  /*}}}*/
400  void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){/*{{{*/
401  int i;
402 
403  /*Assume X is of the correct type, and downcast: */
404  IssmMpiVec* X=NULL;
405 
406  X=(IssmMpiVec<doubletype>*)Xin;
407 
408  /*y=x+a*y where this->vector is y*/
409  for(i=0;i<this->m;i++)this->vector[i]=X->vector[i]+a*this->vector[i];
410 
411  }
412  /*}}}*/
413  doubletype* ToMPISerial(void){/*{{{*/
414 
415  /*communicator info: */
416  ISSM_MPI_Comm comm;
417  int num_procs;
418 
419  /*ISSM_MPI_Allgatherv info: */
420  int lower_row,upper_row;
421  int* recvcounts=NULL;
422  int* displs=NULL;
423 
424  /*output: */
425  doubletype* buffer=NULL;
426 
427  /*initialize comm info: */
428  comm=IssmComm::GetComm();
429  num_procs=IssmComm::GetSize();
430 
431 
432  /*Allocate: */
433 // AD performance is sensitive to calls to ensurecontiguous.
434 // Providing "t" will cause ensurecontiguous to be called.
435 #ifdef _HAVE_AD_
436  buffer=xNew<doubletype>(M,"t");
437 #else
438  buffer=xNew<doubletype>(M);
439 #endif
440 
441  recvcounts=xNew<int>(num_procs);
442  displs=xNew<int>(num_procs);
443 
444  /*recvcounts:*/
445  ISSM_MPI_Allgather(&this->m,1,ISSM_MPI_INT,recvcounts,1,ISSM_MPI_INT,comm);
446 
447  /*get lower_row: */
448  GetOwnershipBoundariesFromRange(&lower_row,&upper_row,this->m,comm);
449 
450  /*displs: */
451  ISSM_MPI_Allgather(&lower_row,1,ISSM_MPI_INT,displs,1,ISSM_MPI_INT,comm);
452 
453  /*All gather:*/
454  ISSM_MPI_Allgatherv(this->vector, this->m, TypeToMPIType<doubletype>(), buffer, recvcounts, displs, TypeToMPIType<doubletype>(),comm);
455  /*free ressources: */
456  xDelete<int>(recvcounts);
457  xDelete<int>(displs);
458 
459  /*return: */
460  return buffer;
461 
462  }
463  /*}}}*/
464  doubletype* ToMPISerial0(void){/*{{{*/
465 
466  /*FIXME: Should not broadcast to every cpu*/
467  return this->ToMPISerial();
468 
469  }
470  /*}}}*/
471  void Shift(doubletype shift){/*{{{*/
472  for(int i=0;i<this->m;i++)this->vector[i]+=shift;
473  }
474  /*}}}*/
475  void Copy(IssmAbsVec<doubletype>* toin){/*{{{*/
476 
477  int i;
478 
479  /*Assume toin is of the correct type, and downcast: */
480  IssmMpiVec* to=NULL;
481 
482  to=(IssmMpiVec<doubletype>*)toin;
483 
484  to->M=this->M;
485  for(i=0;i<this->m;i++)to->vector[i]=this->vector[i];
486 
487  }
488  /*}}}*/
489  doubletype Norm(NormMode mode){/*{{{*/
490 
491  doubletype local_norm;
492  doubletype norm;
493  int i;
494 
495  switch(mode){
496  case NORM_INF:
497  local_norm=0.; for(i=0;i<this->m;i++)local_norm=max(local_norm,fabs(this->vector[i]));
498  //local_norm=0; for(i=0;i<this->m;i++)local_norm=max(local_norm,this->vector[i]);
499  ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_MAX, 0, IssmComm::GetComm());
501  return norm;
502  break;
503  case NORM_TWO:
504  local_norm=0.;
505  for(i=0;i<this->m;i++)local_norm+=this->vector[i]*this->vector[i];
506  ISSM_MPI_Reduce(&local_norm, &norm, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
508  return sqrt(norm);
509  break;
510  default:
511  _error_("unknown norm !");
512  break;
513  }
514  }
515  /*}}}*/
516  void Scale(doubletype scale_factor){/*{{{*/
517 
518  int i;
519  for(i=0;i<this->M;i++)this->vector[i]=scale_factor*this->vector[i];
520 
521  }
522  /*}}}*/
523  doubletype Dot(IssmAbsVec<doubletype>* inputin){/*{{{*/
524 
525  int i;
526  doubletype local_dot=0;
527  doubletype dot=0;
528 
529  /*Assume inputin is of the correct type, and downcast: */
530  IssmMpiVec* input=NULL;
531 
532  input=(IssmMpiVec<doubletype>*)inputin;
533 
534  for(i=0;i<this->m;i++)local_dot+=this->vector[i]*input->vector[i];
535 
536  /*ISSM_MPI_SUM all the dots across the cluster: */
537  ISSM_MPI_Reduce(&local_dot, &dot, 1, ISSM_MPI_DOUBLE, ISSM_MPI_SUM, 0, IssmComm::GetComm());
539 
540  return dot;
541  }
542  /*}}}*/
544 
545  int i;
546 
547  /*Assume xin and yin are of the correct type, and downcast: */
548  IssmMpiVec* x=NULL;
549  IssmMpiVec* y=NULL;
550 
551  x=(IssmMpiVec<doubletype>*)xin;
552  y=(IssmMpiVec<doubletype>*)yin;
553 
554  /*pointwise w=x/y where this->vector is w: */
555  for(i=0;i<this->m;i++)this->vector[i]=x->vector[i]/y->vector[i];
556  }
557  /*}}}*/
558  void BucketsBuildScatterBuffers(int** pnumvalues_forcpu,int** prow_indices_forcpu,doubletype** pvalues_forcpu,int** pmodes_forcpu,DataSet** bucketsforcpu,int num_procs){/*{{{*/
559 
560  /*intermediary: */
561  int i,j;
562  int count = 0;
563  int total_size = 0;
564  int *temp_row_indices_forcpu = NULL;
565  doubletype *temp_values_forcpu = NULL;
566  int *temp_modes_forcpu = NULL;
567 
568  /*output: */
569  int *numvalues_forcpu = NULL;
570  int *row_indices_forcpu = NULL;
571  doubletype *values_forcpu = NULL;
572  int *modes_forcpu = NULL;
573 
574  /*figure out size of buffers per cpu: */
575 
576  numvalues_forcpu=xNew<int>(num_procs);
577  for(i=0;i<num_procs;i++){
578  DataSet *buckets = bucketsforcpu[i];
579 
580  count=0;
581  for(j=0;j<buckets->Size();j++){
583  count+=bucket->MarshallSize();
584  }
585 
586  numvalues_forcpu[i]=count;
587  }
588 
589  /*now, figure out size of total buffers (for all cpus!): */
590  count=0;
591  for(i=0;i<num_procs;i++){
592  count+=numvalues_forcpu[i];
593  }
594  total_size=count;
595 
596  /*Allocate buffers: */
597  row_indices_forcpu = xNew<int>(total_size);
598 // AD performance is sensitive to calls to ensurecontiguous.
599 // Providing "t" will cause ensurecontiguous to be called.
600 #ifdef _HAVE_AD_
601  values_forcpu = xNew<doubletype>(total_size,"t");
602 #else
603  values_forcpu = xNew<doubletype>(total_size);
604 #endif
605 
606  modes_forcpu = xNew<int>(total_size);
607 
608  /*we are going to march through the buffers, and marshall data onto them, so in order to not
609  *lose track of where these buffers are located in memory, we are going to work using copies
610  of them: */
611  temp_row_indices_forcpu=row_indices_forcpu;
612  temp_values_forcpu=values_forcpu;
613  temp_modes_forcpu=modes_forcpu;
614 
615  /*Fill buffers: */
616  for(i=0;i<num_procs;i++){
617  DataSet *buckets = bucketsforcpu[i];
618  for(j=0;j<buckets->Size();j++){
620  bucket->Marshall(&temp_row_indices_forcpu,&temp_values_forcpu,&temp_modes_forcpu); //pass in the address of the buffers, so as to have the Marshall routine increment them.
621  }
622  }
623 
624  /*sanity check: */
625  if (temp_row_indices_forcpu!=row_indices_forcpu+total_size)_error_("problem with marshalling of buckets");
626  if (temp_values_forcpu!=values_forcpu+total_size)_error_("problem with marshalling of buckets");
627  if (temp_modes_forcpu!=modes_forcpu+total_size)_error_("problem with marshalling of buckets");
628 
629  /*output buffers: */
630  *pnumvalues_forcpu = numvalues_forcpu;
631  *prow_indices_forcpu = row_indices_forcpu;
632  *pvalues_forcpu = values_forcpu;
633  *pmodes_forcpu = modes_forcpu;
634  }
635  /*}}}*/
636 };
637 #endif //#ifndef _ISSM_MPI_VEC_H_
DataSet::Size
int Size()
Definition: DataSet.cpp:399
IssmMpiVec::IssmMpiVec
IssmMpiVec()
Definition: IssmMpiVec.h:44
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
IssmMpiVec::PointwiseDivide
void PointwiseDivide(IssmAbsVec< doubletype > *xin, IssmAbsVec< doubletype > *yin)
Definition: IssmMpiVec.h:543
IssmMpiVec::vector
doubletype * vector
Definition: IssmMpiVec.h:40
DataSet::AddObject
int AddObject(Object *object)
Definition: DataSet.cpp:252
ISSM_MPI_SUM
#define ISSM_MPI_SUM
Definition: issmmpi.h:134
ADD_VAL
@ ADD_VAL
Definition: toolkitsenums.h:14
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition: IssmComm.cpp:30
IssmMpiVec::~IssmMpiVec
~IssmMpiVec()
Definition: IssmMpiVec.h:128
GetOwnershipBoundariesFromRange
void GetOwnershipBoundariesFromRange(int *plower_row, int *pupper_row, int range, ISSM_MPI_Comm comm)
Definition: GetOwnershipBoundariesFromRange.cpp:16
NORM_INF
@ NORM_INF
Definition: toolkitsenums.h:15
ISSM_MPI_MAX
#define ISSM_MPI_MAX
Definition: issmmpi.h:131
IssmMpiVec::IssmMpiVec
IssmMpiVec(int min, int Min)
Definition: IssmMpiVec.h:56
IssmMpiVec::Scale
void Scale(doubletype scale_factor)
Definition: IssmMpiVec.h:516
IssmMpiVec::AYPX
void AYPX(IssmAbsVec< doubletype > *Xin, doubletype a)
Definition: IssmMpiVec.h:400
IssmMpiVec::IssmMpiVec
IssmMpiVec(int Min)
Definition: IssmMpiVec.h:52
IssmMpiVec::GetValue
void GetValue(doubletype *pvalue, int dof)
Definition: IssmMpiVec.h:323
Bucket
Definition: Bucket.h:19
NORM_TWO
@ NORM_TWO
Definition: toolkitsenums.h:15
IssmMpiVec::Norm
doubletype Norm(NormMode mode)
Definition: IssmMpiVec.h:489
IssmMpiVec::SetValues
void SetValues(int ssize, int *list, doubletype *values, InsMode mode)
Definition: IssmMpiVec.h:302
IssmMpiVec::IssmMpiVec
IssmMpiVec(doubletype *buffer, int Min, int min)
Definition: IssmMpiVec.h:81
DetermineLocalSize
int DetermineLocalSize(int global_size, ISSM_MPI_Comm comm)
Definition: DetermineLocalSize.cpp:9
Bucket::MarshallSize
int MarshallSize(void)
Definition: Bucket.h:233
IssmMpiVec::ToMPISerial
doubletype * ToMPISerial(void)
Definition: IssmMpiVec.h:413
DetermineGlobalSize
int DetermineGlobalSize(int local_size, ISSM_MPI_Comm comm)
Definition: DetermineGlobalSize.cpp:10
ISSM_MPI_DOUBLE
#define ISSM_MPI_DOUBLE
Definition: issmmpi.h:125
ISSM_MPI_INT
#define ISSM_MPI_INT
Definition: issmmpi.h:127
IssmMpiVec::buckets
DataSet * buckets
Definition: IssmMpiVec.h:41
IssmMpiVec::IssmMpiVec
IssmMpiVec(int Min, bool fromlocalsize)
Definition: IssmMpiVec.h:60
IssmComm::GetSize
static int GetSize(void)
Definition: IssmComm.cpp:46
IssmMpiVec::Dot
doubletype Dot(IssmAbsVec< doubletype > *inputin)
Definition: IssmMpiVec.h:523
IssmMpiVec::Init
void Init(int Min, bool fromlocalsize)
Definition: IssmMpiVec.h:101
IssmMpiVec::BucketsBuildScatterBuffers
void BucketsBuildScatterBuffers(int **pnumvalues_forcpu, int **prow_indices_forcpu, doubletype **pvalues_forcpu, int **pmodes_forcpu, DataSet **bucketsforcpu, int num_procs)
Definition: IssmMpiVec.h:558
IssmMpiVec::Set
void Set(doubletype value)
Definition: IssmMpiVec.h:380
ISSM_MPI_Bcast
int ISSM_MPI_Bcast(void *buffer, int count, ISSM_MPI_Datatype datatype, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:162
IssmAbsVec
Definition: IssmAbsVec.h:24
Bucket::SpawnBucketsPerCpu
void SpawnBucketsPerCpu(DataSet *bucketsofcpu_i, int rank_i, int *rowranks)
Definition: Bucket.h:137
IssmMpiVec::ToMPISerial0
doubletype * ToMPISerial0(void)
Definition: IssmMpiVec.h:464
IssmMpiVec::SetValue
void SetValue(int dof, doubletype value, InsMode mode)
Definition: IssmMpiVec.h:313
NormMode
NormMode
Definition: toolkitsenums.h:15
ISSM_MPI_Allgather
int ISSM_MPI_Allgather(void *sendbuf, int sendcount, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcount, ISSM_MPI_Datatype recvtype, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:45
Bucket::Marshall
void Marshall(char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
Definition: Bucket.h:131
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
IssmMpiVec::GetLocalSize
void GetLocalSize(int *pM)
Definition: IssmMpiVec.h:333
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
min
IssmDouble min(IssmDouble a, IssmDouble b)
Definition: extrema.cpp:14
ISSM_MPI_Comm
int ISSM_MPI_Comm
Definition: issmmpi.h:118
IssmMpiVec::m
int m
Definition: IssmMpiVec.h:39
IssmMpiVec::GetLocalVector
void GetLocalVector(doubletype **pvector, int **pindices)
Definition: IssmMpiVec.h:339
ISSM_MPI_Allgatherv
int ISSM_MPI_Allgatherv(void *sendbuf, int sendcount, ISSM_MPI_Datatype sendtype, void *recvbuf, int *recvcounts, int *displs, ISSM_MPI_Datatype recvtype, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:79
IssmMpiVec::GetSize
void GetSize(int *pM)
Definition: IssmMpiVec.h:327
ISSM_MPI_Barrier
int ISSM_MPI_Barrier(ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:148
InsMode
InsMode
Definition: toolkitsenums.h:14
IssmMpiVec::IssmMpiVec
IssmMpiVec(doubletype *buffer, int Min)
Definition: IssmMpiVec.h:64
IssmMpiVec::Assemble
void Assemble()
Definition: IssmMpiVec.h:147
IssmMpiVec
Definition: IssmMpiVec.h:34
ISSM_MPI_Reduce
int ISSM_MPI_Reduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:373
max
IssmDouble max(IssmDouble a, IssmDouble b)
Definition: extrema.cpp:24
IssmMpiVec::AXPY
void AXPY(IssmAbsVec< doubletype > *Xin, doubletype a)
Definition: IssmMpiVec.h:386
DataSet
Declaration of DataSet class.
Definition: DataSet.h:14
bamg::Min
T Min(const T &a, const T &b)
Definition: extrema.h:6
IssmMpiVec::M
int M
Definition: IssmMpiVec.h:38
IssmMpiVec::Copy
void Copy(IssmAbsVec< doubletype > *toin)
Definition: IssmMpiVec.h:475
DetermineRowRankFromLocalSize
int * DetermineRowRankFromLocalSize(int global_size, int localsize, ISSM_MPI_Comm comm)
Definition: DetermineRowRankFromLocalSize.cpp:12
IssmMpiVec::Duplicate
IssmMpiVec< doubletype > * Duplicate(void)
Definition: IssmMpiVec.h:374
ISSM_MPI_Scatter
int ISSM_MPI_Scatter(void *sendbuf, int sendcnt, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:407
IssmMpiVec::Echo
void Echo(void)
Definition: IssmMpiVec.h:137
ISSM_MPI_Scatterv
int ISSM_MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:444
IssmMpiVec::Shift
void Shift(doubletype shift)
Definition: IssmMpiVec.h:471