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.

131 lines
3.3 KiB

  1. //=====================================================
  2. // File : regularize.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 <set>
  27. using namespace std;
  28. void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
  29. void regularize_curve(const string & filename,
  30. const vector<double> & tab_mflops,
  31. const vector<int> & tab_sizes,
  32. int start_cut_size, int stop_cut_size);
  33. /////////////////////////////////////////////////////////////////////////////////////////////////
  34. int main( int argc , char *argv[] )
  35. {
  36. // input data
  37. if (argc<4){
  38. INFOS("!!! Error ... usage : main filename start_cut_size stop_cut_size regularize_filename");
  39. exit(0);
  40. }
  41. INFOS(argc);
  42. int start_cut_size=atoi(argv[2]);
  43. int stop_cut_size=atoi(argv[3]);
  44. string filename=argv[1];
  45. string regularize_filename=argv[4];
  46. INFOS(filename);
  47. INFOS("start_cut_size="<<start_cut_size);
  48. vector<int> tab_sizes;
  49. vector<double> tab_mflops;
  50. read_xy_file(filename,tab_sizes,tab_mflops);
  51. // regularizeing
  52. regularize_curve(regularize_filename,tab_mflops,tab_sizes,start_cut_size,stop_cut_size);
  53. }
  54. //////////////////////////////////////////////////////////////////////////////////////
  55. void regularize_curve(const string & filename,
  56. const vector<double> & tab_mflops,
  57. const vector<int> & tab_sizes,
  58. int start_cut_size, int stop_cut_size)
  59. {
  60. int size=tab_mflops.size();
  61. ofstream output_file (filename.c_str(),ios::out) ;
  62. int i=0;
  63. while(tab_sizes[i]<start_cut_size){
  64. output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
  65. i++;
  66. }
  67. output_file << endl ;
  68. while(tab_sizes[i]<stop_cut_size){
  69. i++;
  70. }
  71. while(i<size){
  72. output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
  73. i++;
  74. }
  75. output_file.close();
  76. }
  77. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78. void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
  79. ifstream input_file (filename.c_str(),ios::in) ;
  80. if (!input_file){
  81. INFOS("!!! Error opening "<<filename);
  82. exit(0);
  83. }
  84. int nb_point=0;
  85. int size=0;
  86. double mflops=0;
  87. while (input_file >> size >> mflops ){
  88. nb_point++;
  89. tab_sizes.push_back(size);
  90. tab_mflops.push_back(mflops);
  91. }
  92. SCRUTE(nb_point);
  93. input_file.close();
  94. }