Disabled external gits
This commit is contained in:
168
cs440-acg/ext/eigen/bench/btl/generic_bench/bench.hh
Normal file
168
cs440-acg/ext/eigen/bench/btl/generic_bench/bench.hh
Normal file
@@ -0,0 +1,168 @@
|
||||
//=====================================================
|
||||
// File : bench.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:16 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.
|
||||
//
|
||||
#ifndef BENCH_HH
|
||||
#define BENCH_HH
|
||||
|
||||
#include "btl.hh"
|
||||
#include "bench_parameter.hh"
|
||||
#include <iostream>
|
||||
#include "utilities.h"
|
||||
#include "size_lin_log.hh"
|
||||
#include "xy_file.hh"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "timers/portable_perf_analyzer.hh"
|
||||
// #include "timers/mixed_perf_analyzer.hh"
|
||||
// #include "timers/x86_perf_analyzer.hh"
|
||||
// #include "timers/STL_perf_analyzer.hh"
|
||||
#ifdef HAVE_MKL
|
||||
extern "C" void cblas_saxpy(const int, const float, const float*, const int, float *, const int);
|
||||
#endif
|
||||
using namespace std;
|
||||
|
||||
template <template<class> class Perf_Analyzer, class Action>
|
||||
BTL_DONT_INLINE void bench( int size_min, int size_max, int nb_point )
|
||||
{
|
||||
if (BtlConfig::skipAction(Action::name()))
|
||||
return;
|
||||
|
||||
string filename="bench_"+Action::name()+".dat";
|
||||
|
||||
INFOS("starting " <<filename);
|
||||
|
||||
// utilities
|
||||
|
||||
std::vector<double> tab_mflops(nb_point);
|
||||
std::vector<int> tab_sizes(nb_point);
|
||||
|
||||
// matrices and vector size calculations
|
||||
size_lin_log(nb_point,size_min,size_max,tab_sizes);
|
||||
|
||||
std::vector<int> oldSizes;
|
||||
std::vector<double> oldFlops;
|
||||
bool hasOldResults = read_xy_file(filename, oldSizes, oldFlops, true);
|
||||
int oldi = oldSizes.size() - 1;
|
||||
|
||||
// loop on matrix size
|
||||
Perf_Analyzer<Action> perf_action;
|
||||
for (int i=nb_point-1;i>=0;i--)
|
||||
{
|
||||
//INFOS("size=" <<tab_sizes[i]<<" ("<<nb_point-i<<"/"<<nb_point<<")");
|
||||
std::cout << " " << "size = " << tab_sizes[i] << " " << std::flush;
|
||||
|
||||
BTL_DISABLE_SSE_EXCEPTIONS();
|
||||
#ifdef HAVE_MKL
|
||||
{
|
||||
float dummy;
|
||||
cblas_saxpy(1,0,&dummy,1,&dummy,1);
|
||||
}
|
||||
#endif
|
||||
|
||||
tab_mflops[i] = perf_action.eval_mflops(tab_sizes[i]);
|
||||
std::cout << tab_mflops[i];
|
||||
|
||||
if (hasOldResults)
|
||||
{
|
||||
while (oldi>=0 && oldSizes[oldi]>tab_sizes[i])
|
||||
--oldi;
|
||||
if (oldi>=0 && oldSizes[oldi]==tab_sizes[i])
|
||||
{
|
||||
if (oldFlops[oldi]<tab_mflops[i])
|
||||
std::cout << "\t > ";
|
||||
else
|
||||
std::cout << "\t < ";
|
||||
std::cout << oldFlops[oldi];
|
||||
}
|
||||
--oldi;
|
||||
}
|
||||
std::cout << " MFlops (" << nb_point-i << "/" << nb_point << ")" << std::endl;
|
||||
}
|
||||
|
||||
if (!BtlConfig::Instance.overwriteResults)
|
||||
{
|
||||
if (hasOldResults)
|
||||
{
|
||||
// merge the two data
|
||||
std::vector<int> newSizes;
|
||||
std::vector<double> newFlops;
|
||||
unsigned int i=0;
|
||||
unsigned int j=0;
|
||||
while (i<tab_sizes.size() && j<oldSizes.size())
|
||||
{
|
||||
if (tab_sizes[i] == oldSizes[j])
|
||||
{
|
||||
newSizes.push_back(tab_sizes[i]);
|
||||
newFlops.push_back(std::max(tab_mflops[i], oldFlops[j]));
|
||||
++i;
|
||||
++j;
|
||||
}
|
||||
else if (tab_sizes[i] < oldSizes[j])
|
||||
{
|
||||
newSizes.push_back(tab_sizes[i]);
|
||||
newFlops.push_back(tab_mflops[i]);
|
||||
++i;
|
||||
}
|
||||
else
|
||||
{
|
||||
newSizes.push_back(oldSizes[j]);
|
||||
newFlops.push_back(oldFlops[j]);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
while (i<tab_sizes.size())
|
||||
{
|
||||
newSizes.push_back(tab_sizes[i]);
|
||||
newFlops.push_back(tab_mflops[i]);
|
||||
++i;
|
||||
}
|
||||
while (j<oldSizes.size())
|
||||
{
|
||||
newSizes.push_back(oldSizes[j]);
|
||||
newFlops.push_back(oldFlops[j]);
|
||||
++j;
|
||||
}
|
||||
tab_mflops = newFlops;
|
||||
tab_sizes = newSizes;
|
||||
}
|
||||
}
|
||||
|
||||
// dump the result in a file :
|
||||
dump_xy_file(tab_sizes,tab_mflops,filename);
|
||||
|
||||
}
|
||||
|
||||
// default Perf Analyzer
|
||||
|
||||
template <class Action>
|
||||
BTL_DONT_INLINE void bench( int size_min, int size_max, int nb_point ){
|
||||
|
||||
// if the rdtsc is not available :
|
||||
bench<Portable_Perf_Analyzer,Action>(size_min,size_max,nb_point);
|
||||
// if the rdtsc is available :
|
||||
// bench<Mixed_Perf_Analyzer,Action>(size_min,size_max,nb_point);
|
||||
|
||||
|
||||
// Only for small problem size. Otherwize it will be too long
|
||||
// bench<X86_Perf_Analyzer,Action>(size_min,size_max,nb_point);
|
||||
// bench<STL_Perf_Analyzer,Action>(size_min,size_max,nb_point);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
//=====================================================
|
||||
// File : bench_parameter.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:16 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.
|
||||
//
|
||||
#ifndef BENCH_PARAMETER_HH
|
||||
#define BENCH_PARAMETER_HH
|
||||
|
||||
// minimal time for each measurement
|
||||
#define REAL_TYPE float
|
||||
// minimal time for each measurement
|
||||
#define MIN_TIME 0.2
|
||||
// nb of point on bench curves
|
||||
#define NB_POINT 100
|
||||
// min vector size for axpy bench
|
||||
#define MIN_AXPY 5
|
||||
// max vector size for axpy bench
|
||||
#define MAX_AXPY 3000000
|
||||
// min matrix size for matrix vector product bench
|
||||
#define MIN_MV 5
|
||||
// max matrix size for matrix vector product bench
|
||||
#define MAX_MV 5000
|
||||
// min matrix size for matrix matrix product bench
|
||||
#define MIN_MM 5
|
||||
// max matrix size for matrix matrix product bench
|
||||
#define MAX_MM MAX_MV
|
||||
// min matrix size for LU bench
|
||||
#define MIN_LU 5
|
||||
// max matrix size for LU bench
|
||||
#define MAX_LU 3000
|
||||
// max size for tiny vector and matrix
|
||||
#define TINY_MV_MAX_SIZE 16
|
||||
// default nb_sample for x86 timer
|
||||
#define DEFAULT_NB_SAMPLE 1000
|
||||
|
||||
// how many times we run a single bench (keep the best perf)
|
||||
#define DEFAULT_NB_TRIES 3
|
||||
|
||||
#endif
|
||||
242
cs440-acg/ext/eigen/bench/btl/generic_bench/btl.hh
Normal file
242
cs440-acg/ext/eigen/bench/btl/generic_bench/btl.hh
Normal file
@@ -0,0 +1,242 @@
|
||||
//=====================================================
|
||||
// File : btl.hh
|
||||
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
//=====================================================
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
#ifndef BTL_HH
|
||||
#define BTL_HH
|
||||
|
||||
#include "bench_parameter.hh"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "utilities.h"
|
||||
|
||||
#if (defined __GNUC__)
|
||||
#define BTL_ALWAYS_INLINE __attribute__((always_inline)) inline
|
||||
#else
|
||||
#define BTL_ALWAYS_INLINE inline
|
||||
#endif
|
||||
|
||||
#if (defined __GNUC__)
|
||||
#define BTL_DONT_INLINE __attribute__((noinline))
|
||||
#else
|
||||
#define BTL_DONT_INLINE
|
||||
#endif
|
||||
|
||||
#if (defined __GNUC__)
|
||||
#define BTL_ASM_COMMENT(X) asm("#" X)
|
||||
#else
|
||||
#define BTL_ASM_COMMENT(X)
|
||||
#endif
|
||||
|
||||
#ifdef __SSE__
|
||||
#include "xmmintrin.h"
|
||||
// This enables flush to zero (FTZ) and denormals are zero (DAZ) modes:
|
||||
#define BTL_DISABLE_SSE_EXCEPTIONS() { _mm_setcsr(_mm_getcsr() | 0x8040); }
|
||||
#else
|
||||
#define BTL_DISABLE_SSE_EXCEPTIONS()
|
||||
#endif
|
||||
|
||||
/** Enhanced std::string
|
||||
*/
|
||||
class BtlString : public std::string
|
||||
{
|
||||
public:
|
||||
BtlString() : std::string() {}
|
||||
BtlString(const BtlString& str) : std::string(static_cast<const std::string&>(str)) {}
|
||||
BtlString(const std::string& str) : std::string(str) {}
|
||||
BtlString(const char* str) : std::string(str) {}
|
||||
|
||||
operator const char* () const { return c_str(); }
|
||||
|
||||
void trim( bool left = true, bool right = true )
|
||||
{
|
||||
int lspaces, rspaces, len = length(), i;
|
||||
lspaces = rspaces = 0;
|
||||
|
||||
if ( left )
|
||||
for (i=0; i<len && (at(i)==' '||at(i)=='\t'||at(i)=='\r'||at(i)=='\n'); ++lspaces,++i);
|
||||
|
||||
if ( right && lspaces < len )
|
||||
for(i=len-1; i>=0 && (at(i)==' '||at(i)=='\t'||at(i)=='\r'||at(i)=='\n'); rspaces++,i--);
|
||||
|
||||
*this = substr(lspaces, len-lspaces-rspaces);
|
||||
}
|
||||
|
||||
std::vector<BtlString> split( const BtlString& delims = "\t\n ") const
|
||||
{
|
||||
std::vector<BtlString> ret;
|
||||
unsigned int numSplits = 0;
|
||||
size_t start, pos;
|
||||
start = 0;
|
||||
do
|
||||
{
|
||||
pos = find_first_of(delims, start);
|
||||
if (pos == start)
|
||||
{
|
||||
ret.push_back("");
|
||||
start = pos + 1;
|
||||
}
|
||||
else if (pos == npos)
|
||||
ret.push_back( substr(start) );
|
||||
else
|
||||
{
|
||||
ret.push_back( substr(start, pos - start) );
|
||||
start = pos + 1;
|
||||
}
|
||||
//start = find_first_not_of(delims, start);
|
||||
++numSplits;
|
||||
} while (pos != npos);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool endsWith(const BtlString& str) const
|
||||
{
|
||||
if(str.size()>this->size())
|
||||
return false;
|
||||
return this->substr(this->size()-str.size(),str.size()) == str;
|
||||
}
|
||||
bool contains(const BtlString& str) const
|
||||
{
|
||||
return this->find(str)<this->size();
|
||||
}
|
||||
bool beginsWith(const BtlString& str) const
|
||||
{
|
||||
if(str.size()>this->size())
|
||||
return false;
|
||||
return this->substr(0,str.size()) == str;
|
||||
}
|
||||
|
||||
BtlString toLowerCase( void )
|
||||
{
|
||||
std::transform(begin(), end(), begin(), static_cast<int(*)(int)>(::tolower) );
|
||||
return *this;
|
||||
}
|
||||
BtlString toUpperCase( void )
|
||||
{
|
||||
std::transform(begin(), end(), begin(), static_cast<int(*)(int)>(::toupper) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** Case insensitive comparison.
|
||||
*/
|
||||
bool isEquiv(const BtlString& str) const
|
||||
{
|
||||
BtlString str0 = *this;
|
||||
str0.toLowerCase();
|
||||
BtlString str1 = str;
|
||||
str1.toLowerCase();
|
||||
return str0 == str1;
|
||||
}
|
||||
|
||||
/** Decompose the current string as a path and a file.
|
||||
For instance: "dir1/dir2/file.ext" leads to path="dir1/dir2/" and filename="file.ext"
|
||||
*/
|
||||
void decomposePathAndFile(BtlString& path, BtlString& filename) const
|
||||
{
|
||||
std::vector<BtlString> elements = this->split("/\\");
|
||||
path = "";
|
||||
filename = elements.back();
|
||||
elements.pop_back();
|
||||
if (this->at(0)=='/')
|
||||
path = "/";
|
||||
for (unsigned int i=0 ; i<elements.size() ; ++i)
|
||||
path += elements[i] + "/";
|
||||
}
|
||||
};
|
||||
|
||||
class BtlConfig
|
||||
{
|
||||
public:
|
||||
BtlConfig()
|
||||
: overwriteResults(false), checkResults(true), realclock(false), tries(DEFAULT_NB_TRIES)
|
||||
{
|
||||
char * _config;
|
||||
_config = getenv ("BTL_CONFIG");
|
||||
if (_config!=NULL)
|
||||
{
|
||||
std::vector<BtlString> config = BtlString(_config).split(" \t\n");
|
||||
for (unsigned int i = 0; i<config.size(); i++)
|
||||
{
|
||||
if (config[i].beginsWith("-a"))
|
||||
{
|
||||
if (i+1==config.size())
|
||||
{
|
||||
std::cerr << "error processing option: " << config[i] << "\n";
|
||||
exit(2);
|
||||
}
|
||||
Instance.m_selectedActionNames = config[i+1].split(":");
|
||||
|
||||
i += 1;
|
||||
}
|
||||
else if (config[i].beginsWith("-t"))
|
||||
{
|
||||
if (i+1==config.size())
|
||||
{
|
||||
std::cerr << "error processing option: " << config[i] << "\n";
|
||||
exit(2);
|
||||
}
|
||||
Instance.tries = atoi(config[i+1].c_str());
|
||||
|
||||
i += 1;
|
||||
}
|
||||
else if (config[i].beginsWith("--overwrite"))
|
||||
{
|
||||
Instance.overwriteResults = true;
|
||||
}
|
||||
else if (config[i].beginsWith("--nocheck"))
|
||||
{
|
||||
Instance.checkResults = false;
|
||||
}
|
||||
else if (config[i].beginsWith("--real"))
|
||||
{
|
||||
Instance.realclock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BTL_DISABLE_SSE_EXCEPTIONS();
|
||||
}
|
||||
|
||||
BTL_DONT_INLINE static bool skipAction(const std::string& _name)
|
||||
{
|
||||
if (Instance.m_selectedActionNames.empty())
|
||||
return false;
|
||||
|
||||
BtlString name(_name);
|
||||
for (unsigned int i=0; i<Instance.m_selectedActionNames.size(); ++i)
|
||||
if (name.contains(Instance.m_selectedActionNames[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static BtlConfig Instance;
|
||||
bool overwriteResults;
|
||||
bool checkResults;
|
||||
bool realclock;
|
||||
int tries;
|
||||
|
||||
protected:
|
||||
std::vector<BtlString> m_selectedActionNames;
|
||||
};
|
||||
|
||||
#define BTL_MAIN \
|
||||
BtlConfig BtlConfig::Instance
|
||||
|
||||
#endif // BTL_HH
|
||||
@@ -0,0 +1,54 @@
|
||||
//=====================================================
|
||||
// File : init_function.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:18 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.
|
||||
//
|
||||
#ifndef INIT_FUNCTION_HH
|
||||
#define INIT_FUNCTION_HH
|
||||
|
||||
double simple_function(int index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
double simple_function(int index_i, int index_j)
|
||||
{
|
||||
return index_i+index_j;
|
||||
}
|
||||
|
||||
double pseudo_random(int /*index*/)
|
||||
{
|
||||
return std::rand()/double(RAND_MAX);
|
||||
}
|
||||
|
||||
double pseudo_random(int /*index_i*/, int /*index_j*/)
|
||||
{
|
||||
return std::rand()/double(RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
double null_function(int /*index*/)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
double null_function(int /*index_i*/, int /*index_j*/)
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,64 @@
|
||||
//=====================================================
|
||||
// File : init_matrix.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:19 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.
|
||||
//
|
||||
#ifndef INIT_MATRIX_HH
|
||||
#define INIT_MATRIX_HH
|
||||
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for setting element
|
||||
// value_type defined
|
||||
template<double init_function(int,int), class Vector>
|
||||
BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
|
||||
|
||||
X.resize(size);
|
||||
|
||||
for (unsigned int j=0;j<X.size();j++){
|
||||
X[j]=typename Vector::value_type(init_function(row,j));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Matrix is a Vector of Vector
|
||||
// The Matrix class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for setting rows
|
||||
template<double init_function(int,int),class Vector>
|
||||
BTL_DONT_INLINE void init_matrix(Vector & A, int size){
|
||||
A.resize(size);
|
||||
for (unsigned int row=0; row<A.size() ; row++){
|
||||
init_row<init_function>(A[row],size,row);
|
||||
}
|
||||
}
|
||||
|
||||
template<double init_function(int,int),class Matrix>
|
||||
BTL_DONT_INLINE void init_matrix_symm(Matrix& A, int size){
|
||||
A.resize(size);
|
||||
for (unsigned int row=0; row<A.size() ; row++)
|
||||
A[row].resize(size);
|
||||
for (unsigned int row=0; row<A.size() ; row++){
|
||||
A[row][row] = init_function(row,row);
|
||||
for (unsigned int col=0; col<row ; col++){
|
||||
double x = init_function(row,col);
|
||||
A[row][col] = A[col][row] = x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,37 @@
|
||||
//=====================================================
|
||||
// File : init_vector.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:18 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.
|
||||
//
|
||||
#ifndef INIT_VECTOR_HH
|
||||
#define INIT_VECTOR_HH
|
||||
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for setting element
|
||||
// value_type defined
|
||||
template<double init_function(int), class Vector>
|
||||
void init_vector(Vector & X, int size){
|
||||
|
||||
X.resize(size);
|
||||
|
||||
for (unsigned int i=0;i<X.size();i++){
|
||||
X[i]=typename Vector::value_type(init_function(i));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,80 @@
|
||||
//=====================================================
|
||||
// File : bench_static.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:16 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.
|
||||
//
|
||||
#ifndef BENCH_STATIC_HH
|
||||
#define BENCH_STATIC_HH
|
||||
|
||||
#include "btl.hh"
|
||||
#include "bench_parameter.hh"
|
||||
#include <iostream>
|
||||
#include "utilities.h"
|
||||
#include "xy_file.hh"
|
||||
#include "static/static_size_generator.hh"
|
||||
#include "timers/portable_perf_analyzer.hh"
|
||||
// #include "timers/mixed_perf_analyzer.hh"
|
||||
// #include "timers/x86_perf_analyzer.hh"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
template <template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
|
||||
BTL_DONT_INLINE void bench_static(void)
|
||||
{
|
||||
if (BtlConfig::skipAction(Action<Interface<REAL_TYPE,10> >::name()))
|
||||
return;
|
||||
|
||||
string filename = "bench_" + Action<Interface<REAL_TYPE,10> >::name() + ".dat";
|
||||
|
||||
INFOS("starting " << filename);
|
||||
|
||||
const int max_size = TINY_MV_MAX_SIZE;
|
||||
|
||||
std::vector<double> tab_mflops;
|
||||
std::vector<double> tab_sizes;
|
||||
|
||||
static_size_generator<max_size,Perf_Analyzer,Action,Interface>::go(tab_sizes,tab_mflops);
|
||||
|
||||
dump_xy_file(tab_sizes,tab_mflops,filename);
|
||||
}
|
||||
|
||||
// default Perf Analyzer
|
||||
template <template<class> class Action, template<class,int> class Interface>
|
||||
BTL_DONT_INLINE void bench_static(void)
|
||||
{
|
||||
bench_static<Portable_Perf_Analyzer,Action,Interface>();
|
||||
//bench_static<Mixed_Perf_Analyzer,Action,Interface>();
|
||||
//bench_static<X86_Perf_Analyzer,Action,Interface>();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//=====================================================
|
||||
// File : intel_bench_fixed_size.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:37 CET 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.
|
||||
//
|
||||
#ifndef _BENCH_FIXED_SIZE_HH_
|
||||
#define _BENCH_FIXED_SIZE_HH_
|
||||
|
||||
#include "utilities.h"
|
||||
#include "function_time.hh"
|
||||
|
||||
template <class Action>
|
||||
double bench_fixed_size(int size, unsigned long long & nb_calc,unsigned long long & nb_init)
|
||||
{
|
||||
|
||||
Action action(size);
|
||||
|
||||
double time_baseline=time_init(nb_init,action);
|
||||
|
||||
while (time_baseline < MIN_TIME) {
|
||||
|
||||
//INFOS("nb_init="<<nb_init);
|
||||
//INFOS("time_baseline="<<time_baseline);
|
||||
nb_init*=2;
|
||||
time_baseline=time_init(nb_init,action);
|
||||
}
|
||||
|
||||
time_baseline=time_baseline/(double(nb_init));
|
||||
|
||||
double time_action=time_calculate(nb_calc,action);
|
||||
|
||||
while (time_action < MIN_TIME) {
|
||||
|
||||
nb_calc*=2;
|
||||
time_action=time_calculate(nb_calc,action);
|
||||
}
|
||||
|
||||
INFOS("nb_init="<<nb_init);
|
||||
INFOS("nb_calc="<<nb_calc);
|
||||
|
||||
|
||||
time_action=time_action/(double(nb_calc));
|
||||
|
||||
action.check_result();
|
||||
|
||||
time_action=time_action-time_baseline;
|
||||
|
||||
return action.nb_op_base()/(time_action*1000000.0);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
//=====================================================
|
||||
// File : static_size_generator.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:36 CET 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.
|
||||
//
|
||||
#ifndef _STATIC_SIZE_GENERATOR_HH
|
||||
#define _STATIC_SIZE_GENERATOR_HH
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
//recursive generation of statically defined matrix and vector sizes
|
||||
|
||||
template <int SIZE,template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
|
||||
struct static_size_generator{
|
||||
static void go(vector<double> & tab_sizes, vector<double> & tab_mflops)
|
||||
{
|
||||
tab_sizes.push_back(SIZE);
|
||||
std::cout << tab_sizes.back() << " \t" << std::flush;
|
||||
Perf_Analyzer<Action<Interface<REAL_TYPE,SIZE> > > perf_action;
|
||||
tab_mflops.push_back(perf_action.eval_mflops(SIZE));
|
||||
std::cout << tab_mflops.back() << " MFlops" << std::endl;
|
||||
static_size_generator<SIZE-1,Perf_Analyzer,Action,Interface>::go(tab_sizes,tab_mflops);
|
||||
};
|
||||
};
|
||||
|
||||
//recursion end
|
||||
|
||||
template <template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
|
||||
struct static_size_generator<1,Perf_Analyzer,Action,Interface>{
|
||||
static void go(vector<double> & tab_sizes, vector<double> & tab_mflops)
|
||||
{
|
||||
tab_sizes.push_back(1);
|
||||
Perf_Analyzer<Action<Interface<REAL_TYPE,1> > > perf_action;
|
||||
tab_mflops.push_back(perf_action.eval_mflops(1));
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//=====================================================
|
||||
// File : STL_perf_analyzer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 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.
|
||||
//
|
||||
#ifndef _STL_PERF_ANALYSER_HH
|
||||
#define _STL_PERF_ANALYSER_HH
|
||||
|
||||
#include "STL_timer.hh"
|
||||
#include "bench_parameter.hh"
|
||||
|
||||
template<class ACTION>
|
||||
class STL_Perf_Analyzer{
|
||||
public:
|
||||
STL_Perf_Analyzer(unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
|
||||
{
|
||||
MESSAGE("STL_Perf_Analyzer Ctor");
|
||||
};
|
||||
STL_Perf_Analyzer( const STL_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~STL_Perf_Analyzer( void ){
|
||||
MESSAGE("STL_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
|
||||
inline double eval_mflops(int size)
|
||||
{
|
||||
|
||||
ACTION action(size);
|
||||
|
||||
_chronos.start_baseline(_nb_sample);
|
||||
|
||||
do {
|
||||
|
||||
action.initialize();
|
||||
} while (_chronos.check());
|
||||
|
||||
double baseline_time=_chronos.get_time();
|
||||
|
||||
_chronos.start(_nb_sample);
|
||||
do {
|
||||
action.initialize();
|
||||
action.calculate();
|
||||
} while (_chronos.check());
|
||||
|
||||
double calculate_time=_chronos.get_time();
|
||||
|
||||
double corrected_time=calculate_time-baseline_time;
|
||||
|
||||
// cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;
|
||||
|
||||
return action.nb_op_base()/(corrected_time*1000000.0);
|
||||
//return action.nb_op_base()/(calculate_time*1000000.0);
|
||||
|
||||
}
|
||||
private:
|
||||
|
||||
STL_Timer _chronos;
|
||||
unsigned long long _nb_sample;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,78 @@
|
||||
//=====================================================
|
||||
// File : STL_Timer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 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.
|
||||
//
|
||||
// STL Timer Class. Adapted (L.P.) from the timer class by Musser et Al
|
||||
// described int the Book : STL Tutorial and reference guide.
|
||||
// Define a timer class for analyzing algorithm performance.
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
using namespace std;
|
||||
|
||||
class STL_Timer {
|
||||
public:
|
||||
STL_Timer(){ baseline = false; }; // Default constructor
|
||||
// Start a series of r trials:
|
||||
void start(unsigned int r){
|
||||
reps = r;
|
||||
count = 0;
|
||||
iterations.clear();
|
||||
iterations.reserve(reps);
|
||||
initial = time(0);
|
||||
};
|
||||
// Start a series of r trials to determine baseline time:
|
||||
void start_baseline(unsigned int r)
|
||||
{
|
||||
baseline = true;
|
||||
start(r);
|
||||
}
|
||||
// Returns true if the trials have been completed, else false
|
||||
bool check()
|
||||
{
|
||||
++count;
|
||||
final = time(0);
|
||||
if (initial < final) {
|
||||
iterations.push_back(count);
|
||||
initial = final;
|
||||
count = 0;
|
||||
}
|
||||
return (iterations.size() < reps);
|
||||
};
|
||||
// Returns the results for external use
|
||||
double get_time( void )
|
||||
{
|
||||
sort(iterations.begin(), iterations.end());
|
||||
return 1.0/iterations[reps/2];
|
||||
};
|
||||
private:
|
||||
unsigned int reps; // Number of trials
|
||||
// For storing loop iterations of a trial
|
||||
vector<long> iterations;
|
||||
// For saving initial and final times of a trial
|
||||
time_t initial, final;
|
||||
// For counting loop iterations of a trial
|
||||
unsigned long count;
|
||||
// true if this is a baseline computation, false otherwise
|
||||
bool baseline;
|
||||
// For recording the baseline time
|
||||
double baseline_time;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
//=====================================================
|
||||
// File : mixed_perf_analyzer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:36 CET 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.
|
||||
//
|
||||
#ifndef _MIXED_PERF_ANALYSER_HH
|
||||
#define _MIXED_PERF_ANALYSER_HH
|
||||
|
||||
#include "x86_perf_analyzer.hh"
|
||||
#include "portable_perf_analyzer.hh"
|
||||
|
||||
// choose portable perf analyzer for long calculations and x86 analyser for short ones
|
||||
|
||||
|
||||
template<class Action>
|
||||
class Mixed_Perf_Analyzer{
|
||||
|
||||
public:
|
||||
Mixed_Perf_Analyzer( void ):_x86pa(),_ppa(),_use_ppa(true)
|
||||
{
|
||||
MESSAGE("Mixed_Perf_Analyzer Ctor");
|
||||
};
|
||||
Mixed_Perf_Analyzer( const Mixed_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~Mixed_Perf_Analyzer( void ){
|
||||
MESSAGE("Mixed_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
|
||||
inline double eval_mflops(int size)
|
||||
{
|
||||
|
||||
double result=0.0;
|
||||
if (_use_ppa){
|
||||
result=_ppa.eval_mflops(size);
|
||||
if (_ppa.get_nb_calc()>DEFAULT_NB_SAMPLE){_use_ppa=false;}
|
||||
}
|
||||
else{
|
||||
result=_x86pa.eval_mflops(size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Portable_Perf_Analyzer<Action> _ppa;
|
||||
X86_Perf_Analyzer<Action> _x86pa;
|
||||
bool _use_ppa;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//=====================================================
|
||||
// File : portable_perf_analyzer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 2002
|
||||
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
|
||||
//=====================================================
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
#ifndef _PORTABLE_PERF_ANALYZER_HH
|
||||
#define _PORTABLE_PERF_ANALYZER_HH
|
||||
|
||||
#include "utilities.h"
|
||||
#include "timers/portable_timer.hh"
|
||||
|
||||
template <class Action>
|
||||
class Portable_Perf_Analyzer{
|
||||
public:
|
||||
Portable_Perf_Analyzer( ):_nb_calc(0), m_time_action(0), _chronos(){
|
||||
MESSAGE("Portable_Perf_Analyzer Ctor");
|
||||
};
|
||||
Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~Portable_Perf_Analyzer(){
|
||||
MESSAGE("Portable_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
BTL_DONT_INLINE double eval_mflops(int size)
|
||||
{
|
||||
Action action(size);
|
||||
|
||||
// action.initialize();
|
||||
// time_action = time_calculate(action);
|
||||
while (m_time_action < MIN_TIME)
|
||||
{
|
||||
if(_nb_calc==0) _nb_calc = 1;
|
||||
else _nb_calc *= 2;
|
||||
action.initialize();
|
||||
m_time_action = time_calculate(action);
|
||||
}
|
||||
|
||||
// optimize
|
||||
for (int i=1; i<BtlConfig::Instance.tries; ++i)
|
||||
{
|
||||
Action _action(size);
|
||||
std::cout << " " << _action.nb_op_base()*_nb_calc/(m_time_action*1e6) << " ";
|
||||
_action.initialize();
|
||||
m_time_action = std::min(m_time_action, time_calculate(_action));
|
||||
}
|
||||
|
||||
double time_action = m_time_action / (double(_nb_calc));
|
||||
|
||||
// check
|
||||
if (BtlConfig::Instance.checkResults && size<128)
|
||||
{
|
||||
action.initialize();
|
||||
action.calculate();
|
||||
action.check_result();
|
||||
}
|
||||
return action.nb_op_base()/(time_action*1e6);
|
||||
}
|
||||
|
||||
BTL_DONT_INLINE double time_calculate(Action & action)
|
||||
{
|
||||
// time measurement
|
||||
action.calculate();
|
||||
_chronos.start();
|
||||
for (unsigned int ii=0;ii<_nb_calc;ii++)
|
||||
{
|
||||
action.calculate();
|
||||
}
|
||||
_chronos.stop();
|
||||
return _chronos.user_time();
|
||||
}
|
||||
|
||||
unsigned long long get_nb_calc()
|
||||
{
|
||||
return _nb_calc;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
unsigned long long _nb_calc;
|
||||
double m_time_action;
|
||||
Portable_Timer _chronos;
|
||||
|
||||
};
|
||||
|
||||
#endif //_PORTABLE_PERF_ANALYZER_HH
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
//=====================================================
|
||||
// File : portable_perf_analyzer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 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.
|
||||
//
|
||||
#ifndef _PORTABLE_PERF_ANALYZER_HH
|
||||
#define _PORTABLE_PERF_ANALYZER_HH
|
||||
|
||||
#include "utilities.h"
|
||||
#include "timers/portable_timer.hh"
|
||||
|
||||
template <class Action>
|
||||
class Portable_Perf_Analyzer{
|
||||
public:
|
||||
Portable_Perf_Analyzer( void ):_nb_calc(1),_nb_init(1),_chronos(){
|
||||
MESSAGE("Portable_Perf_Analyzer Ctor");
|
||||
};
|
||||
Portable_Perf_Analyzer( const Portable_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~Portable_Perf_Analyzer( void ){
|
||||
MESSAGE("Portable_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline double eval_mflops(int size)
|
||||
{
|
||||
|
||||
Action action(size);
|
||||
|
||||
// double time_baseline = time_init(action);
|
||||
// while (time_baseline < MIN_TIME_INIT)
|
||||
// {
|
||||
// _nb_init *= 2;
|
||||
// time_baseline = time_init(action);
|
||||
// }
|
||||
//
|
||||
// // optimize
|
||||
// for (int i=1; i<NB_TRIES; ++i)
|
||||
// time_baseline = std::min(time_baseline, time_init(action));
|
||||
//
|
||||
// time_baseline = time_baseline/(double(_nb_init));
|
||||
|
||||
double time_action = time_calculate(action);
|
||||
while (time_action < MIN_TIME)
|
||||
{
|
||||
_nb_calc *= 2;
|
||||
time_action = time_calculate(action);
|
||||
}
|
||||
|
||||
// optimize
|
||||
for (int i=1; i<NB_TRIES; ++i)
|
||||
time_action = std::min(time_action, time_calculate(action));
|
||||
|
||||
// INFOS("size="<<size);
|
||||
// INFOS("_nb_init="<<_nb_init);
|
||||
// INFOS("_nb_calc="<<_nb_calc);
|
||||
|
||||
time_action = time_action / (double(_nb_calc));
|
||||
|
||||
action.check_result();
|
||||
|
||||
|
||||
double time_baseline = time_init(action);
|
||||
for (int i=1; i<NB_TRIES; ++i)
|
||||
time_baseline = std::min(time_baseline, time_init(action));
|
||||
time_baseline = time_baseline/(double(_nb_init));
|
||||
|
||||
|
||||
|
||||
// INFOS("time_baseline="<<time_baseline);
|
||||
// INFOS("time_action="<<time_action);
|
||||
|
||||
time_action = time_action - time_baseline;
|
||||
|
||||
// INFOS("time_corrected="<<time_action);
|
||||
|
||||
return action.nb_op_base()/(time_action*1000000.0);
|
||||
}
|
||||
|
||||
inline double time_init(Action & action)
|
||||
{
|
||||
// time measurement
|
||||
_chronos.start();
|
||||
for (int ii=0; ii<_nb_init; ii++)
|
||||
action.initialize();
|
||||
_chronos.stop();
|
||||
return _chronos.user_time();
|
||||
}
|
||||
|
||||
|
||||
inline double time_calculate(Action & action)
|
||||
{
|
||||
// time measurement
|
||||
_chronos.start();
|
||||
for (int ii=0;ii<_nb_calc;ii++)
|
||||
{
|
||||
action.initialize();
|
||||
action.calculate();
|
||||
}
|
||||
_chronos.stop();
|
||||
return _chronos.user_time();
|
||||
}
|
||||
|
||||
unsigned long long get_nb_calc( void )
|
||||
{
|
||||
return _nb_calc;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
unsigned long long _nb_calc;
|
||||
unsigned long long _nb_init;
|
||||
Portable_Timer _chronos;
|
||||
|
||||
};
|
||||
|
||||
#endif //_PORTABLE_PERF_ANALYZER_HH
|
||||
187
cs440-acg/ext/eigen/bench/btl/generic_bench/timers/portable_timer.hh
Executable file
187
cs440-acg/ext/eigen/bench/btl/generic_bench/timers/portable_timer.hh
Executable file
@@ -0,0 +1,187 @@
|
||||
//=====================================================
|
||||
// File : portable_timer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)> from boost lib
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:17 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.
|
||||
//
|
||||
// simple_time extracted from the boost library
|
||||
//
|
||||
#ifndef _PORTABLE_TIMER_HH
|
||||
#define _PORTABLE_TIMER_HH
|
||||
|
||||
#include <ctime>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#define USEC_IN_SEC 1000000
|
||||
|
||||
|
||||
// timer -------------------------------------------------------------------//
|
||||
|
||||
// A timer object measures CPU time.
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
/*#ifndef hr_timer
|
||||
#include "hr_time.h"
|
||||
#define hr_timer
|
||||
#endif*/
|
||||
|
||||
class Portable_Timer
|
||||
{
|
||||
public:
|
||||
|
||||
typedef struct {
|
||||
LARGE_INTEGER start;
|
||||
LARGE_INTEGER stop;
|
||||
} stopWatch;
|
||||
|
||||
|
||||
Portable_Timer()
|
||||
{
|
||||
startVal.QuadPart = 0;
|
||||
stopVal.QuadPart = 0;
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
}
|
||||
|
||||
void start() { QueryPerformanceCounter(&startVal); }
|
||||
|
||||
void stop() { QueryPerformanceCounter(&stopVal); }
|
||||
|
||||
double elapsed() {
|
||||
LARGE_INTEGER time;
|
||||
time.QuadPart = stopVal.QuadPart - startVal.QuadPart;
|
||||
return LIToSecs(time);
|
||||
}
|
||||
|
||||
double user_time() { return elapsed(); }
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double LIToSecs(LARGE_INTEGER& L) {
|
||||
return ((double)L.QuadPart /(double)frequency.QuadPart) ;
|
||||
}
|
||||
|
||||
LARGE_INTEGER startVal;
|
||||
LARGE_INTEGER stopVal;
|
||||
LARGE_INTEGER frequency;
|
||||
|
||||
|
||||
}; // Portable_Timer
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <mach/mach_time.h>
|
||||
|
||||
|
||||
class Portable_Timer
|
||||
{
|
||||
public:
|
||||
|
||||
Portable_Timer()
|
||||
{
|
||||
}
|
||||
|
||||
void start()
|
||||
{
|
||||
m_start_time = double(mach_absolute_time())*1e-9;;
|
||||
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
m_stop_time = double(mach_absolute_time())*1e-9;;
|
||||
|
||||
}
|
||||
|
||||
double elapsed()
|
||||
{
|
||||
return user_time();
|
||||
}
|
||||
|
||||
double user_time()
|
||||
{
|
||||
return m_stop_time - m_start_time;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double m_stop_time, m_start_time;
|
||||
|
||||
}; // Portable_Timer (Apple)
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/times.h>
|
||||
|
||||
class Portable_Timer
|
||||
{
|
||||
public:
|
||||
|
||||
Portable_Timer()
|
||||
{
|
||||
m_clkid = BtlConfig::Instance.realclock ? CLOCK_REALTIME : CLOCK_PROCESS_CPUTIME_ID;
|
||||
}
|
||||
|
||||
Portable_Timer(int clkid) : m_clkid(clkid)
|
||||
{}
|
||||
|
||||
void start()
|
||||
{
|
||||
timespec ts;
|
||||
clock_gettime(m_clkid, &ts);
|
||||
m_start_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
||||
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
timespec ts;
|
||||
clock_gettime(m_clkid, &ts);
|
||||
m_stop_time = double(ts.tv_sec) + 1e-9 * double(ts.tv_nsec);
|
||||
|
||||
}
|
||||
|
||||
double elapsed()
|
||||
{
|
||||
return user_time();
|
||||
}
|
||||
|
||||
double user_time()
|
||||
{
|
||||
return m_stop_time - m_start_time;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int m_clkid;
|
||||
double m_stop_time, m_start_time;
|
||||
|
||||
}; // Portable_Timer (Linux)
|
||||
|
||||
#endif
|
||||
|
||||
#endif // PORTABLE_TIMER_HPP
|
||||
@@ -0,0 +1,108 @@
|
||||
//=====================================================
|
||||
// File : x86_perf_analyzer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 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.
|
||||
//
|
||||
#ifndef _X86_PERF_ANALYSER_HH
|
||||
#define _X86_PERF_ANALYSER_HH
|
||||
|
||||
#include "x86_timer.hh"
|
||||
#include "bench_parameter.hh"
|
||||
|
||||
template<class ACTION>
|
||||
class X86_Perf_Analyzer{
|
||||
public:
|
||||
X86_Perf_Analyzer( unsigned long long nb_sample=DEFAULT_NB_SAMPLE):_nb_sample(nb_sample),_chronos()
|
||||
{
|
||||
MESSAGE("X86_Perf_Analyzer Ctor");
|
||||
_chronos.find_frequency();
|
||||
};
|
||||
X86_Perf_Analyzer( const X86_Perf_Analyzer & ){
|
||||
INFOS("Copy Ctor not implemented");
|
||||
exit(0);
|
||||
};
|
||||
~X86_Perf_Analyzer( void ){
|
||||
MESSAGE("X86_Perf_Analyzer Dtor");
|
||||
};
|
||||
|
||||
|
||||
inline double eval_mflops(int size)
|
||||
{
|
||||
|
||||
ACTION action(size);
|
||||
|
||||
int nb_loop=5;
|
||||
double calculate_time=0.0;
|
||||
double baseline_time=0.0;
|
||||
|
||||
for (int j=0 ; j < nb_loop ; j++){
|
||||
|
||||
_chronos.clear();
|
||||
|
||||
for(int i=0 ; i < _nb_sample ; i++)
|
||||
{
|
||||
_chronos.start();
|
||||
action.initialize();
|
||||
action.calculate();
|
||||
_chronos.stop();
|
||||
_chronos.add_get_click();
|
||||
}
|
||||
|
||||
calculate_time += double(_chronos.get_shortest_clicks())/_chronos.frequency();
|
||||
|
||||
if (j==0) action.check_result();
|
||||
|
||||
_chronos.clear();
|
||||
|
||||
for(int i=0 ; i < _nb_sample ; i++)
|
||||
{
|
||||
_chronos.start();
|
||||
action.initialize();
|
||||
_chronos.stop();
|
||||
_chronos.add_get_click();
|
||||
|
||||
}
|
||||
|
||||
baseline_time+=double(_chronos.get_shortest_clicks())/_chronos.frequency();
|
||||
|
||||
}
|
||||
|
||||
double corrected_time = (calculate_time-baseline_time)/double(nb_loop);
|
||||
|
||||
|
||||
// INFOS("_nb_sample="<<_nb_sample);
|
||||
// INFOS("baseline_time="<<baseline_time);
|
||||
// INFOS("calculate_time="<<calculate_time);
|
||||
// INFOS("corrected_time="<<corrected_time);
|
||||
|
||||
// cout << size <<" "<<baseline_time<<" "<<calculate_time<<" "<<corrected_time<<" "<<action.nb_op_base() << endl;
|
||||
|
||||
return action.nb_op_base()/(corrected_time*1000000.0);
|
||||
//return action.nb_op_base()/(calculate_time*1000000.0);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
X86_Timer _chronos;
|
||||
unsigned long long _nb_sample;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
246
cs440-acg/ext/eigen/bench/btl/generic_bench/timers/x86_timer.hh
Normal file
246
cs440-acg/ext/eigen/bench/btl/generic_bench/timers/x86_timer.hh
Normal file
@@ -0,0 +1,246 @@
|
||||
//=====================================================
|
||||
// File : x86_timer.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:35 CET 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.
|
||||
//
|
||||
#ifndef _X86_TIMER_HH
|
||||
#define _X86_TIMER_HH
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/times.h>
|
||||
//#include "system_time.h"
|
||||
#define u32 unsigned int
|
||||
#include <asm/msr.h>
|
||||
#include "utilities.h"
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
// frequence de la becanne en Hz
|
||||
//#define FREQUENCY 648000000
|
||||
//#define FREQUENCY 1400000000
|
||||
#define FREQUENCY 1695000000
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class X86_Timer {
|
||||
|
||||
public :
|
||||
|
||||
X86_Timer( void ):_frequency(FREQUENCY),_nb_sample(0)
|
||||
{
|
||||
MESSAGE("X86_Timer Default Ctor");
|
||||
}
|
||||
|
||||
inline void start( void ){
|
||||
|
||||
rdtsc(_click_start.n32[0],_click_start.n32[1]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline void stop( void ){
|
||||
|
||||
rdtsc(_click_stop.n32[0],_click_stop.n32[1]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline double frequency( void ){
|
||||
return _frequency;
|
||||
}
|
||||
|
||||
double get_elapsed_time_in_second( void ){
|
||||
|
||||
return (_click_stop.n64-_click_start.n64)/double(FREQUENCY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
unsigned long long get_click( void ){
|
||||
|
||||
return (_click_stop.n64-_click_start.n64);
|
||||
|
||||
}
|
||||
|
||||
inline void find_frequency( void ){
|
||||
|
||||
time_t initial, final;
|
||||
int dummy=2;
|
||||
|
||||
initial = time(0);
|
||||
start();
|
||||
do {
|
||||
dummy+=2;
|
||||
}
|
||||
while(time(0)==initial);
|
||||
// On est au debut d'un cycle d'une seconde !!!
|
||||
initial = time(0);
|
||||
start();
|
||||
do {
|
||||
dummy+=2;
|
||||
}
|
||||
while(time(0)==initial);
|
||||
final=time(0);
|
||||
stop();
|
||||
// INFOS("fine grained time : "<< get_elapsed_time_in_second());
|
||||
// INFOS("coarse grained time : "<< final-initial);
|
||||
_frequency=_frequency*get_elapsed_time_in_second()/double(final-initial);
|
||||
/// INFOS("CPU frequency : "<< _frequency);
|
||||
|
||||
}
|
||||
|
||||
void add_get_click( void ){
|
||||
|
||||
_nb_sample++;
|
||||
_counted_clicks[get_click()]++;
|
||||
fill_history_clicks();
|
||||
|
||||
}
|
||||
|
||||
void dump_statistics(string filemane){
|
||||
|
||||
ofstream outfile (filemane.c_str(),ios::out) ;
|
||||
|
||||
std::map<unsigned long long , unsigned long long>::iterator itr;
|
||||
for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
|
||||
{
|
||||
outfile << (*itr).first << " " << (*itr).second << endl ;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
|
||||
}
|
||||
|
||||
void dump_history(string filemane){
|
||||
|
||||
ofstream outfile (filemane.c_str(),ios::out) ;
|
||||
|
||||
|
||||
|
||||
for(int i=0 ; i<_history_mean_clicks.size() ; i++)
|
||||
{
|
||||
outfile << i << " "
|
||||
<< _history_mean_clicks[i] << " "
|
||||
<< _history_shortest_clicks[i] << " "
|
||||
<< _history_most_occured_clicks[i] << endl ;
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
double get_mean_clicks( void ){
|
||||
|
||||
std::map<unsigned long long,unsigned long long>::iterator itr;
|
||||
|
||||
unsigned long long mean_clicks=0;
|
||||
|
||||
for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
|
||||
{
|
||||
|
||||
mean_clicks+=(*itr).second*(*itr).first;
|
||||
}
|
||||
|
||||
return mean_clicks/double(_nb_sample);
|
||||
|
||||
}
|
||||
|
||||
double get_shortest_clicks( void ){
|
||||
|
||||
return double((*_counted_clicks.begin()).first);
|
||||
|
||||
}
|
||||
|
||||
void fill_history_clicks( void ){
|
||||
|
||||
_history_mean_clicks.push_back(get_mean_clicks());
|
||||
_history_shortest_clicks.push_back(get_shortest_clicks());
|
||||
_history_most_occured_clicks.push_back(get_most_occured_clicks());
|
||||
|
||||
}
|
||||
|
||||
|
||||
double get_most_occured_clicks( void ){
|
||||
|
||||
unsigned long long moc=0;
|
||||
unsigned long long max_occurence=0;
|
||||
|
||||
std::map<unsigned long long,unsigned long long>::iterator itr;
|
||||
|
||||
for(itr=_counted_clicks.begin() ; itr!=_counted_clicks.end() ; itr++)
|
||||
{
|
||||
|
||||
if (max_occurence<=(*itr).second){
|
||||
max_occurence=(*itr).second;
|
||||
moc=(*itr).first;
|
||||
}
|
||||
}
|
||||
|
||||
return double(moc);
|
||||
|
||||
}
|
||||
|
||||
void clear( void )
|
||||
{
|
||||
_counted_clicks.clear();
|
||||
|
||||
_history_mean_clicks.clear();
|
||||
_history_shortest_clicks.clear();
|
||||
_history_most_occured_clicks.clear();
|
||||
|
||||
_nb_sample=0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private :
|
||||
|
||||
union
|
||||
{
|
||||
unsigned long int n32[2] ;
|
||||
unsigned long long n64 ;
|
||||
} _click_start;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned long int n32[2] ;
|
||||
unsigned long long n64 ;
|
||||
} _click_stop;
|
||||
|
||||
double _frequency ;
|
||||
|
||||
map<unsigned long long,unsigned long long> _counted_clicks;
|
||||
|
||||
vector<double> _history_mean_clicks;
|
||||
vector<double> _history_shortest_clicks;
|
||||
vector<double> _history_most_occured_clicks;
|
||||
|
||||
unsigned long long _nb_sample;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
//=====================================================
|
||||
// File : size_lin_log.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, mar d<>c 3 18:59:37 CET 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.
|
||||
//
|
||||
#ifndef SIZE_LIN_LOG
|
||||
#define SIZE_LIN_LOG
|
||||
|
||||
#include "size_log.hh"
|
||||
|
||||
template<class Vector>
|
||||
void size_lin_log(const int nb_point, const int /*size_min*/, const int size_max, Vector & X)
|
||||
{
|
||||
int ten=10;
|
||||
int nine=9;
|
||||
|
||||
X.resize(nb_point);
|
||||
|
||||
if (nb_point>ten){
|
||||
|
||||
for (int i=0;i<nine;i++){
|
||||
|
||||
X[i]=i+1;
|
||||
|
||||
}
|
||||
|
||||
Vector log_size;
|
||||
size_log(nb_point-nine,ten,size_max,log_size);
|
||||
|
||||
for (int i=0;i<nb_point-nine;i++){
|
||||
|
||||
X[i+nine]=log_size[i];
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
for (int i=0;i<nb_point;i++){
|
||||
|
||||
X[i]=i+1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// for (int i=0;i<nb_point;i++){
|
||||
|
||||
// INFOS("computed sizes : X["<<i<<"]="<<X[i]);
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//=====================================================
|
||||
// File : size_log.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:17 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.
|
||||
//
|
||||
#ifndef SIZE_LOG
|
||||
#define SIZE_LOG
|
||||
|
||||
#include "math.h"
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for seting element
|
||||
// the vector element are int compatible.
|
||||
template<class Vector>
|
||||
void size_log(const int nb_point, const int size_min, const int size_max, Vector & X)
|
||||
{
|
||||
X.resize(nb_point);
|
||||
|
||||
float ls_min=log(float(size_min));
|
||||
float ls_max=log(float(size_max));
|
||||
|
||||
float ls=0.0;
|
||||
|
||||
float delta_ls=(ls_max-ls_min)/(float(nb_point-1));
|
||||
|
||||
int size=0;
|
||||
|
||||
for (int i=0;i<nb_point;i++){
|
||||
|
||||
ls = ls_min + float(i)*delta_ls ;
|
||||
|
||||
size=int(exp(ls));
|
||||
|
||||
X[i]=size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,90 @@
|
||||
//=============================================================================
|
||||
// File : utilities.h
|
||||
// Created : mar jun 19 13:18:14 CEST 2001
|
||||
// Author : Antoine YESSAYAN, Paul RASCLE, EDF
|
||||
// Project : SALOME
|
||||
// Copyright : EDF 2001
|
||||
// $Header$
|
||||
//=============================================================================
|
||||
|
||||
/* --- Definition macros file to print information if _DEBUG_ is defined --- */
|
||||
|
||||
# ifndef UTILITIES_H
|
||||
# define UTILITIES_H
|
||||
|
||||
# include <stdlib.h>
|
||||
//# include <iostream> ok for gcc3.01
|
||||
# include <iostream>
|
||||
|
||||
/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */
|
||||
|
||||
# define HEREWEARE cout<<flush ; cerr << __FILE__ << " [" << __LINE__ << "] : " << flush ;
|
||||
# define INFOS(chain) {HEREWEARE ; cerr << chain << endl ;}
|
||||
# define PYSCRIPT(chain) {cout<<flush ; cerr << "---PYSCRIPT--- " << chain << endl ;}
|
||||
|
||||
/* --- To print date and time of compilation of current source on stdout --- */
|
||||
|
||||
# if defined ( __GNUC__ )
|
||||
# define COMPILER "g++" ;
|
||||
# elif defined ( __sun )
|
||||
# define COMPILER "CC" ;
|
||||
# elif defined ( __KCC )
|
||||
# define COMPILER "KCC" ;
|
||||
# elif defined ( __PGI )
|
||||
# define COMPILER "pgCC" ;
|
||||
# else
|
||||
# define COMPILER "undefined" ;
|
||||
# endif
|
||||
|
||||
# ifdef INFOS_COMPILATION
|
||||
# error INFOS_COMPILATION already defined
|
||||
# endif
|
||||
# define INFOS_COMPILATION {\
|
||||
cerr << flush;\
|
||||
cout << __FILE__ ;\
|
||||
cout << " [" << __LINE__ << "] : " ;\
|
||||
cout << "COMPILED with " << COMPILER ;\
|
||||
cout << ", " << __DATE__ ; \
|
||||
cout << " at " << __TIME__ << endl ;\
|
||||
cout << "\n\n" ;\
|
||||
cout << flush ;\
|
||||
}
|
||||
|
||||
# ifdef _DEBUG_
|
||||
|
||||
/* --- the following MACROS are useful at debug time --- */
|
||||
|
||||
# define HERE cout<<flush ; cerr << "- Trace " << __FILE__ << " [" << __LINE__ << "] : " << flush ;
|
||||
# define SCRUTE(var) HERE ; cerr << #var << "=" << var << endl ;
|
||||
# define MESSAGE(chain) {HERE ; cerr << chain << endl ;}
|
||||
# define INTERRUPTION(code) HERE ; cerr << "INTERRUPTION return code= " << code << endl ; exit(code) ;
|
||||
|
||||
# ifndef ASSERT
|
||||
# define ASSERT(condition) if (!(condition)){ HERE ; cerr << "CONDITION " << #condition << " NOT VERIFIED"<< endl ; INTERRUPTION(1) ;}
|
||||
# endif /* ASSERT */
|
||||
|
||||
#define REPERE cout<<flush ; cerr << " --------------" << endl << flush ;
|
||||
#define BEGIN_OF(chain) {REPERE ; HERE ; cerr << "Begin of: " << chain << endl ; REPERE ; }
|
||||
#define END_OF(chain) {REPERE ; HERE ; cerr << "Normal end of: " << chain << endl ; REPERE ; }
|
||||
|
||||
|
||||
|
||||
# else /* ifdef _DEBUG_*/
|
||||
|
||||
# define HERE
|
||||
# define SCRUTE(var)
|
||||
# define MESSAGE(chain)
|
||||
# define INTERRUPTION(code)
|
||||
|
||||
# ifndef ASSERT
|
||||
# define ASSERT(condition)
|
||||
# endif /* ASSERT */
|
||||
|
||||
#define REPERE
|
||||
#define BEGIN_OF(chain)
|
||||
#define END_OF(chain)
|
||||
|
||||
|
||||
# endif /* ifdef _DEBUG_*/
|
||||
|
||||
# endif /* ifndef UTILITIES_H */
|
||||
75
cs440-acg/ext/eigen/bench/btl/generic_bench/utils/xy_file.hh
Normal file
75
cs440-acg/ext/eigen/bench/btl/generic_bench/utils/xy_file.hh
Normal file
@@ -0,0 +1,75 @@
|
||||
//=====================================================
|
||||
// File : dump_file_x_y.hh
|
||||
// Author : L. Plagne <laurent.plagne@edf.fr)>
|
||||
// Copyright (C) EDF R&D, lun sep 30 14:23:20 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.
|
||||
//
|
||||
#ifndef XY_FILE_HH
|
||||
#define XY_FILE_HH
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
bool read_xy_file(const std::string & filename, std::vector<int> & tab_sizes,
|
||||
std::vector<double> & tab_mflops, bool quiet = false)
|
||||
{
|
||||
|
||||
std::ifstream input_file (filename.c_str(),std::ios::in);
|
||||
|
||||
if (!input_file){
|
||||
if (!quiet) {
|
||||
INFOS("!!! Error opening "<<filename);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
SCRUTE(nb_point);
|
||||
|
||||
input_file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
// The Vector class must satisfy the following part of STL vector concept :
|
||||
// resize() method
|
||||
// [] operator for seting element
|
||||
// the vector element must have the << operator define
|
||||
|
||||
using namespace std;
|
||||
|
||||
template<class Vector_A, class Vector_B>
|
||||
void dump_xy_file(const Vector_A & X, const Vector_B & Y, const std::string & filename){
|
||||
|
||||
ofstream outfile (filename.c_str(),ios::out) ;
|
||||
int size=X.size();
|
||||
|
||||
for (int i=0;i<size;i++)
|
||||
outfile << X[i] << " " << Y[i] << endl;
|
||||
|
||||
outfile.close();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user