x86_perf_analyzer.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  x86_perf_analyzer.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>
00004 // Copyright (C) EDF R&D,  mar d�c 3 18:59:35 CET 2002
00005 //=====================================================
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 //
00020 #ifndef _X86_PERF_ANALYSER_HH
00021 #define _X86_PERF_ANALYSER_HH
00022 
00023 #include "x86_timer.hh"
00024 #include "bench_parameter.hh"
00025 
00026 template<class ACTION>
00027 class X86_Perf_Analyzer{
00028 public:
00029   X86_Perf_Analyzer( unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
00030   {
00031     MESSAGE("X86_Perf_Analyzer Ctor");
00032     _chronos.find_frequency();
00033   };
00034   X86_Perf_Analyzer( const X86_Perf_Analyzer & ){
00035     INFOS("Copy Ctor not implemented");
00036     exit(0);
00037   };
00038   ~X86_Perf_Analyzer( void ){
00039     MESSAGE("X86_Perf_Analyzer Dtor");
00040   };
00041 
00042 
00043   inline double eval_mflops(int size)
00044   {
00045 
00046     ACTION action(size);
00047 
00048     int nb_loop=5;
00049     double calculate_time=0.0;
00050     double baseline_time=0.0;
00051 
00052     for (int j=0 ; j < nb_loop ; j++){
00053 
00054       _chronos.clear();
00055 
00056       for(int i=0 ; i < _nb_sample  ; i++)
00057       {
00058         _chronos.start();
00059         action.initialize();
00060         action.calculate();
00061         _chronos.stop();
00062         _chronos.add_get_click();
00063       }
00064 
00065       calculate_time += double(_chronos.get_shortest_clicks())/_chronos.frequency();
00066 
00067       if (j==0) action.check_result();
00068 
00069       _chronos.clear();
00070 
00071       for(int i=0 ; i < _nb_sample  ; i++)
00072       {
00073         _chronos.start();
00074         action.initialize();
00075         _chronos.stop();
00076         _chronos.add_get_click();
00077 
00078       }
00079 
00080       baseline_time+=double(_chronos.get_shortest_clicks())/_chronos.frequency();
00081 
00082     }
00083 
00084     double corrected_time = (calculate_time-baseline_time)/double(nb_loop);
00085 
00086 
00087 //     INFOS("_nb_sample="<<_nb_sample);
00088 //     INFOS("baseline_time="<<baseline_time);
00089 //     INFOS("calculate_time="<<calculate_time);
00090 //     INFOS("corrected_time="<<corrected_time);
00091 
00092 //    cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;
00093 
00094     return action.nb_op_base()/(corrected_time*1000000.0);
00095     //return action.nb_op_base()/(calculate_time*1000000.0);
00096   }
00097 
00098 private:
00099 
00100   X86_Timer _chronos;
00101   unsigned long long _nb_sample;
00102 
00103 
00104 };
00105 
00106 
00107 
00108 #endif


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:34:05