NeoPZ
main.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "arglib.h"
3 #include "pzfmatrix.h"
4 #include "pzparallel.h"
5 #include "run_stats_table.h"
6 
7 #include <float.h> // FLT_MAX
8 #include <stdio.h> // printf
9 
10 clarg::argInt number_of_matrices("-n", "Number of matrices.", 2);
11 clarg::argInt dimension("-d", "Matrices dimension M x M", 1000);
12 
13 #ifndef DATATYPE
14 #define RPT 5
15 #endif
16 
17 RunStatsTable total_rst ("-tot_rdt", "Whole program (total) statistics raw data table");
18 
20 private:
21  std::vector<TPZFMatrix<REAL> *> matrices;
22 public:
23  MatrixBenchmark(int number_of_matrices, int dimension) : matrices(number_of_matrices) {
24  for (int i = 0; i < number_of_matrices; i++) {
25  matrices[i] = new TPZFMatrix<REAL>(dimension, dimension, M_PI);
26  }
27  }
28 
29  void operator()(int i) {
30  matrices[i]->Decompose_LU();
31  }
32 
34  for (int i = 0; i < matrices.size(); i++)
35  delete matrices[i];
36  matrices.clear();
37  }
38 };
39 
40 /* Code to read the wall clock time. */
41 #include <sys/time.h>
42 double mysecond()
43 {
44  struct timeval tp;
45  struct timezone tzp;
46  gettimeofday(&tp,&tzp);
47  return ( (double) tp.tv_sec + (double) tp.tv_usec * 1.e-6 );
48 }
49 
50 /* Kernel name. */
51 const char* kernel_name = "TPZFMatrix LU Decomposition";
52 
53 void kernel()
54 {
57 }
58 
59 /* -----------------------------*/
60 int main()
61 {
62  uint64_t k;
63  double times[RPT];
64  double mintime = FLT_MAX;
65  double avgtime = 0;
66  double maxtime = 0;
67  double t;
68 
69  printf("Kernel name : %s\n",kernel_name);
70  printf("# of runs : %d\n", RPT);
71 
72  /* Main loop. */
73  for (k=0; k<RPT; k++)
74  {
75  t = mysecond();
76  /* Kernel */
77  kernel();
78  times[k] = mysecond() - t;
79  //printf(" -> %6.2f s\n", times[k]);
80  }
81 
82  /* Final report */
83  for (k=0; k<RPT; k++)
84  /* Discard first iteration (k=1). */
85  {
86  avgtime = avgtime + times[k];
87  mintime = MIN(mintime, times[k]);
88  maxtime = MAX(maxtime, times[k]);
89  }
90  /* Print Report */
91  avgtime = avgtime / (RPT-1);
92  printf("Avg time : %6.2f\n",avgtime);
93  printf("Min time : %6.2f\n",mintime);
94  printf("Max time : %6.2f\n",maxtime);
95 
96  return 0;
97 }
98 
Contains a class to record running statistics on CSV tables.
double mysecond()
Definition: main.cpp:42
MatrixBenchmark(int number_of_matrices, int dimension)
Definition: main.cpp:23
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
RunStatsTable total_rst("-tot_rdt", "Whole program (total) statistics raw data table")
~MatrixBenchmark()
Definition: main.cpp:33
#define MAX(a, b)
Gets maxime value between a and b.
Definition: pzreal.h:81
const char * kernel_name
Definition: main.cpp:51
Contains TPZMatrixclass which implements full matrix (using column major representation).
void parallel_for(int n, body_t &obj)
Definition: pzparallel.h:24
std::vector< TPZFMatrix< REAL > * > matrices
Definition: main.cpp:21
#define MIN(a, b)
Gets minime value between a and b.
Definition: pzreal.h:85
void kernel()
Definition: main.cpp:53
const T & get_value() const
Definition: arglib.h:177
clarg::argInt number_of_matrices("-n", "Number of matrices.", 2)
void operator()(int i)
Definition: main.cpp:29
#define RPT
Definition: main.cpp:14
int main()
Definition: main.cpp:60