You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

182 lines
5.2 KiB

  1. //=====================================================
  2. // File : mean.cxx
  3. // Author : L. Plagne <laurent.plagne@edf.fr)>
  4. // Copyright (C) EDF R&D, lun sep 30 14:23:15 CEST 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. #include "utilities.h"
  21. #include <vector>
  22. #include <string>
  23. #include <iostream>
  24. #include <fstream>
  25. #include "bench_parameter.hh"
  26. #include "utils/xy_file.hh"
  27. #include <set>
  28. using namespace std;
  29. double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max);
  30. class Lib_Mean{
  31. public:
  32. Lib_Mean( void ):_lib_name(),_mean_in_cache(),_mean_out_of_cache(){
  33. MESSAGE("Lib_mean Default Ctor");
  34. MESSAGE("!!! should not be used");
  35. exit(0);
  36. }
  37. Lib_Mean(const string & name, const double & mic, const double & moc):_lib_name(name),_mean_in_cache(mic),_mean_out_of_cache(moc){
  38. MESSAGE("Lib_mean Ctor");
  39. }
  40. 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){
  41. MESSAGE("Lib_mean Copy Ctor");
  42. }
  43. ~Lib_Mean( void ){
  44. MESSAGE("Lib_mean Dtor");
  45. }
  46. double _mean_in_cache;
  47. double _mean_out_of_cache;
  48. string _lib_name;
  49. bool operator < ( const Lib_Mean &right) const
  50. {
  51. //return ( this->_mean_out_of_cache > right._mean_out_of_cache) ;
  52. return ( this->_mean_in_cache > right._mean_in_cache) ;
  53. }
  54. };
  55. int main( int argc , char *argv[] )
  56. {
  57. if (argc<6){
  58. INFOS("!!! Error ... usage : main what mic Mic moc Moc filename1 finename2...");
  59. exit(0);
  60. }
  61. INFOS(argc);
  62. int min_in_cache=atoi(argv[2]);
  63. int max_in_cache=atoi(argv[3]);
  64. int min_out_of_cache=atoi(argv[4]);
  65. int max_out_of_cache=atoi(argv[5]);
  66. multiset<Lib_Mean> s_lib_mean ;
  67. for (int i=6;i<argc;i++){
  68. string filename=argv[i];
  69. INFOS(filename);
  70. double mic=0;
  71. double moc=0;
  72. {
  73. vector<int> tab_sizes;
  74. vector<double> tab_mflops;
  75. read_xy_file(filename,tab_sizes,tab_mflops);
  76. mic=mean_calc(tab_sizes,tab_mflops,min_in_cache,max_in_cache);
  77. moc=mean_calc(tab_sizes,tab_mflops,min_out_of_cache,max_out_of_cache);
  78. Lib_Mean cur_lib_mean(filename,mic,moc);
  79. s_lib_mean.insert(cur_lib_mean);
  80. }
  81. }
  82. cout << "<TABLE BORDER CELLPADDING=2>" << endl ;
  83. cout << " <TR>" << endl ;
  84. cout << " <TH ALIGN=CENTER> " << argv[1] << " </TH>" << endl ;
  85. cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> in cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
  86. cout << " <TH ALIGN=CENTER> in cache <BR> % best </TH>" << endl ;
  87. cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> out of cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
  88. cout << " <TH ALIGN=CENTER> out of cache <BR> % best </TH>" << endl ;
  89. cout << " <TH ALIGN=CENTER> details </TH>" << endl ;
  90. cout << " <TH ALIGN=CENTER> comments </TH>" << endl ;
  91. cout << " </TR>" << endl ;
  92. multiset<Lib_Mean>::iterator is = s_lib_mean.begin();
  93. Lib_Mean best(*is);
  94. for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
  95. cout << " <TR>" << endl ;
  96. cout << " <TD> " << is->_lib_name << " </TD>" << endl ;
  97. cout << " <TD> " << is->_mean_in_cache << " </TD>" << endl ;
  98. cout << " <TD> " << 100*(is->_mean_in_cache/best._mean_in_cache) << " </TD>" << endl ;
  99. cout << " <TD> " << is->_mean_out_of_cache << " </TD>" << endl ;
  100. cout << " <TD> " << 100*(is->_mean_out_of_cache/best._mean_out_of_cache) << " </TD>" << endl ;
  101. cout << " <TD> " <<
  102. "<a href=\"#"<<is->_lib_name<<"_"<<argv[1]<<"\">snippet</a>/"
  103. "<a href=\"#"<<is->_lib_name<<"_flags\">flags</a> </TD>" << endl ;
  104. cout << " <TD> " <<
  105. "<a href=\"#"<<is->_lib_name<<"_comments\">click here</a> </TD>" << endl ;
  106. cout << " </TR>" << endl ;
  107. }
  108. cout << "</TABLE>" << endl ;
  109. ofstream output_file ("../order_lib",ios::out) ;
  110. for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
  111. output_file << is->_lib_name << endl ;
  112. }
  113. output_file.close();
  114. }
  115. double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max){
  116. int size=tab_sizes.size();
  117. int nb_sample=0;
  118. double mean=0.0;
  119. for (int i=0;i<size;i++){
  120. if ((tab_sizes[i]>=size_min)&&(tab_sizes[i]<=size_max)){
  121. nb_sample++;
  122. mean+=tab_mflops[i];
  123. }
  124. }
  125. if (nb_sample==0){
  126. INFOS("no data for mean calculation");
  127. return 0.0;
  128. }
  129. return mean/nb_sample;
  130. }