NeoPZ
PerfTests
DataMigration
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
19
class
MatrixBenchmark
{
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
33
~MatrixBenchmark
() {
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
{
55
MatrixBenchmark
bt(
number_of_matrices
.
get_value
(),
dimension
.
get_value
());
56
pz::parallel_for
(
number_of_matrices
.
get_value
(), bt);
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
run_stats_table.h
Contains a class to record running statistics on CSV tables.
mysecond
double mysecond()
Definition:
main.cpp:42
RunStatsTable
Definition:
run_stats_table.h:34
MatrixBenchmark::MatrixBenchmark
MatrixBenchmark(int number_of_matrices, int dimension)
Definition:
main.cpp:23
dimension
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
total_rst
RunStatsTable total_rst("-tot_rdt", "Whole program (total) statistics raw data table")
MatrixBenchmark::~MatrixBenchmark
~MatrixBenchmark()
Definition:
main.cpp:33
MAX
#define MAX(a, b)
Gets maxime value between a and b.
Definition:
pzreal.h:81
MatrixBenchmark
Definition:
main.cpp:19
pzparallel.h
kernel_name
const char * kernel_name
Definition:
main.cpp:51
pzfmatrix.h
Contains TPZMatrixclass which implements full matrix (using column major representation).
arglib.h
pz::parallel_for
void parallel_for(int n, body_t &obj)
Definition:
pzparallel.h:24
MatrixBenchmark::matrices
std::vector< TPZFMatrix< REAL > * > matrices
Definition:
main.cpp:21
MIN
#define MIN(a, b)
Gets minime value between a and b.
Definition:
pzreal.h:85
TPZFMatrix< REAL >
kernel
void kernel()
Definition:
main.cpp:53
clarg::argInt
Definition:
arglib.h:222
clarg::argT::get_value
const T & get_value() const
Definition:
arglib.h:177
number_of_matrices
clarg::argInt number_of_matrices("-n", "Number of matrices.", 2)
MatrixBenchmark::operator()
void operator()(int i)
Definition:
main.cpp:29
RPT
#define RPT
Definition:
main.cpp:14
main
int main()
Definition:
main.cpp:60
Generated on Sun Aug 16 2020 11:17:08 for NeoPZ by
1.8.13