in BTL: a specific bench/action can be selected at runtime, e.g.:

BTL_CONFIG="-a ata" ctest -V -R eigen
  run the all benchmarks having "ata" in their name for all
  libraries matching the regexp "eigen"
This commit is contained in:
Gael Guennebaud
2008-07-09 22:35:11 +00:00
parent c9b046d5d5
commit 7b4c6b8862
23 changed files with 415 additions and 122 deletions

View File

@@ -11,8 +11,10 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON)
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "-g0 -O3 -DNDEBUG")
SET(CMAKE_Fortran_FLAGS "-g0 -O3 -DNDEBUG")
IF(NOT BTL_NOVEC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -msse2")
ELSE(NOT BTL_NOVEC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_DONT_VECTORIZE")
ENDIF(NOT BTL_NOVEC)
@@ -36,6 +38,7 @@ ENABLE_TESTING()
find_package(Eigen2)
if (EIGEN2_FOUND)
macro_optional_add_subdirectory(libs/eigen2 ON)
macro_optional_add_subdirectory(libs/tiny_eigen2 OFF)
endif (EIGEN2_FOUND)
# GMM++
@@ -55,9 +58,15 @@ endif (Boost_FOUND)
find_package(Blitz)
if (BLITZ_FOUND)
macro_optional_add_subdirectory(libs/blitz ON)
macro_optional_add_subdirectory(libs/tiny_blitz ON)
macro_optional_add_subdirectory(libs/tiny_blitz OFF)
endif (BLITZ_FOUND)
# tvmet
find_package(Tvmet)
if (TVMET_FOUND)
macro_optional_add_subdirectory(libs/tvmet OFF)
endif (TVMET_FOUND)
# cblas
find_package(CBLAS)
if (CBLAS_FOUND)

View File

@@ -1,7 +1,7 @@
ADD_CUSTOM_TARGET(copy_scripts)
SET(script_files go_mean aat.hh ata.hh axpy.hh order_lib mk_mean_script.sh mk_new_gnuplot.sh mk_gnuplot_script.sh matrix_matrix.hh matrix_vector.hh)
SET(script_files go_mean aat.hh ata.hh axpy.hh order_lib mk_mean_script.sh mk_new_gnuplot.sh mk_gnuplot_script.sh matrix_matrix.hh matrix_vector.hh atv.hh)
FOREACH(script_file ${script_files})
ADD_CUSTOM_COMMAND(

108
bench/btl/data/atv.hh Normal file
View File

@@ -0,0 +1,108 @@
#!/usr/bin/gnuplot -persist
#
#
# G N U P L O T
# Linux version 3.7
# patchlevel 0
# last modified Thu Jan 14 19:34:53 BST 1999
#
# Copyright(C) 1986 - 1993, 1998, 1999
# Thomas Williams, Colin Kelley and many others
#
# Type `help` to access the on-line reference manual
# The gnuplot FAQ is available from
# <http://www.uni-karlsruhe.de/~ig25/gnuplot-faq/>
#
# Send comments and requests for help to <info-gnuplot@dartmouth.edu>
# Send bugs, suggestions and mods to <bug-gnuplot@dartmouth.edu>
#
# set terminal postscript landscape noenhanced monochrome dashed defaultplex "Helvetica" 14
# set output 'bench_gcc.ps'
set noclip points
set clip one
set noclip two
set bar 1.000000
set border 31 lt -1 lw 1.000
set xdata
set ydata
set zdata
set x2data
set y2data
set boxwidth
set dummy x,y
set format x "%g"
set format y "%g"
set format x2 "%g"
set format y2 "%g"
set format z "%g"
set angles radians
set nogrid
set key title ""
set key right top Right noreverse box linetype -2 linewidth 1.000 samplen 4 spacing 1 width 0
set nolabel
set noarrow
set nolinestyle
set nologscale
set logscale x 10
set offsets 0, 0, 0, 0
set pointsize 1
set encoding default
set nopolar
set noparametric
set view 60, 30, 1, 1
set samples 100, 100
set isosamples 10, 10
set surface
set nocontour
set clabel '%8.3g'
set mapping cartesian
set nohidden3d
set cntrparam order 4
set cntrparam linear
set cntrparam levels auto 5
set cntrparam points 5
set size ratio 0 1,1
set origin 0,0
set data style linespoints
set function style lines
set xzeroaxis lt -2 lw 1.000
set x2zeroaxis lt -2 lw 1.000
set yzeroaxis lt -2 lw 1.000
set y2zeroaxis lt -2 lw 1.000
set tics in
set ticslevel 0.5
set ticscale 1 0.5
set mxtics default
set mytics default
set mx2tics default
set my2tics default
set xtics border mirror norotate autofreq
set ytics border mirror norotate autofreq
set ztics border nomirror norotate autofreq
set nox2tics
set noy2tics
set title "transposed-matrix vector product " 0.000000,0.000000 ""
set timestamp "" bottom norotate 0.000000,0.000000 ""
set rrange [ * : * ] noreverse nowriteback # (currently [-0:10] )
set trange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set urange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set vrange [ * : * ] noreverse nowriteback # (currently [-5:5] )
set xlabel "matrix size" 0.000000,0.000000 ""
set x2label "" 0.000000,0.000000 ""
set timefmt "%d/%m/%y\n%H:%M"
set xrange [ 10 : 1000 ] noreverse nowriteback
set x2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
set ylabel "MFLOPS" 0.000000,0.000000 ""
set y2label "" 0.000000,0.000000 ""
set yrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
set y2range [ * : * ] noreverse nowriteback # (currently [-10:10] )
set zlabel "" 0.000000,0.000000 ""
set zrange [ * : * ] noreverse nowriteback # (currently [-10:10] )
set zero 1e-08
set lmargin -1
set bmargin -1
set rmargin -1
set tmargin -1
set locale "C"
set xrange [1:1000]
##set yrange [0:400]

View File

@@ -3,6 +3,7 @@ mkdir $1
source mk_mean_script.sh axpy $1 11 2500 100000 250000 > $1/axpy.html
source mk_mean_script.sh matrix_vector $1 11 50 300 500 > $1/matrix_vector.html
source mk_mean_script.sh atv $1 11 50 300 500 > $1/atv.html
source mk_mean_script.sh matrix_matrix $1 11 100 300 500 > $1/matrix_matrix.html
source mk_mean_script.sh aat $1 11 100 300 1000 > $1/aat.html
source mk_mean_script.sh ata $1 11 100 300 1000 > $1/ata.html

View File

@@ -19,6 +19,8 @@
//
#ifndef BENCH_HH
#define BENCH_HH
#include "btl.hh"
#include "bench_parameter.hh"
#include <iostream>
#include "utilities.h"
@@ -34,9 +36,10 @@
using namespace std;
template <template<class> class Perf_Analyzer, class Action>
void bench( int size_min, int size_max, int nb_point ){
// bench name
void bench( int size_min, int size_max, int nb_point )
{
if (BtlConfig::skipAction(Action::name()))
return;
string filename="bench_"+Action::name()+".dat";

View File

@@ -48,6 +48,6 @@
#define DEFAULT_NB_SAMPLE 1000
// how many times we run a single bench (keep the best perf)
#define NB_TRIES 3
#define NB_TRIES 4
#endif

View File

@@ -0,0 +1,186 @@
//=====================================================
// File : btl.hh
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.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 <vector>
#include <string>
#include "utilities.h"
/** 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()
: m_runSingleAction(false)
{
char * _config;
_config = getenv ("BTL_CONFIG");
if (_config!=NULL)
{
std::vector<BtlString> config = BtlString(_config).split(" \t\n");
for (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_runSingleAction = true;
Instance.m_singleActionName = config[i+1];
i += 1;
}
}
}
}
static bool skipAction(const std::string& name)
{
if (Instance.m_runSingleAction)
{
std::cout << "Instance.m_singleActionName = " << Instance.m_singleActionName << "\n";
return !BtlString(name).contains(Instance.m_singleActionName);
}
return false;
}
protected:
bool m_runSingleAction;
BtlString m_singleActionName;
static BtlConfig Instance;
};
#define BTL_MAIN \
BtlConfig BtlConfig::Instance
#endif // BTL_HH

View File

@@ -19,6 +19,8 @@
//
#ifndef BENCH_STATIC_HH
#define BENCH_STATIC_HH
#include "btl.hh"
#include "bench_parameter.hh"
#include <iostream>
#include "utilities.h"
@@ -34,6 +36,9 @@ using namespace std;
template <template<class> class Perf_Analyzer, template<class> class Action, template<class,int> class Interface>
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);

View File

@@ -28,6 +28,8 @@
//#include "action_lu_solve.hh"
#include "timers/mixed_perf_analyzer.hh"
BTL_MAIN;
int main()
{

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : main.cpp
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:28 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 "C_BLAS_interface.hh"
#include "bench.hh"
@@ -27,22 +27,23 @@
#include "action_ata_product.hh"
#include "action_aat_product.hh"
BTL_MAIN;
int main()
{
bench<Action_axpy<C_BLAS_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
bench<Action_axpy<C_BLAS_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
bench<Action_matrix_vector_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_matrix_vector_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_matrix_matrix_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_matrix_matrix_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_ata_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_aat_product<C_BLAS_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
//bench<Action_lu_solve<C_BLAS_LU_solve_interface<REAL_TYPE> > >(MIN_LU,MAX_LU,NB_POINT);
return 0;
}

View File

@@ -28,6 +28,8 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{
bench<Action_axpy<STL_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);

View File

@@ -23,6 +23,8 @@
#include "action_atv_product.hh"
#include "action_axpy.hh"
BTL_MAIN;
int main()
{

View File

@@ -29,6 +29,8 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{

View File

@@ -108,7 +108,7 @@ public :
}
static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
X = (A*B).lazy();
X = (A.transpose()*B).lazy();
}
static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){

View File

@@ -18,7 +18,6 @@
#include "utilities.h"
#include "eigen2_interface.hh"
#include "bench.hh"
#include "static/bench_static.hh"
#include "action_matrix_vector_product.hh"
#include "action_matrix_matrix_product.hh"
#include "action_axpy.hh"
@@ -27,22 +26,20 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{
bench<Action_matrix_vector_product<eigen2_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_atv_product<eigen2_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_axpy<eigen2_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
bench<Action_matrix_matrix_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_ata_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_aat_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
// bench<Action_axpy<eigen2_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
// bench<Action_matrix_matrix_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
// bench<Action_ata_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
// bench<Action_aat_product<eigen2_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
//bench<Action_lu_solve<blitz_LU_solve_interface<REAL_TYPE> > >(MIN_LU,MAX_LU,NB_POINT);
bench_static<Action_axpy,eigen2_interface>();
bench_static<Action_matrix_matrix_product,eigen2_interface>();
bench_static<Action_matrix_vector_product,eigen2_interface>();
return 0;
}

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : main.cpp
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:25 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 "f77_interface.hh"
#include "bench.hh"
@@ -27,17 +27,18 @@
#include "action_ata_product.hh"
#include "action_aat_product.hh"
BTL_MAIN;
int main()
{
bench<Action_axpy<f77_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
bench<Action_axpy<f77_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
bench<Action_matrix_vector_product<f77_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_matrix_vector_product<f77_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
bench<Action_matrix_matrix_product<f77_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_matrix_matrix_product<f77_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_ata_product<f77_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
bench<Action_aat_product<f77_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
return 0;

View File

@@ -26,6 +26,8 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{

View File

@@ -26,6 +26,8 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : main.cpp
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:30 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 "tiny_blitz_interface.hh"
#include "static/bench_static.hh"
@@ -25,6 +25,8 @@
#include "action_axpy.hh"
#include "timers/x86_perf_analyzer.hh"
BTL_MAIN;
int main()
{
bench_static<Action_axpy,tiny_blitz_interface>();

View File

@@ -1,4 +1,3 @@
include_directories(${BLITZ_INCLUDES})
add_executable(btl_blitz main.cpp)
target_link_libraries(btl_blitz ${BLITZ_LIBRARIES})
include_directories(${TVMET_INCLUDE_DIR})
add_executable(btl_tvmet main.cpp)

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : main.cpp
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:30 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,19 +16,23 @@
// 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 "tvmet_interface.hh"
#include "static/bench_static.hh"
#include "action_matrix_vector_product.hh"
#include "action_matrix_matrix_product.hh"
#include "action_atv_product.hh"
#include "action_axpy.hh"
BTL_MAIN;
int main()
{
bench_static<Action_axpy,tvmet_interface>();
bench_static<Action_matrix_matrix_product,tvmet_interface>();
bench_static<Action_matrix_vector_product,tvmet_interface>();
bench_static<Action_atv_product,tvmet_interface>();
return 0;
}

View File

@@ -1,14 +1,14 @@
//=====================================================
// File : tvmet_interface.hh
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Author : L. Plagne <laurent.plagne@edf.fr)>
// Copyright (C) EDF R&D, lun sep 30 14:23:30 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,10 +16,11 @@
// 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 TVMET_INTERFACE_HH
#define TVMET_INTERFACE_HH
#include <tvmet/tvmet.h>
#include <tvmet/Vector.h>
#include <tvmet/Matrix.h>
@@ -29,113 +30,75 @@ using namespace tvmet;
template<class real, int SIZE>
class tvmet_interface{
public :
typedef real real_type ;
typedef std::vector<real> stl_vector;
typedef std::vector<stl_vector > stl_matrix;
typedef Vector<real,SIZE> gene_vector;
typedef Matrix<real,SIZE,SIZE> gene_matrix;
static inline std::string name( void )
{
return "tvmet";
}
static void free_matrix(gene_matrix & A, int N){
return ;
}
static void free_vector(gene_vector & B){
return ;
}
static inline std::string name() { return "tvmet"; }
static void free_matrix(gene_matrix & A, int N){}
static void free_vector(gene_vector & B){}
static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
for (int i=0; i<A_stl.size() ; i++){
for (int j=0; j<A_stl[i].size() ; j++){
A(i,j)=A_stl[i][j];
}
}
for (int j=0; j<A_stl.size() ; j++)
for (int i=0; i<A_stl[j].size() ; i++)
A(i,j) = A_stl[j][i];
}
static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
for (int i=0; i<B_stl.size() ; i++){
for (int i=0; i<B_stl.size() ; i++)
B[i]=B_stl[i];
}
}
static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
for (int i=0; i<B_stl.size() ; i++){
B_stl[i]=B[i];
}
}
static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
int N=A_stl.size();
for (int i=0;i<N;i++){
A_stl[i].resize(N);
for (int j=0;j<N;j++){
A_stl[i][j]=A(i,j);
}
int N = A_stl.size();
for (int j=0;j<N;j++){
A_stl[j].resize(N);
for (int i=0;i<N;i++)
A_stl[j][i] = A(i,j);
}
}
static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N)
{
for (int i=0;i<N;i++){
for (int j=0;j<N;j++){
cible(i,j)=source(i,j);
}
}
static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
cible = source;
}
static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N)
{
for (int i=0;i<N;i++){
cible[i]=source[i];
}
}
static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N)
{
X=product(A,B);
static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
cible = source;
}
static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N)
{
X=product(A,B);
static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
X = prod(A,B);
}
static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N)
{
static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
X = prod(A,B);
}
static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
X = prod(trans(A),B);
}
static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
Y+=coef*X;
}
};
#endif

View File

@@ -27,6 +27,8 @@
#include "action_aat_product.hh"
#include "action_atv_product.hh"
BTL_MAIN;
int main()
{
bench<Action_axpy<ublas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);