Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test/EpetraBenchmarkTest/cxx_main.cpp
Go to the documentation of this file.
1 //@HEADER
2 // ************************************************************************
3 //
4 // Epetra: Linear Algebra Services Package
5 // Copyright 2011 Sandia Corporation
6 //
7 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ************************************************************************
40 //@HEADER
41 
42 #include <iostream>
43 #include <cstring>
44 #include "Epetra_Map.h"
45 #include "Epetra_LocalMap.h"
46 #include "Epetra_BlockMap.h"
47 #include "Epetra_Time.h"
48 #include "Epetra_CrsMatrix.h"
49 #include "Epetra_VbrMatrix.h"
50 #include "Epetra_Vector.h"
51 #include "Epetra_IntVector.h"
52 #include "Epetra_MultiVector.h"
55 #ifdef EPETRA_MPI
56 #include "Epetra_MpiComm.h"
57 #include "mpi.h"
58 #else
59 #include "Epetra_SerialComm.h"
60 #endif
61 #include "Epetra_Version.h"
62 
63 // prototypes
64 
65 void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints,
66  int * xoff, int * yoff,
67  const Epetra_Comm &comm,
68  Epetra_Map *& map,
70  Epetra_Vector *& b,
71  Epetra_Vector *& bt,
72  Epetra_Vector *&xexact, bool StaticProfile, bool MakeLocalOnly);
73 
74 void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints,
75  int * xoff, int * yoff, int nrhs,
76  const Epetra_Comm &comm,
77  Epetra_Map *& map,
79  Epetra_MultiVector *& b,
80  Epetra_MultiVector *& bt,
81  Epetra_MultiVector *&xexact, bool StaticProfile, bool MakeLocalOnly);
82 
83 
84 void GenerateMyGlobalElements(int numNodesX, int numNodesY, int numProcsX, int numProcs,
85  int myPID, int * & myGlobalElements);
86 
88  Epetra_MultiVector * xexact, bool StaticProfile);
89 
90 int main(int argc, char *argv[])
91 {
92 
93  const string EpetraBenchmarkTest = "Epetra Benchmark Test Version 0.2 08/30/2007"; // Change this number and date when changes are made to functionality
94  int ierr = 0;
95  double elapsed_time;
96  double total_flops;
97  double MFLOPs;
98  double global_dimension;
99  double global_nonzero_count;
100 
101 
102 #ifdef EPETRA_MPI
103 
104  // Initialize MPI
105  MPI_Init(&argc,&argv);
106  Epetra_MpiComm comm( MPI_COMM_WORLD );
107 #else
108  Epetra_SerialComm comm;
109 #endif
110 
111  // Check if we should print only selected timing info to standard out
112  bool printflops = true, printmflops = true, printtime = true;
113  if (argc>5) if (argv[5][0]=='-' && argv[5][1]=='f') {printmflops = false; printtime = false;}
114  bool mflopsonly = false;
115  if (argc>5) if (argv[5][0]=='-' && argv[5][1]=='m') {printflops = false; printtime = false;}
116  bool timeonly = false;
117  if (argc>5) if (argv[5][0]=='-' && argv[5][1]=='t') {printflops = false; printmflops = false;}
118 
119  // Check if we should print header to standard out
120  bool makeheader = false;
121  if (argc>6) if (argv[6][0]=='-' && argv[6][1]=='h') makeheader = true;
122 
123  if(argc < 5) {
124  cerr << "Usage: " << argv[0]
125  << " NumNodesX NumNodesY NumProcX NumProcY [-a|-f|-m|-t [-h]]" << endl
126  << "where:" << endl
127  << "NumNodesX - Number of mesh nodes in X direction per processor" << endl
128  << "NumNodesY - Number of mesh nodes in Y direction per processor" << endl
129  << "NumProcX - Number of processors to use in X direction" << endl
130  << "NumProcY - Number of processors to use in Y direction" << endl
131  << "-a|-f|-m|-t - Type of information to print: a=all, f=FLOPS, m=MFLOP/s, t=time (sec). Default is -a."
132  << "-h - (Optional) Printer output table header if -h present (typically done on first call)." << endl
133  << " NOTES: NumProcX*NumProcY must equal the number of processors used to run the problem." << endl << endl
134  << " Serial example:" << endl << endl
135  << argv[0] << " 200 300 1 1 -m" << endl
136  << " Run this program on 1 processor using a 200 by 300 grid, printing only MFLOP/s information without a header."<< endl <<endl
137  << " MPI example:" << endl << endl
138  << "mpirun -np 32 " << argv[0] << " 250 200 4 8 -a -h" << endl
139  << " Run this program on 32 processors putting a 250 by 200 subgrid on each processor using 4 processors "<< endl
140  << " in the X direction and 8 in the Y direction. Total grid size is 1000 points in X and 1600 in Y for a total of 1.6M equations."<< endl
141  << " Print all information. Print header." << endl
142  << endl;
143  return(1);
144 
145  }
146  //char tmp;
147  //if (comm.MyPID()==0) cout << "Press any key to continue..."<< endl;
148  //if (comm.MyPID()==0) cin >> tmp;
149  //comm.Barrier();
150 
151  if (makeheader && comm.MyPID()==0)
152  cout << EpetraBenchmarkTest << endl
153  << "Using " << Epetra_Version() << endl << endl;
154  if (makeheader) cout << comm <<endl;
155 
156 
157  // Redefine makeheader to only print on PE 0
158 
159  if (makeheader && comm.MyPID()!=0) makeheader = false;
160 
161  int numNodesX = atoi(argv[1]);
162  int numNodesY = atoi(argv[2]);
163  int numProcsX = atoi(argv[3]);
164  int numProcsY = atoi(argv[4]);
165  int numPoints = 25;
166 
167  if (makeheader) {
168  cout << " Number of local nodes in X direction = " << numNodesX << endl
169  << " Number of local nodes in Y direction = " << numNodesY << endl
170  << " Number of global nodes in X direction = " << numNodesX*numProcsX << endl
171  << " Number of global nodes in Y direction = " << numNodesY*numProcsY << endl
172  << " Number of local nonzero entries = " << numNodesX*numNodesY*numPoints << endl
173  << " Number of global nonzero entries = " << numNodesX*numNodesY*numPoints*numProcsX*numProcsY << endl
174  << " Number of Processors in X direction = " << numProcsX << endl
175  << " Number of Processors in Y direction = " << numProcsY << endl
176  << " Number of Points in stencil = " << numPoints << endl << endl;
177  cout << " Timing the following:" <<endl
178  << " SpMV - Sparse matrix vector product using Epetra_CrsMatrix class" << endl
179  << " SpMM2- Sparse matrix times 2-column multivector using Epetra_CrsMatrix class" << endl
180  << " SpMM4- Sparse matrix times 4-column multivector using Epetra_CrsMatrix class" << endl
181  << " SpMM8- Sparse matrix times 8-column multivector using Epetra_CrsMatrix class" << endl
182  << " 2-norm of an Epetra_MultiVector" << endl
183  << " Dot-product of 2 Epetra_MultiVectors" << endl
184  << " AXPY of 2 Epetra_MultiVectors" << endl << endl;
185  }
186 
187  if (numProcsX*numProcsY!=comm.NumProc()) {
188  cerr << "Number of processors = " << comm.NumProc() << endl
189  << " is not the product of " << numProcsX << " and " << numProcsY << endl << endl;
190  return(1);
191  }
192 
193  if (numNodesX*numNodesY<=0) {
194  cerr << "Product of number of nodes is <= zero" << endl << endl;
195  return(1);
196  }
197 
198  Epetra_IntSerialDenseVector Xoff, XLoff, XUoff;
199  Epetra_IntSerialDenseVector Yoff, YLoff, YUoff;
200  // Generate a 25-point 2D Finite Difference matrix
201  Xoff.Size(25);
202  Yoff.Size(25);
203  int xi = 0, yi = 0;
204  int xo = -2, yo = -2;
205  Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++;
206  Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ;
207  xo = -2, yo++;
208  Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++;
209  Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ;
210  xo = -2, yo++;
211  Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++;
212  Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ;
213  xo = -2, yo++;
214  Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++;
215  Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ;
216  xo = -2, yo++;
217  Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++; Xoff[xi++] = xo++;
218  Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ; Yoff[yi++] = yo ;
219 
220 
221 
222  Epetra_Map * map;
224  Epetra_MultiVector * b;
225  Epetra_MultiVector * bt;
226  Epetra_MultiVector * xexact;
227  Epetra_SerialDenseVector resvec(0);
228  global_dimension = (double) (numNodesX*numNodesY); // local grid dimension
229  global_dimension *= (double) (numProcsX*numProcsY); // times number of processors
230  global_nonzero_count = global_dimension * (double) numPoints; // number of nonzeros (w/o accounting for boundaries)
231 
232  //Timings
233  Epetra_Time timer(comm);
234  const int maxtimings = 7;
235  const int maxtrials = 10;
236  double results[maxtimings][3]; // timing results stored here
237 
238  int nrhs = 1;
239  int ntimings = 0;
240  for (int k=0; k<4; k++) {
241  if (k>0) nrhs = nrhs*2;
242 
243  GenerateCrsProblem(numNodesX, numNodesY, numProcsX, numProcsY, numPoints,
244  Xoff.Values(), Yoff.Values(), nrhs, comm,
245  map, A, b, bt, xexact, true, false);
246 
247 
248  Epetra_MultiVector z(*b);
249  Epetra_MultiVector r(*b);
250  Epetra_SerialDenseVector resvec(b->NumVectors());
251 
252  //Timings
253  Epetra_Time timer(A->Comm());
254  A->OptimizeStorage();
255 
256  timer.ResetStartTime();
257 
258  //maxtrials matvecs
259  for( int i = 0; i < maxtrials; ++i )
260  A->Multiply(false, *xexact, z); // Compute z = A*xexact or z = A'*xexact
261 
262  double elapsed_time = timer.ElapsedTime();
263  double total_flops = 2.0*global_nonzero_count *((double) maxtrials);
264 
265  // Compute residual
266  r.Update(-1.0, z, 1.0, *b, 0.0); // r = b - z
267 
268  r.Norm2(resvec.Values());
269  double diff = resvec.NormInf();
270  if (diff>1.0e-8 && comm.MyPID()==0) cerr << "Warning: Residual vector unusually large = " << diff << endl;
271 
272  double MFLOPs = total_flops/elapsed_time/1000000.0;
273 
274  results[ntimings][0] = total_flops;
275  results[ntimings][1] = elapsed_time;
276  results[ntimings++][2] = MFLOPs;
277 
278  delete A;
279  delete b;
280  delete bt;
281  delete xexact;
282  } // end of k loop
283 
284 
285  // *************** Vector timings *********************
286 
287  if (ntimings+3>maxtimings) cerr << "Variable maxtimings = " << maxtimings << " must be at least = " << ntimings+3 << endl;
288 
289  Epetra_MultiVector q(*map, nrhs);
290  Epetra_MultiVector z(q);
291  Epetra_MultiVector r(q);
292 
293  delete map;
294 
295  resvec.Resize(nrhs);
296 
297 
298  timer.ResetStartTime();
299 
300  //maxtrials norms
301  for( int i = 0; i < maxtrials; ++i )
302  q.Norm2( resvec.Values() );
303 
304  elapsed_time = timer.ElapsedTime();
305  total_flops = 2.0*global_dimension *((double) maxtrials);
306  MFLOPs = total_flops/elapsed_time/1000000.0;
307  results[ntimings][0] = total_flops;
308  results[ntimings][1] = elapsed_time;
309  results[ntimings++][2] = MFLOPs;
310 
311 
312 
313  timer.ResetStartTime();
314 
315  //maxtrials dot's
316  for( int i = 0; i < maxtrials; ++i )
317  q.Dot(z, resvec.Values());
318 
319  elapsed_time = timer.ElapsedTime();
320  total_flops = 2.0*global_dimension *((double) maxtrials);
321  MFLOPs = total_flops/elapsed_time/1000000.0;
322  results[ntimings][0] = total_flops;
323  results[ntimings][1] = elapsed_time;
324  results[ntimings++][2] = MFLOPs;
325 
326  timer.ResetStartTime();
327 
328  //maxtrials updates
329  for( int i = 0; i < maxtrials; ++i )
330  q.Update(1.0, z, 1.0, r, 0.0);
331 
332  elapsed_time = timer.ElapsedTime();
333  total_flops = 2.0*global_dimension *((double) maxtrials);
334  MFLOPs = total_flops/elapsed_time/1000000.0;
335  results[ntimings][0] = total_flops;
336  results[ntimings][1] = elapsed_time;
337  results[ntimings++][2] = MFLOPs;
338 
339  if (makeheader)
340  cout << "Metric_\t\t_Procs_\t__SpMV__\t_SpMM2__\t_SpMM4__\t_SpMM8__\t__NORM___\t__DOT___\t__AXPY__" << endl;
341  if (comm.MyPID()==0) {
342  cout.setf(std::ios::scientific);
343  cout.precision(2);
344  for (int j=0; j<3; j++) {
345  bool doloop = false;
346  if (j==0 && printflops) { cout << "FLOPS\t"; doloop = true;}
347  else if (j==1 && printtime) {cout << "Time(s)\t"; doloop = true;}
348  else if (j==2 && printmflops) {cout << "MFLOP/s\t"; doloop = true;}
349  if (doloop) {
350  cout << "\t" << comm.NumProc();
351  for (int i=0; i<maxtimings; i++)
352  cout << "\t" << results[i][j];
353  cout << endl;
354  }
355  }
356  }
357 
358 #ifdef EPETRA_MPI
359  MPI_Finalize() ;
360 #endif
361 
362 return ierr ;
363 }
364 
365 // Constructs a 2D PDE finite difference matrix using the list of x and y offsets.
366 //
367 // nx (In) - number of grid points in x direction
368 // ny (In) - number of grid points in y direction
369 // The total number of equations will be nx*ny ordered such that the x direction changes
370 // most rapidly:
371 // First equation is at point (0,0)
372 // Second at (1,0)
373 // ...
374 // nx equation at (nx-1,0)
375 // nx+1st equation at (0,1)
376 
377 // numPoints (In) - number of points in finite difference stencil
378 // xoff (In) - stencil offsets in x direction (of length numPoints)
379 // yoff (In) - stencil offsets in y direction (of length numPoints)
380 // A standard 5-point finite difference stencil would be described as:
381 // numPoints = 5
382 // xoff = [-1, 1, 0, 0, 0]
383 // yoff = [ 0, 0, 0, -1, 1]
384 
385 // nrhs - Number of rhs to generate. (First interface produces vectors, so nrhs is not needed
386 
387 // comm (In) - an Epetra_Comm object describing the parallel machine (numProcs and my proc ID)
388 // map (Out) - Epetra_Map describing distribution of matrix and vectors/multivectors
389 // A (Out) - Epetra_CrsMatrix constructed for nx by ny grid using prescribed stencil
390 // Off-diagonal values are random between 0 and 1. If diagonal is part of stencil,
391 // diagonal will be slightly diag dominant.
392 // b (Out) - Generated RHS. Values satisfy b = A*xexact
393 // bt (Out) - Generated RHS. Values satisfy b = A'*xexact
394 // xexact (Out) - Generated exact solution to Ax = b and b' = A'xexact
395 
396 // Note: Caller of this function is responsible for deleting all output objects.
397 
398 void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints,
399  int * xoff, int * yoff,
400  const Epetra_Comm &comm,
401  Epetra_Map *& map,
402  Epetra_CrsMatrix *& A,
403  Epetra_Vector *& b,
404  Epetra_Vector *& bt,
405  Epetra_Vector *&xexact, bool StaticProfile, bool MakeLocalOnly) {
406 
407  Epetra_MultiVector * b1, * bt1, * xexact1;
408 
409  GenerateCrsProblem(numNodesX, numNodesY, numProcsX, numProcsY, numPoints,
410  xoff, yoff, 1, comm,
411  map, A, b1, bt1, xexact1, StaticProfile, MakeLocalOnly);
412 
413  b = dynamic_cast<Epetra_Vector *>(b1);
414  bt = dynamic_cast<Epetra_Vector *>(bt1);
415  xexact = dynamic_cast<Epetra_Vector *>(xexact1);
416 
417  return;
418 }
419 
420 void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints,
421  int * xoff, int * yoff, int nrhs,
422  const Epetra_Comm &comm,
423  Epetra_Map *& map,
424  Epetra_CrsMatrix *& A,
425  Epetra_MultiVector *& b,
426  Epetra_MultiVector *& bt,
427  Epetra_MultiVector *&xexact, bool StaticProfile, bool MakeLocalOnly) {
428 
429  Epetra_Time timer(comm);
430  // Determine my global IDs
431  int * myGlobalElements;
432  GenerateMyGlobalElements(numNodesX, numNodesY, numProcsX, numProcsY, comm.MyPID(), myGlobalElements);
433 
434  int numMyEquations = numNodesX*numNodesY;
435 
436  map = new Epetra_Map(-1, numMyEquations, myGlobalElements, 0, comm); // Create map with 2D block partitioning.
437  delete [] myGlobalElements;
438 
439  int numGlobalEquations = map->NumGlobalElements();
440 
441  int profile = 0; if (StaticProfile) profile = numPoints;
442 
443 #ifdef EPETRA_HAVE_STATICPROFILE
444 
445  if (MakeLocalOnly)
446  A = new Epetra_CrsMatrix(Copy, *map, *map, profile, StaticProfile); // Construct matrix with rowmap=colmap
447  else
448  A = new Epetra_CrsMatrix(Copy, *map, profile, StaticProfile); // Construct matrix
449 
450 #else
451 
452  if (MakeLocalOnly)
453  A = new Epetra_CrsMatrix(Copy, *map, *map, profile); // Construct matrix with rowmap=colmap
454  else
455  A = new Epetra_CrsMatrix(Copy, *map, profile); // Construct matrix
456 
457 #endif
458 
459  int * indices = new int[numPoints];
460  double * values = new double[numPoints];
461 
462  double dnumPoints = (double) numPoints;
463  int nx = numNodesX*numProcsX;
464 
465  for (int i=0; i<numMyEquations; i++) {
466 
467  int rowID = map->GID(i);
468  int numIndices = 0;
469 
470  for (int j=0; j<numPoints; j++) {
471  int colID = rowID + xoff[j] + nx*yoff[j]; // Compute column ID based on stencil offsets
472  if (colID>-1 && colID<numGlobalEquations) {
473  indices[numIndices] = colID;
474  double value = - ((double) rand())/ ((double) RAND_MAX);
475  if (colID==rowID)
476  values[numIndices++] = dnumPoints - value; // Make diagonal dominant
477  else
478  values[numIndices++] = value;
479  }
480  }
481  //cout << "Building row " << rowID << endl;
482  A->InsertGlobalValues(rowID, numIndices, values, indices);
483  }
484 
485  delete [] indices;
486  delete [] values;
487  double insertTime = timer.ElapsedTime();
488  timer.ResetStartTime();
489  A->FillComplete();
490  double fillCompleteTime = timer.ElapsedTime();
491 
492  if (nrhs<=1) {
493  b = new Epetra_Vector(*map);
494  bt = new Epetra_Vector(*map);
495  xexact = new Epetra_Vector(*map);
496  }
497  else {
498  b = new Epetra_MultiVector(*map, nrhs);
499  bt = new Epetra_MultiVector(*map, nrhs);
500  xexact = new Epetra_MultiVector(*map, nrhs);
501  }
502 
503  xexact->Random(); // Fill xexact with random values
504 
505  A->Multiply(false, *xexact, *b);
506  A->Multiply(true, *xexact, *bt);
507 
508  return;
509 }
510 
511 
512 
513 
514 void GenerateMyGlobalElements(int numNodesX, int numNodesY, int numProcsX, int numProcs,
515  int myPID, int * & myGlobalElements) {
516 
517  myGlobalElements = new int[numNodesX*numNodesY];
518  int myProcX = myPID%numProcsX;
519  int myProcY = myPID/numProcsX;
520  int curGID = myProcY*(numProcsX*numNodesX)*numNodesY+myProcX*numNodesX;
521  for (int j=0; j<numNodesY; j++) {
522  for (int i=0; i<numNodesX; i++) {
523  myGlobalElements[j*numNodesX+i] = curGID+i;
524  }
525  curGID+=numNodesX*numProcsX;
526  }
527  //for (int i=0; i<numNodesX*numNodesY; i++) cout << "MYPID " << myPID <<" GID "<< myGlobalElements[i] << endl;
528 
529  return;
530 }
531 
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int NumGlobalElements() const
Number of elements across all processors.
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:119
int Random()
Set multi-vector values to random numbers.
Epetra_IntSerialDenseVector: A class for constructing and using dense vectors.
int Multiply(bool TransA, const Epetra_Vector &x, Epetra_Vector &y) const
Returns the result of a Epetra_CrsMatrix multiplied by a Epetra_Vector x in y.
double ElapsedTime(void) const
Epetra_Time elapsed time function.
int Size(int Length_in)
Set length of a Epetra_IntSerialDenseVector object; init values to zero.
virtual int InsertGlobalValues(int GlobalRow, int NumEntries, const double *Values, const int *Indices)
Insert a list of elements in a given global row of the matrix.
double NormInf() const
Compute Inf-norm of each vector in multi-vector.
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
int MyPID() const
Return my process ID.
Epetra_MpiComm: The Epetra MPI Communication Class.
std::string Epetra_Version()
virtual int MyPID() const =0
Return my process ID.
int FillComplete(bool OptimizeDataStorage=true)
Signal that data entry is complete. Perform transformations to local index space. ...
int Resize(int Length_in)
Resize a Epetra_SerialDenseVector object.
Epetra_Time: The Epetra Timing Class.
Definition: Epetra_Time.h:75
int Dot(const Epetra_MultiVector &A, double *Result) const
Computes dot product of each corresponding pair of vectors.
Epetra_SerialDenseVector: A class for constructing and using dense vectors.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:73
void GenerateCrsProblem(int numNodesX, int numNodesY, int numProcsX, int numProcsY, int numPoints, int *xoff, int *yoff, const Epetra_Comm &comm, bool verbose, bool summary, Epetra_Map *&map, Epetra_CrsMatrix *&A, Epetra_Vector *&b, Epetra_Vector *&bt, Epetra_Vector *&xexact, bool StaticProfile, bool MakeLocalOnly)
int GID(int LID) const
Returns global ID of local ID, return IndexBase-1 if not found on this processor. ...
int NumProc() const
Returns total number of processes (always returns 1 for SerialComm).
Epetra_SerialComm: The Epetra Serial Communication Class.
int Update(double ScalarA, const Epetra_MultiVector &A, double ScalarThis)
Update multi-vector values with scaled values of A, this = ScalarThis*this + ScalarA*A.
Epetra_CrsMatrix: A class for constructing and using real-valued double-precision sparse compressed r...
int Norm2(double *Result) const
Compute 2-norm of each vector in multi-vector.
int main(int argc, char *argv[])
void runMatrixTests(Epetra_CrsMatrix *A, Epetra_MultiVector *b, Epetra_MultiVector *bt, Epetra_MultiVector *xexact, bool StaticProfile, bool verbose, bool summary)
void GenerateMyGlobalElements(int numNodesX, int numNodesY, int numProcsX, int numProcs, int myPID, int *&myGlobalElements)
double * Values() const
Returns pointer to the values in vector.
int * Values()
Returns pointer to the values in vector.
void ResetStartTime(void)
Epetra_Time function to reset the start time for a timer object.