source: XMLIO_V2/external/include/blitz/benchext.h @ 73

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