This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchext.h
121 lines (87 loc) · 3.36 KB
/
benchext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/***************************************************************************
* blitz/benchext.h BenchmarkExt classes (Benchmarks with external
* control)
*
* Copyright (C) 1997-2001 Todd Veldhuizen <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* Suggestions: [email protected]
* Bugs: [email protected]
*
* For more information, please see the Blitz++ Home Page:
* http://oonumerics.org/blitz/
*
***************************************************************************/
#ifndef BZ_BENCHEXT_H
#define BZ_BENCHEXT_H
#ifndef BZ_MATRIX_H
#include <blitz/matrix.h>
#endif
#ifndef BZ_TIMER_H
#include <blitz/timer.h>
#endif
#include <math.h>
// NEEDS_WORK: replace use of const char* with <string>, once standard
// library is widely supported.
BZ_NAMESPACE(blitz)
// Declaration of class BenchmarkExt<T>
// The template parameter T is the parameter type which is varied in
// the benchmark. Typically T will be an unsigned, and will represent
// the length of a vector, size of an array, etc.
template<typename P_parameter = unsigned>
class BenchmarkExt {
public:
typedef P_parameter T_parameter;
BenchmarkExt(const char* description, int numImplementations);
~BenchmarkExt();
void setNumParameters(int numParameters);
void setParameterVector(Vector<T_parameter> parms);
void setParameterDescription(const char* string);
void setIterations(Vector<long> iters);
void setFlopsPerIteration(Vector<double> flopsPerIteration);
void setRateDescription(const char* string);
void beginBenchmarking();
void beginImplementation(const char* description);
bool doneImplementationBenchmark() const;
T_parameter getParameter() const;
long getIterations() const;
inline void start();
inline void stop();
void startOverhead();
void stopOverhead();
void endImplementation();
void endBenchmarking();
double getMflops(unsigned implementation, unsigned parameterNum) const;
void saveMatlabGraph(const char* filename, const char* graphType="semilogx") const;
protected:
BenchmarkExt(const BenchmarkExt<P_parameter>&) { }
void operator=(const BenchmarkExt<P_parameter>&) { }
enum { initializing, benchmarking, benchmarkingImplementation,
running, runningOverhead, done } state_;
unsigned numImplementations_;
unsigned implementationNumber_;
const char* description_;
Vector<const char*> implementationDescriptions_;
Matrix<double,RowMajor> times_; // Elapsed time
Vector<T_parameter> parameters_;
Vector<long> iterations_;
Vector<double> flopsPerIteration_;
Timer timer_;
Timer overheadTimer_;
const char* parameterDescription_;
const char* rateDescription_;
unsigned numParameters_;
unsigned parameterNumber_;
};
BZ_NAMESPACE_END
#include <blitz/benchext.cc>
#endif // BZ_BENCHEXT_H