[658] | 1 | /***************************************************************************
|
---|
| 2 | * blitz/benchext.h BenchmarkExt classes (Benchmarks with external
|
---|
| 3 | * control)
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca>
|
---|
| 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-suggest@cybervision.com
|
---|
| 18 | * Bugs: blitz-bugs@cybervision.com
|
---|
| 19 | *
|
---|
| 20 | * For more information, please see the Blitz++ Home Page:
|
---|
| 21 | * http://seurat.uwaterloo.ca/blitz/
|
---|
| 22 | *
|
---|
| 23 | ***************************************************************************
|
---|
| 24 | * $Log: not supported by cvs2svn $
|
---|
| 25 | * Revision 1.1.1.1 1999/04/09 17:59:01 ansari
|
---|
| 26 | * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
|
---|
| 27 | *
|
---|
| 28 | * Revision 1.2 1998/03/14 00:04:47 tveldhui
|
---|
| 29 | * 0.2-alpha-05
|
---|
| 30 | *
|
---|
| 31 | * Revision 1.1 1997/07/16 14:51:20 tveldhui
|
---|
| 32 | * Update: Alpha release 0.2 (Arrays)
|
---|
| 33 | *
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | #ifndef BZ_BENCHEXT_H
|
---|
| 37 | #define BZ_BENCHEXT_H
|
---|
| 38 |
|
---|
| 39 | #ifndef BZ_MATRIX_H
|
---|
| 40 | #include <blitz/matrix.h>
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
| 43 | #ifndef BZ_TIMER_H
|
---|
| 44 | #include <blitz/timer.h>
|
---|
| 45 | #endif
|
---|
| 46 |
|
---|
| 47 | #include <math.h>
|
---|
| 48 |
|
---|
| 49 | // NEEDS_WORK: replace use of const char* with <string>, once standard
|
---|
| 50 | // library is widely supported.
|
---|
| 51 |
|
---|
| 52 | BZ_NAMESPACE(blitz)
|
---|
| 53 |
|
---|
| 54 | // Declaration of class BenchmarkExt<T>
|
---|
| 55 | // The template parameter T is the parameter type which is varied in
|
---|
| 56 | // the benchmark. Typically T will be an unsigned, and will represent
|
---|
| 57 | // the length of a vector, size of an array, etc.
|
---|
| 58 |
|
---|
| 59 | template<class P_parameter = unsigned>
|
---|
| 60 | class BenchmarkExt {
|
---|
| 61 |
|
---|
| 62 | public:
|
---|
| 63 | typedef P_parameter T_parameter;
|
---|
| 64 |
|
---|
| 65 | BenchmarkExt(const char* description, int numImplementations);
|
---|
| 66 |
|
---|
| 67 | ~BenchmarkExt();
|
---|
| 68 |
|
---|
| 69 | void setNumParameters(int numParameters);
|
---|
| 70 | void setParameterVector(Vector<T_parameter> parms);
|
---|
| 71 | void setParameterDescription(const char* string);
|
---|
| 72 | void setIterations(Vector<long> iters);
|
---|
| 73 | void setFlopsPerIteration(Vector<double> flopsPerIteration);
|
---|
| 74 | void setRateDescription(const char* string);
|
---|
| 75 |
|
---|
| 76 | void beginBenchmarking();
|
---|
| 77 |
|
---|
| 78 | void beginImplementation(const char* description);
|
---|
| 79 |
|
---|
| 80 | _bz_bool doneImplementationBenchmark() const;
|
---|
| 81 |
|
---|
| 82 | T_parameter getParameter() const;
|
---|
| 83 | long getIterations() const;
|
---|
| 84 |
|
---|
| 85 | inline void start();
|
---|
| 86 | inline void stop();
|
---|
| 87 |
|
---|
| 88 | void startOverhead();
|
---|
| 89 | void stopOverhead();
|
---|
| 90 |
|
---|
| 91 | void endImplementation();
|
---|
| 92 |
|
---|
| 93 | void endBenchmarking();
|
---|
| 94 |
|
---|
| 95 | double getMflops(unsigned implementation, unsigned parameterNum) const;
|
---|
| 96 |
|
---|
| 97 | void saveMatlabGraph(const char* filename) const;
|
---|
| 98 |
|
---|
| 99 | protected:
|
---|
| 100 | BenchmarkExt(const BenchmarkExt<P_parameter>&) { }
|
---|
| 101 | void operator=(const BenchmarkExt<P_parameter>&) { }
|
---|
| 102 |
|
---|
| 103 | enum { initializing, benchmarking, benchmarkingImplementation,
|
---|
| 104 | running, runningOverhead, done } state_;
|
---|
| 105 |
|
---|
| 106 | unsigned numImplementations_;
|
---|
| 107 | unsigned implementationNumber_;
|
---|
| 108 |
|
---|
| 109 | const char* description_;
|
---|
| 110 | Vector<const char*> implementationDescriptions_;
|
---|
| 111 |
|
---|
| 112 | Matrix<double,RowMajor> times_; // Elapsed time
|
---|
| 113 |
|
---|
| 114 | Vector<T_parameter> parameters_;
|
---|
| 115 | Vector<long> iterations_;
|
---|
| 116 | Vector<double> flopsPerIteration_;
|
---|
| 117 |
|
---|
| 118 | Timer timer_;
|
---|
| 119 | Timer overheadTimer_;
|
---|
| 120 |
|
---|
| 121 | const char* parameterDescription_;
|
---|
| 122 | const char* rateDescription_;
|
---|
| 123 |
|
---|
| 124 | int numParameters_;
|
---|
| 125 | int parameterNumber_;
|
---|
| 126 | };
|
---|
| 127 |
|
---|
| 128 | BZ_NAMESPACE_END
|
---|
| 129 |
|
---|
| 130 | #include <blitz/benchext.cc>
|
---|
| 131 |
|
---|
| 132 | #endif // BZ_BENCHEXT_H
|
---|