portable_perf_analyzer_old.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : portable_perf_analyzer.hh
3 // Author : L. Plagne <laurent.plagne@edf.fr)>
4 // Copyright (C) EDF R&D, mar d�c 3 18:59:35 CET 2002
5 //=====================================================
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 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 //
20 #ifndef _PORTABLE_PERF_ANALYZER_HH
21 #define _PORTABLE_PERF_ANALYZER_HH
22 
23 #include "utilities.h"
24 #include "timers/portable_timer.hh"
25 
26 template <class Action>
28 public:
30  MESSAGE("Portable_Perf_Analyzer Ctor");
31  };
33  INFOS("Copy Ctor not implemented");
34  exit(0);
35  };
37  MESSAGE("Portable_Perf_Analyzer Dtor");
38  };
39 
40 
41 
42  inline double eval_mflops(int size)
43  {
44 
46 
47 // double time_baseline = time_init(action);
48 // while (time_baseline < MIN_TIME_INIT)
49 // {
50 // _nb_init *= 2;
51 // time_baseline = time_init(action);
52 // }
53 //
54 // // optimize
55 // for (int i=1; i<NB_TRIES; ++i)
56 // time_baseline = std::min(time_baseline, time_init(action));
57 //
58 // time_baseline = time_baseline/(double(_nb_init));
59 
60  double time_action = time_calculate(action);
61  while (time_action < MIN_TIME)
62  {
63  _nb_calc *= 2;
64  time_action = time_calculate(action);
65  }
66 
67  // optimize
68  for (int i=1; i<NB_TRIES; ++i)
69  time_action = std::min(time_action, time_calculate(action));
70 
71 // INFOS("size="<<size);
72 // INFOS("_nb_init="<<_nb_init);
73 // INFOS("_nb_calc="<<_nb_calc);
74 
75  time_action = time_action / (double(_nb_calc));
76 
77  action.check_result();
78 
79 
80  double time_baseline = time_init(action);
81  for (int i=1; i<NB_TRIES; ++i)
82  time_baseline = std::min(time_baseline, time_init(action));
83  time_baseline = time_baseline/(double(_nb_init));
84 
85 
86 
87 // INFOS("time_baseline="<<time_baseline);
88 // INFOS("time_action="<<time_action);
89 
90  time_action = time_action - time_baseline;
91 
92 // INFOS("time_corrected="<<time_action);
93 
94  return action.nb_op_base()/(time_action*1000000.0);
95  }
96 
97  inline double time_init(Action & action)
98  {
99  // time measurement
100  _chronos.start();
101  for (int ii=0; ii<_nb_init; ii++)
102  action.initialize();
103  _chronos.stop();
104  return _chronos.user_time();
105  }
106 
107 
108  inline double time_calculate(Action & action)
109  {
110  // time measurement
111  _chronos.start();
112  for (int ii=0;ii<_nb_calc;ii++)
113  {
114  action.initialize();
115  action.calculate();
116  }
117  _chronos.stop();
118  return _chronos.user_time();
119  }
120 
121  unsigned long long get_nb_calc( void )
122  {
123  return _nb_calc;
124  }
125 
126 
127 private:
128  unsigned long long _nb_calc;
129  unsigned long long _nb_init;
131 
132 };
133 
134 #endif //_PORTABLE_PERF_ANALYZER_HH
Portable_Perf_Analyzer::_nb_calc
unsigned long long _nb_calc
Definition: portable_perf_analyzer.hh:96
MIN_TIME
#define MIN_TIME
Definition: bench_parameter.hh:26
Portable_Perf_Analyzer::eval_mflops
double eval_mflops(int size)
Definition: portable_perf_analyzer_old.hh:42
Portable_Perf_Analyzer::Portable_Perf_Analyzer
Portable_Perf_Analyzer(void)
Definition: portable_perf_analyzer_old.hh:29
Portable_Perf_Analyzer::time_calculate
BTL_DONT_INLINE double time_calculate(Action &action)
Definition: portable_perf_analyzer.hh:76
Portable_Perf_Analyzer::get_nb_calc
unsigned long long get_nb_calc(void)
Definition: portable_perf_analyzer_old.hh:121
Portable_Perf_Analyzer::time_calculate
double time_calculate(Action &action)
Definition: portable_perf_analyzer_old.hh:108
Portable_Perf_Analyzer
Definition: portable_perf_analyzer.hh:28
Portable_Timer::stop
void stop()
Definition: portable_timer.hh:159
portable_timer.hh
size
Scalar Scalar int size
Definition: benchVecAdd.cpp:17
MESSAGE
#define MESSAGE(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:76
Portable_Perf_Analyzer::~Portable_Perf_Analyzer
~Portable_Perf_Analyzer(void)
Definition: portable_perf_analyzer_old.hh:36
Portable_Timer
Definition: portable_timer.hh:139
Portable_Perf_Analyzer::_chronos
Portable_Timer _chronos
Definition: portable_perf_analyzer.hh:98
gtsam.examples.DogLegOptimizerExample.action
action
Definition: DogLegOptimizerExample.py:115
Portable_Perf_Analyzer::_nb_init
unsigned long long _nb_init
Definition: portable_perf_analyzer_old.hh:129
Portable_Timer::user_time
double user_time()
Definition: portable_timer.hh:172
Portable_Timer::start
void start()
Definition: portable_timer.hh:151
Eigen::Action
Action
Definition: Constants.h:504
INFOS
#define INFOS(chain)
Definition: 3rdparty/Eigen/bench/btl/generic_bench/utils/utilities.h:22
Portable_Perf_Analyzer::time_init
double time_init(Action &action)
Definition: portable_perf_analyzer_old.hh:97
min
#define min(a, b)
Definition: datatypes.h:19
Portable_Perf_Analyzer::Portable_Perf_Analyzer
Portable_Perf_Analyzer(const Portable_Perf_Analyzer &)
Definition: portable_perf_analyzer_old.hh:32
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:34:23