1 //=====================================================
2 // File   :  mixed_perf_analyzer.hh
3 // Author :  L. Plagne <laurent.plagne@edf.fr)>
4 // Copyright (C) EDF R&D,  mar d�c 3 18:59:36 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 _MIXED_PERF_ANALYSER_HH
21 #define _MIXED_PERF_ANALYSER_HH
22 
23 #include "x86_perf_analyzer.hh"
24 #include "portable_perf_analyzer.hh"
25 
26 // choose portable perf analyzer for long calculations and x86 analyser for short ones
27 
28 
29 template<class Action>
30 class Mixed_Perf_Analyzer{
31 
32 public:
Mixed_Perf_Analyzer(void)33   Mixed_Perf_Analyzer( void ):_x86pa(),_ppa(),_use_ppa(true)
34   {
35     MESSAGE("Mixed_Perf_Analyzer Ctor");
36   };
Mixed_Perf_Analyzer(const Mixed_Perf_Analyzer &)37   Mixed_Perf_Analyzer( const Mixed_Perf_Analyzer & ){
38     INFOS("Copy Ctor not implemented");
39     exit(0);
40   };
~Mixed_Perf_Analyzer(void)41   ~Mixed_Perf_Analyzer( void ){
42     MESSAGE("Mixed_Perf_Analyzer Dtor");
43   };
44 
45 
eval_mflops(int size)46   inline double eval_mflops(int size)
47   {
48 
49     double result=0.0;
50     if (_use_ppa){
51       result=_ppa.eval_mflops(size);
52       if (_ppa.get_nb_calc()>DEFAULT_NB_SAMPLE){_use_ppa=false;}
53     }
54     else{
55       result=_x86pa.eval_mflops(size);
56     }
57 
58     return result;
59   }
60 
61 private:
62 
63   Portable_Perf_Analyzer<Action> _ppa;
64   X86_Perf_Analyzer<Action> _x86pa;
65   bool _use_ppa;
66 
67 };
68 
69 #endif
70 
71 
72 
73 
74