portable_perf_analyzer.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 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //=====================================================
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 //
21 #ifndef _PORTABLE_PERF_ANALYZER_HH
22 #define _PORTABLE_PERF_ANALYZER_HH
23 
24 #include "utilities.h"
25 #include "timers/portable_timer.hh"
26 
27 template <class Action>
29 public:
31  MESSAGE("Portable_Perf_Analyzer Ctor");
32  };
34  INFOS("Copy Ctor not implemented");
35  exit(0);
36  };
38  MESSAGE("Portable_Perf_Analyzer Dtor");
39  };
40 
42  {
44 
45 // action.initialize();
46 // time_action = time_calculate(action);
47  while (m_time_action < MIN_TIME)
48  {
49  if(_nb_calc==0) _nb_calc = 1;
50  else _nb_calc *= 2;
51  action.initialize();
53  }
54 
55  // optimize
56  for (int i=1; i<BtlConfig::Instance.tries; ++i)
57  {
58  Action _action(size);
59  std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " ";
60  _action.initialize();
62  }
63 
64  double time_action = m_time_action / (double(_nb_calc));
65 
66  // check
67  if (BtlConfig::Instance.checkResults && size<128)
68  {
69  action.initialize();
70  action.calculate();
71  action.check_result();
72  }
73  return action.nb_op_base()/(time_action*1e6);
74  }
75 
77  {
78  // time measurement
79  action.calculate();
80  _chronos.start();
81  for (unsigned int ii=0;ii<_nb_calc;ii++)
82  {
83  action.calculate();
84  }
85  _chronos.stop();
86  return _chronos.user_time();
87  }
88 
89  unsigned long long get_nb_calc()
90  {
91  return _nb_calc;
92  }
93 
94 
95 private:
96  unsigned long long _nb_calc;
97  double m_time_action;
99 
100 };
101 
102 #endif //_PORTABLE_PERF_ANALYZER_HH
103 
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::m_time_action
double m_time_action
Definition: portable_perf_analyzer.hh:97
Portable_Perf_Analyzer::time_calculate
BTL_DONT_INLINE double time_calculate(Action &action)
Definition: portable_perf_analyzer.hh:76
Portable_Perf_Analyzer::~Portable_Perf_Analyzer
~Portable_Perf_Analyzer()
Definition: portable_perf_analyzer.hh:37
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_Timer
Definition: portable_timer.hh:139
Portable_Perf_Analyzer::_chronos
Portable_Timer _chronos
Definition: portable_perf_analyzer.hh:98
Portable_Perf_Analyzer::eval_mflops
BTL_DONT_INLINE double eval_mflops(int size)
Definition: portable_perf_analyzer.hh:41
gtsam.examples.DogLegOptimizerExample.action
action
Definition: DogLegOptimizerExample.py:115
Portable_Timer::user_time
double user_time()
Definition: portable_timer.hh:172
Portable_Perf_Analyzer::get_nb_calc
unsigned long long get_nb_calc()
Definition: portable_perf_analyzer.hh:89
BtlConfig::tries
int tries
Definition: btl.hh:233
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
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.hh:33
Portable_Perf_Analyzer::Portable_Perf_Analyzer
Portable_Perf_Analyzer()
Definition: portable_perf_analyzer.hh:30
BTL_DONT_INLINE
#define BTL_DONT_INLINE
Definition: btl.hh:38
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
BtlConfig::Instance
static BtlConfig Instance
Definition: btl.hh:229


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:12:45