mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -1,14 +1,14 @@
|
||||
//=====================================================
|
||||
// File : mean.cxx
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// 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
|
||||
@@ -16,7 +16,7 @@
|
||||
// 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 <vector>
|
||||
#include <string>
|
||||
@@ -28,155 +28,138 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
double mean_calc(const vector<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max);
|
||||
double mean_calc(const vector<int> &tab_sizes, const vector<double> &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(){
|
||||
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){
|
||||
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){
|
||||
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");
|
||||
}
|
||||
|
||||
~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) ;
|
||||
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){
|
||||
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]);
|
||||
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<Lib_Mean> s_lib_mean;
|
||||
|
||||
multiset<Lib_Mean> s_lib_mean ;
|
||||
for (int i = 6; i < argc; i++) {
|
||||
string filename = argv[i];
|
||||
|
||||
for (int i=6;i<argc;i++){
|
||||
|
||||
string filename=argv[i];
|
||||
|
||||
INFOS(filename);
|
||||
|
||||
double mic=0;
|
||||
double moc=0;
|
||||
double mic = 0;
|
||||
double moc = 0;
|
||||
|
||||
{
|
||||
|
||||
vector<int> tab_sizes;
|
||||
vector<double> tab_mflops;
|
||||
|
||||
read_xy_file(filename,tab_sizes,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);
|
||||
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);
|
||||
Lib_Mean cur_lib_mean(filename, mic, moc);
|
||||
|
||||
}
|
||||
|
||||
s_lib_mean.insert(cur_lib_mean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cout << "<TABLE BORDER CELLPADDING=2>" << endl ;
|
||||
cout << " <TR>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> " << argv[1] << " </TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> in cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> in cache <BR> % best </TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> <a href=""#mean_marker""> out of cache <BR> mean perf <BR> Mflops </a></TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> out of cache <BR> % best </TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> details </TH>" << endl ;
|
||||
cout << " <TH ALIGN=CENTER> comments </TH>" << endl ;
|
||||
cout << " </TR>" << endl ;
|
||||
cout << "<TABLE BORDER CELLPADDING=2>" << endl;
|
||||
cout << " <TR>" << endl;
|
||||
cout << " <TH ALIGN=CENTER> " << argv[1] << " </TH>" << endl;
|
||||
cout << " <TH ALIGN=CENTER> <a href="
|
||||
"#mean_marker"
|
||||
"> in cache <BR> mean perf <BR> Mflops </a></TH>"
|
||||
<< endl;
|
||||
cout << " <TH ALIGN=CENTER> in cache <BR> % best </TH>" << endl;
|
||||
cout << " <TH ALIGN=CENTER> <a href="
|
||||
"#mean_marker"
|
||||
"> out of cache <BR> mean perf <BR> Mflops </a></TH>"
|
||||
<< endl;
|
||||
cout << " <TH ALIGN=CENTER> out of cache <BR> % best </TH>" << endl;
|
||||
cout << " <TH ALIGN=CENTER> details </TH>" << endl;
|
||||
cout << " <TH ALIGN=CENTER> comments </TH>" << endl;
|
||||
cout << " </TR>" << endl;
|
||||
|
||||
multiset<Lib_Mean>::iterator is = s_lib_mean.begin();
|
||||
Lib_Mean best(*is);
|
||||
|
||||
Lib_Mean best(*is);
|
||||
|
||||
for (is=s_lib_mean.begin(); is!=s_lib_mean.end() ; is++){
|
||||
|
||||
cout << " <TR>" << endl ;
|
||||
cout << " <TD> " << is->_lib_name << " </TD>" << endl ;
|
||||
cout << " <TD> " << is->_mean_in_cache << " </TD>" << endl ;
|
||||
cout << " <TD> " << 100*(is->_mean_in_cache/best._mean_in_cache) << " </TD>" << endl ;
|
||||
cout << " <TD> " << is->_mean_out_of_cache << " </TD>" << endl ;
|
||||
cout << " <TD> " << 100*(is->_mean_out_of_cache/best._mean_out_of_cache) << " </TD>" << endl ;
|
||||
cout << " <TD> " <<
|
||||
"<a href=\"#"<<is->_lib_name<<"_"<<argv[1]<<"\">snippet</a>/"
|
||||
"<a href=\"#"<<is->_lib_name<<"_flags\">flags</a> </TD>" << endl ;
|
||||
cout << " <TD> " <<
|
||||
"<a href=\"#"<<is->_lib_name<<"_comments\">click here</a> </TD>" << endl ;
|
||||
cout << " </TR>" << endl ;
|
||||
|
||||
for (is = s_lib_mean.begin(); is != s_lib_mean.end(); is++) {
|
||||
cout << " <TR>" << endl;
|
||||
cout << " <TD> " << is->_lib_name << " </TD>" << endl;
|
||||
cout << " <TD> " << is->_mean_in_cache << " </TD>" << endl;
|
||||
cout << " <TD> " << 100 * (is->_mean_in_cache / best._mean_in_cache) << " </TD>" << endl;
|
||||
cout << " <TD> " << is->_mean_out_of_cache << " </TD>" << endl;
|
||||
cout << " <TD> " << 100 * (is->_mean_out_of_cache / best._mean_out_of_cache) << " </TD>" << endl;
|
||||
cout << " <TD> "
|
||||
<< "<a href=\"#" << is->_lib_name << "_" << argv[1]
|
||||
<< "\">snippet</a>/"
|
||||
"<a href=\"#"
|
||||
<< is->_lib_name << "_flags\">flags</a> </TD>" << endl;
|
||||
cout << " <TD> "
|
||||
<< "<a href=\"#" << is->_lib_name << "_comments\">click here</a> </TD>" << endl;
|
||||
cout << " </TR>" << endl;
|
||||
}
|
||||
|
||||
cout << "</TABLE>" << endl ;
|
||||
cout << "</TABLE>" << 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 ;
|
||||
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<int> & tab_sizes, const vector<double> & tab_mflops, const int size_min, const int size_max){
|
||||
|
||||
int size=tab_sizes.size();
|
||||
int nb_sample=0;
|
||||
double mean=0.0;
|
||||
double mean_calc(const vector<int> &tab_sizes, const vector<double> &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)){
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if ((tab_sizes[i] >= size_min) && (tab_sizes[i] <= size_max)) {
|
||||
nb_sample++;
|
||||
mean+=tab_mflops[i];
|
||||
|
||||
mean += tab_mflops[i];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (nb_sample==0){
|
||||
if (nb_sample == 0) {
|
||||
INFOS("no data for mean calculation");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return mean/nb_sample;
|
||||
return mean / nb_sample;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//=====================================================
|
||||
// File : regularize.cxx
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// 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
|
||||
@@ -16,7 +16,7 @@
|
||||
// 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 <vector>
|
||||
#include <string>
|
||||
@@ -27,99 +27,82 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
|
||||
void regularize_curve(const string & filename,
|
||||
const vector<double> & tab_mflops,
|
||||
const vector<int> & tab_sizes,
|
||||
int start_cut_size, int stop_cut_size);
|
||||
void read_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops);
|
||||
void regularize_curve(const string &filename, const vector<double> &tab_mflops, const vector<int> &tab_sizes,
|
||||
int start_cut_size, int stop_cut_size);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main( int argc , char *argv[] )
|
||||
{
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// input data
|
||||
|
||||
if (argc<4){
|
||||
if (argc < 4) {
|
||||
INFOS("!!! Error ... usage : main filename start_cut_size stop_cut_size regularize_filename");
|
||||
exit(0);
|
||||
}
|
||||
INFOS(argc);
|
||||
|
||||
int start_cut_size=atoi(argv[2]);
|
||||
int stop_cut_size=atoi(argv[3]);
|
||||
int start_cut_size = atoi(argv[2]);
|
||||
int stop_cut_size = atoi(argv[3]);
|
||||
|
||||
string filename = argv[1];
|
||||
string regularize_filename = argv[4];
|
||||
|
||||
string filename=argv[1];
|
||||
string regularize_filename=argv[4];
|
||||
|
||||
INFOS(filename);
|
||||
INFOS("start_cut_size="<<start_cut_size);
|
||||
INFOS("start_cut_size=" << start_cut_size);
|
||||
|
||||
vector<int> tab_sizes;
|
||||
vector<double> tab_mflops;
|
||||
|
||||
read_xy_file(filename,tab_sizes,tab_mflops);
|
||||
read_xy_file(filename, tab_sizes, tab_mflops);
|
||||
|
||||
// regularizeing
|
||||
|
||||
regularize_curve(regularize_filename,tab_mflops,tab_sizes,start_cut_size,stop_cut_size);
|
||||
|
||||
|
||||
regularize_curve(regularize_filename, tab_mflops, tab_sizes, start_cut_size, stop_cut_size);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void regularize_curve(const string & filename,
|
||||
const vector<double> & tab_mflops,
|
||||
const vector<int> & tab_sizes,
|
||||
int start_cut_size, int stop_cut_size)
|
||||
{
|
||||
int size=tab_mflops.size();
|
||||
ofstream output_file (filename.c_str(),ios::out) ;
|
||||
void regularize_curve(const string &filename, const vector<double> &tab_mflops, const vector<int> &tab_sizes,
|
||||
int start_cut_size, int stop_cut_size) {
|
||||
int size = tab_mflops.size();
|
||||
ofstream output_file(filename.c_str(), ios::out);
|
||||
|
||||
int i=0;
|
||||
int i = 0;
|
||||
|
||||
while(tab_sizes[i]<start_cut_size){
|
||||
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
|
||||
while (tab_sizes[i] < start_cut_size) {
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl;
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
output_file << endl ;
|
||||
|
||||
while(tab_sizes[i]<stop_cut_size){
|
||||
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
while(i<size){
|
||||
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
|
||||
i++;
|
||||
output_file << endl;
|
||||
|
||||
while (tab_sizes[i] < stop_cut_size) {
|
||||
i++;
|
||||
}
|
||||
|
||||
while (i < size) {
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl;
|
||||
i++;
|
||||
}
|
||||
|
||||
output_file.close();
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
|
||||
void read_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops) {
|
||||
ifstream input_file(filename.c_str(), ios::in);
|
||||
|
||||
ifstream input_file (filename.c_str(),ios::in) ;
|
||||
|
||||
if (!input_file){
|
||||
INFOS("!!! Error opening "<<filename);
|
||||
if (!input_file) {
|
||||
INFOS("!!! Error opening " << filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int nb_point=0;
|
||||
int size=0;
|
||||
double mflops=0;
|
||||
|
||||
while (input_file >> size >> mflops ){
|
||||
int nb_point = 0;
|
||||
int size = 0;
|
||||
double mflops = 0;
|
||||
|
||||
while (input_file >> size >> mflops) {
|
||||
nb_point++;
|
||||
tab_sizes.push_back(size);
|
||||
tab_mflops.push_back(mflops);
|
||||
@@ -128,4 +111,3 @@ void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<doubl
|
||||
|
||||
input_file.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
//=====================================================
|
||||
// File : smooth.cxx
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// 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
|
||||
@@ -16,7 +16,7 @@
|
||||
// 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 <vector>
|
||||
#include <deque>
|
||||
@@ -28,165 +28,133 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
|
||||
void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops);
|
||||
void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
|
||||
void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width);
|
||||
void read_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops);
|
||||
void write_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops);
|
||||
void smooth_curve(const vector<double> &tab_mflops, vector<double> &smooth_tab_mflops, int window_half_width);
|
||||
void centered_smooth_curve(const vector<double> &tab_mflops, vector<double> &smooth_tab_mflops, int window_half_width);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int main( int argc , char *argv[] )
|
||||
{
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// input data
|
||||
|
||||
if (argc<3){
|
||||
if (argc < 3) {
|
||||
INFOS("!!! Error ... usage : main filename window_half_width smooth_filename");
|
||||
exit(0);
|
||||
}
|
||||
INFOS(argc);
|
||||
|
||||
int window_half_width=atoi(argv[2]);
|
||||
int window_half_width = atoi(argv[2]);
|
||||
|
||||
string filename = argv[1];
|
||||
string smooth_filename = argv[3];
|
||||
|
||||
string filename=argv[1];
|
||||
string smooth_filename=argv[3];
|
||||
|
||||
INFOS(filename);
|
||||
INFOS("window_half_width="<<window_half_width);
|
||||
INFOS("window_half_width=" << window_half_width);
|
||||
|
||||
vector<int> tab_sizes;
|
||||
vector<double> tab_mflops;
|
||||
|
||||
read_xy_file(filename,tab_sizes,tab_mflops);
|
||||
read_xy_file(filename, tab_sizes, tab_mflops);
|
||||
|
||||
// smoothing
|
||||
|
||||
vector<double> smooth_tab_mflops;
|
||||
|
||||
//smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
|
||||
centered_smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
|
||||
// smooth_curve(tab_mflops,smooth_tab_mflops,window_half_width);
|
||||
centered_smooth_curve(tab_mflops, smooth_tab_mflops, window_half_width);
|
||||
|
||||
// output result
|
||||
|
||||
write_xy_file(smooth_filename,tab_sizes,smooth_tab_mflops);
|
||||
|
||||
|
||||
write_xy_file(smooth_filename, tab_sizes, smooth_tab_mflops);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class VECTOR>
|
||||
double weighted_mean(const VECTOR & data)
|
||||
{
|
||||
|
||||
double mean=0.0;
|
||||
|
||||
for (int i=0 ; i<data.size() ; i++){
|
||||
|
||||
mean+=data[i];
|
||||
template <class VECTOR>
|
||||
double weighted_mean(const VECTOR &data) {
|
||||
double mean = 0.0;
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
mean += data[i];
|
||||
}
|
||||
|
||||
return mean/double(data.size()) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return mean / double(data.size());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void smooth_curve(const vector<double> &tab_mflops, vector<double> &smooth_tab_mflops, int window_half_width) {
|
||||
int window_width = 2 * window_half_width + 1;
|
||||
|
||||
void smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
|
||||
|
||||
int window_width=2*window_half_width+1;
|
||||
|
||||
int size=tab_mflops.size();
|
||||
int size = tab_mflops.size();
|
||||
|
||||
vector<double> sample(window_width);
|
||||
|
||||
for (int i=0 ; i < size ; i++){
|
||||
|
||||
for ( int j=0 ; j < window_width ; j++ ){
|
||||
|
||||
int shifted_index=i+j-window_half_width;
|
||||
if (shifted_index<0) shifted_index=0;
|
||||
if (shifted_index>size-1) shifted_index=size-1;
|
||||
sample[j]=tab_mflops[shifted_index];
|
||||
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int j = 0; j < window_width; j++) {
|
||||
int shifted_index = i + j - window_half_width;
|
||||
if (shifted_index < 0) shifted_index = 0;
|
||||
if (shifted_index > size - 1) shifted_index = size - 1;
|
||||
sample[j] = tab_mflops[shifted_index];
|
||||
}
|
||||
|
||||
smooth_tab_mflops.push_back(weighted_mean(sample));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void centered_smooth_curve(const vector<double> & tab_mflops, vector<double> & smooth_tab_mflops,int window_half_width){
|
||||
|
||||
int max_window_width=2*window_half_width+1;
|
||||
void centered_smooth_curve(const vector<double> &tab_mflops, vector<double> &smooth_tab_mflops, int window_half_width) {
|
||||
int max_window_width = 2 * window_half_width + 1;
|
||||
|
||||
int size=tab_mflops.size();
|
||||
|
||||
|
||||
for (int i=0 ; i < size ; i++){
|
||||
int size = tab_mflops.size();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
deque<double> sample;
|
||||
|
||||
|
||||
sample.push_back(tab_mflops[i]);
|
||||
|
||||
for ( int j=1 ; j <= window_half_width ; j++ ){
|
||||
|
||||
int before=i-j;
|
||||
int after=i+j;
|
||||
|
||||
if ((before>=0)&&(after<size)) // inside of the vector
|
||||
{
|
||||
sample.push_front(tab_mflops[before]);
|
||||
sample.push_back(tab_mflops[after]);
|
||||
}
|
||||
for (int j = 1; j <= window_half_width; j++) {
|
||||
int before = i - j;
|
||||
int after = i + j;
|
||||
|
||||
if ((before >= 0) && (after < size)) // inside of the vector
|
||||
{
|
||||
sample.push_front(tab_mflops[before]);
|
||||
sample.push_back(tab_mflops[after]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
smooth_tab_mflops.push_back(weighted_mean(sample));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void write_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops) {
|
||||
ofstream output_file(filename.c_str(), ios::out);
|
||||
|
||||
for (int i = 0; i < tab_sizes.size(); i++) {
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void write_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
|
||||
|
||||
ofstream output_file (filename.c_str(),ios::out) ;
|
||||
|
||||
for (int i=0 ; i < tab_sizes.size() ; i++)
|
||||
{
|
||||
output_file << tab_sizes[i] << " " << tab_mflops[i] << endl ;
|
||||
}
|
||||
|
||||
output_file.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<double> & tab_mflops){
|
||||
void read_xy_file(const string &filename, vector<int> &tab_sizes, vector<double> &tab_mflops) {
|
||||
ifstream input_file(filename.c_str(), ios::in);
|
||||
|
||||
ifstream input_file (filename.c_str(),ios::in) ;
|
||||
|
||||
if (!input_file){
|
||||
INFOS("!!! Error opening "<<filename);
|
||||
if (!input_file) {
|
||||
INFOS("!!! Error opening " << filename);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int nb_point=0;
|
||||
int size=0;
|
||||
double mflops=0;
|
||||
|
||||
while (input_file >> size >> mflops ){
|
||||
int nb_point = 0;
|
||||
int size = 0;
|
||||
double mflops = 0;
|
||||
|
||||
while (input_file >> size >> mflops) {
|
||||
nb_point++;
|
||||
tab_sizes.push_back(size);
|
||||
tab_mflops.push_back(mflops);
|
||||
@@ -195,4 +163,3 @@ void read_xy_file(const string & filename, vector<int> & tab_sizes, vector<doubl
|
||||
|
||||
input_file.close();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user