* [gentoo-commits] proj/auto-numerical-bench:master commit in: btl/actions/, /, btl/libs/LAPACK/
@ 2011-06-15 0:57 Andrea Arteaga
0 siblings, 0 replies; only message in thread
From: Andrea Arteaga @ 2011-06-15 0:57 UTC (permalink / raw
To: gentoo-commits
commit: 51b442c2fa96111016b8680319163b781cd56aac
Author: spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Wed Jun 15 00:56:22 2011 +0000
Commit: Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Wed Jun 15 00:56:22 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=51b442c2
Work on BTL LAPACK interface and test suite.
---
blasbase.py | 13 ++++-
btl/actions/action_cholesky.hh | 1 +
btl/actions/action_least_squares.hh | 2 +-
btl/actions/action_symm_ev.hh | 87 ++++++++++++++++++++++++++++++
btl/libs/LAPACK/lapack_interface.hh | 9 +++
btl/libs/LAPACK/lapack_interface_impl.hh | 31 +++++++++++
btl/libs/LAPACK/main.cpp | 26 +++++++--
cblas.py | 7 ++-
main.py | 4 +-
9 files changed, 168 insertions(+), 12 deletions(-)
diff --git a/blasbase.py b/blasbase.py
index b9be2cd..36413c7 100644
--- a/blasbase.py
+++ b/blasbase.py
@@ -1,8 +1,15 @@
-import os, shlex
+import sys, os, shlex
import commands as cmd
import subprocess as sp
-import matplotlib.pyplot as plt
-import numpy as np
+
+try:
+ import matplotlib.pyplot as plt
+ import numpy as np
+except ImportError:
+ sys.stderr.write('Error: matplotlib and numpy are needed' + \
+ 'in order to generate the reports!\n')
+ sys.stderr.write('Continue anyway.\n')
+
import btlutils as btl
run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
diff --git a/btl/actions/action_cholesky.hh b/btl/actions/action_cholesky.hh
index 5f66d11..a1c751b 100644
--- a/btl/actions/action_cholesky.hh
+++ b/btl/actions/action_cholesky.hh
@@ -21,6 +21,7 @@
#include "utilities.h"
#include "STL_interface.hh"
#include <string>
+#include <cmath>
#include "init/init_function.hh"
#include "init/init_vector.hh"
#include "init/init_matrix.hh"
diff --git a/btl/actions/action_least_squares.hh b/btl/actions/action_least_squares.hh
index a37ac66..b597f5f 100644
--- a/btl/actions/action_least_squares.hh
+++ b/btl/actions/action_least_squares.hh
@@ -117,4 +117,4 @@ private:
};
-#endif// ACTION_LEAST_SQUARES
+#endif // ACTION_LEAST_SQUARES
diff --git a/btl/actions/action_symm_ev.hh b/btl/actions/action_symm_ev.hh
new file mode 100644
index 0000000..8f7f5d3
--- /dev/null
+++ b/btl/actions/action_symm_ev.hh
@@ -0,0 +1,87 @@
+#ifndef ACTION_SYMM_EV
+#define ACTION_SYMM_EV
+
+#include "utilities.h"
+#include "STL_interface.hh"
+#include <string>
+#include "init/init_function.hh"
+#include "init/init_vector.hh"
+#include "init/init_matrix.hh"
+
+template<class Interface>
+class Action_symm_ev {
+
+public:
+
+ // Ctor
+ Action_symm_ev( int size ) : _size(size)
+ {
+ MESSAGE("Action_symm_ev Ctor");
+
+ // STL matrix initialization
+ init_matrix_symm<pseudo_random>(X_stl,_size);
+ init_vector<pseudo_random>(W_stl,_size);
+
+ // generic matrix and vector initialization
+ Interface::matrix_from_stl(X,X_stl);
+ Interface::vector_from_stl(W,W_stl);
+
+
+ }
+
+ // invalidate copy ctor
+
+ Action_symm_ev( const Action_symm_ev & )
+ {
+ INFOS("illegal call to Action_symm_ev Copy Ctor");
+ exit(1);
+ }
+
+ // Dtor
+
+ ~Action_symm_ev( void ){
+
+ MESSAGE("Action_symm_ev Dtor");
+
+ // deallocation
+ Interface::free_matrix(X,_size);
+ }
+
+ // action name
+
+ static inline std::string name( void )
+ {
+ return "symm_ev_"+Interface::name();
+ }
+
+ double nb_op_base( void ){
+ // TODO: is this right?
+ return _size*_size;
+ }
+
+ inline void initialize( void ){
+ }
+
+ inline void calculate( void ) {
+ Interface::symm_ev(X,W,_size);
+ }
+
+ void check_result( void ) {
+ // TODO: check result
+ }
+
+private :
+
+ typename Interface::stl_matrix X_stl;
+ typename Interface::stl_vector W_stl;
+
+ typename Interface::gene_matrix X;
+ typename Interface::gene_vector W;
+
+ int _size;
+ double _cost;
+
+};
+
+
+#endif // ACTION_SYMM_EV
diff --git a/btl/libs/LAPACK/lapack_interface.hh b/btl/libs/LAPACK/lapack_interface.hh
index 73aab38..33de2be 100644
--- a/btl/libs/LAPACK/lapack_interface.hh
+++ b/btl/libs/LAPACK/lapack_interface.hh
@@ -9,6 +9,15 @@ extern "C" {
void sgels_(char*, int*, int*, int*, float *, int*, float *, int*, float *, int*, int*);
void dgels_(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, int*);
+
+//void sgetrf_(int*, int*, float *, int*, int*, int*);
+//void dgetrf_(int*, int*, double*, int*, int*, int*);
+
+//void spotrf_(char*, int*, float *, int*, int*);
+//void dpotrf_(char*, int*, double*, int*, int*);
+
+void ssyev_(char*, char*, int*, float *, int*, float *, float *, int*, int*);
+void dsyev_(char*, char*, int*, double*, int*, double*, double*, int*, int*);
}
diff --git a/btl/libs/LAPACK/lapack_interface_impl.hh b/btl/libs/LAPACK/lapack_interface_impl.hh
index 38e3639..18ce305 100644
--- a/btl/libs/LAPACK/lapack_interface_impl.hh
+++ b/btl/libs/LAPACK/lapack_interface_impl.hh
@@ -33,5 +33,36 @@ public:
delete[] ipiv;
}
+ static inline void lu_decomp(const gene_matrix& X, gene_matrix& C, int N)
+ {
+ int N2 = N*N;
+ int *ipiv = new int[N];
+ int info;
+ LPF(copy)(&N2, X, &intone, C, &intone);
+ LPF(getrf)(&N, &N, C, &N, ipiv, &info);
+ delete[] ipiv;
+ }
+
+ static inline void cholesky(const gene_matrix& X, gene_matrix& C, int N)
+ {
+ int N2 = N*N;
+ int info;
+ LPF(copy)(&N2, X, &intone, C, &intone);
+ LPF(potrf)(&lower, &N, C, &N, &info);
+ }
+
+ static inline void symm_ev(const gene_matrix& X, gene_vector& W, int N)
+ {
+ char jobz = 'N';
+ SCALAR *work = new SCALAR;
+ int lwork = -1, info;
+ LPF(syev)(&jobz, &lower, &N, X, &N, W, work, &lwork, &info);
+ lwork = *work;
+ delete work;
+ work = new SCALAR[lwork];
+ LPF(syev)(&jobz, &lower, &N, X, &N, W, work, &lwork, &info);
+ delete[] work;
+ }
+
};
diff --git a/btl/libs/LAPACK/main.cpp b/btl/libs/LAPACK/main.cpp
index caa076c..138554a 100644
--- a/btl/libs/LAPACK/main.cpp
+++ b/btl/libs/LAPACK/main.cpp
@@ -2,6 +2,9 @@
#include <bench.hh>
#include <action_general_solve.hh>
#include <action_least_squares.hh>
+#include <action_lu_decomp.hh>
+#include <action_cholesky.hh>
+#include <action_symm_ev.hh>
#include <lapack_interface.hh>
#include <string>
@@ -11,22 +14,35 @@ BTL_MAIN;
int main(int argc, char **argv)
{
bool
- general_solve=false, least_squares=false
+ general_solve=false, least_squares=false, lu_decomp=false, cholesky=false,
+ symm_ev=false
;
- for (int i = 1; i < argv; ++i) {
- std::string arg = argc[i];
+ for (int i = 1; i < argc; ++i) {
+ std::string arg = argv[i];
if (arg == "general_solve") general_solve = true;
else if (arg == "least_squares") least_squares = true;
+ else if (arg == "lu_decomp") lu_decomp = true;
+ else if (arg == "cholesky") cholesky = true;
+ else if (arg == "symm_ev") symm_ev = true;
}
if (general_solve)
- bench<Action_general_solve<lapack_interface<REAL_TYPE> > >(0,2000,NB_POINT);
+ bench<Action_general_solve<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
if (least_squares)
- bench<Action_least_squares<lapack_interface<REAL_TYPE> > >(0,2000,NB_POINT);
+ bench<Action_least_squares<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+
+ if (lu_decomp)
+ bench<Action_lu_decomp<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+
+ if (cholesky)
+ bench<Action_cholesky<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+
+ if (symm_ev)
+ bench<Action_symm_ev<lapack_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
return 0;
}
diff --git a/cblas.py b/cblas.py
index c3140bd..ad47c65 100644
--- a/cblas.py
+++ b/cblas.py
@@ -4,8 +4,11 @@ import subprocess as sp
class Module(blasbase.ModuleBase):
@staticmethod
def get_impls(root):
- return [i for i in os.listdir(root + "/etc/env.d/alternatives/cblas") \
- if i[0] != '_']
+ output = sp.Popen(
+ ['eselect', '--no-color', '--brief', 'cblas', 'list'],
+ env={'ROOT' : root}, stdout=sp.PIPE
+ ).communicate()[0]
+ return output.strip().split('\n')
def _get_flags(self, root, impl, libdir):
# Retrieve pkgconfig settings and map the directories to the new root
diff --git a/main.py b/main.py
index ea459a4..feeef86 100644
--- a/main.py
+++ b/main.py
@@ -64,8 +64,10 @@ def tests_from_input(input):
if len(avail) > 1:
for n,p in enumerate(avail):
tests[spl[0]+"_%02i"%n] = {'package':p , 'env':env}
- else:
+ elif len(avail) == 1:
tests[spl[0]] = {'package':avail[0] , 'env':env}
+ else:
+ sys.stderr.write('Error: package ' + spl[1] + ' not found\n')
return tests
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-15 0:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-15 0:57 [gentoo-commits] proj/auto-numerical-bench:master commit in: btl/actions/, /, btl/libs/LAPACK/ Andrea Arteaga
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox