//===================================================== // File : mean.cxx // Author : L. Plagne // Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 2002 //===================================================== // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // #include "utilities.h" #include #include #include #include #include "bench_parameter.hh" #include "utils/xy_file.hh" #include using namespace std; double mean_calc(const vector &tab_sizes, const vector &tab_mflops, const int size_min, const int size_max); class Lib_Mean { public: Lib_Mean(void) : _lib_name(), _mean_in_cache(), _mean_out_of_cache() { MESSAGE("Lib_mean Default Ctor"); MESSAGE("!!! should not be used"); exit(0); } Lib_Mean(const string &name, const double &mic, const double &moc) : _lib_name(name), _mean_in_cache(mic), _mean_out_of_cache(moc) { MESSAGE("Lib_mean Ctor"); } Lib_Mean(const Lib_Mean &lm) : _lib_name(lm._lib_name), _mean_in_cache(lm._mean_in_cache), _mean_out_of_cache(lm._mean_out_of_cache) { MESSAGE("Lib_mean Copy Ctor"); } ~Lib_Mean(void) { MESSAGE("Lib_mean Dtor"); } double _mean_in_cache; double _mean_out_of_cache; string _lib_name; bool operator<(const Lib_Mean &right) const { // return ( this->_mean_out_of_cache > right._mean_out_of_cache) ; return (this->_mean_in_cache > right._mean_in_cache); } }; int main(int argc, char *argv[]) { if (argc < 6) { INFOS("!!! Error ... usage : main what mic Mic moc Moc filename1 finename2..."); exit(0); } INFOS(argc); int min_in_cache = atoi(argv[2]); int max_in_cache = atoi(argv[3]); int min_out_of_cache = atoi(argv[4]); int max_out_of_cache = atoi(argv[5]); multiset s_lib_mean; for (int i = 6; i < argc; i++) { string filename = argv[i]; INFOS(filename); double mic = 0; double moc = 0; { vector tab_sizes; vector tab_mflops; read_xy_file(filename, tab_sizes, tab_mflops); mic = mean_calc(tab_sizes, tab_mflops, min_in_cache, max_in_cache); moc = mean_calc(tab_sizes, tab_mflops, min_out_of_cache, max_out_of_cache); Lib_Mean cur_lib_mean(filename, mic, moc); s_lib_mean.insert(cur_lib_mean); } } cout << "" << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; multiset::iterator is = s_lib_mean.begin(); Lib_Mean best(*is); for (is = s_lib_mean.begin(); is != s_lib_mean.end(); is++) { cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; cout << " " << endl; } cout << "
" << argv[1] << " in cache
mean perf
Mflops
in cache
% best
out of cache
mean perf
Mflops
out of cache
% best
details comments
" << is->_lib_name << " " << is->_mean_in_cache << " " << 100 * (is->_mean_in_cache / best._mean_in_cache) << " " << is->_mean_out_of_cache << " " << 100 * (is->_mean_out_of_cache / best._mean_out_of_cache) << " " << "_lib_name << "_" << argv[1] << "\">snippet/" "_lib_name << "_flags\">flags " << "_lib_name << "_comments\">click here
" << endl; ofstream output_file("../order_lib", ios::out); for (is = s_lib_mean.begin(); is != s_lib_mean.end(); is++) { output_file << is->_lib_name << endl; } output_file.close(); } double mean_calc(const vector &tab_sizes, const vector &tab_mflops, const int size_min, const int size_max) { int size = tab_sizes.size(); int nb_sample = 0; double mean = 0.0; for (int i = 0; i < size; i++) { if ((tab_sizes[i] >= size_min) && (tab_sizes[i] <= size_max)) { nb_sample++; mean += tab_mflops[i]; } } if (nb_sample == 0) { INFOS("no data for mean calculation"); return 0.0; } return mean / nb_sample; }