public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/auto-numerical-bench:master commit in: /, btl/libs/BLAS/
@ 2011-06-07 23:14 Andrea Arteaga
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Arteaga @ 2011-06-07 23:14 UTC (permalink / raw
  To: gentoo-commits

commit:     0321f710f0a735c6536369d7d2b4dea20a5f6d6a
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Tue Jun  7 23:14:01 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Tue Jun  7 23:14:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=0321f710

Splitted blas levels 1, 2 and 3. Many bugs solved.

---
 PortageUtils.py        |    9 +------
 blas.py                |   52 +++++++++++++++++++++++++++++++---------
 btl/libs/BLAS/main.cpp |   62 ++++++++++++++++++++++++++---------------------
 main.py                |   47 +++++++++++++++++++++++++++---------
 4 files changed, 110 insertions(+), 60 deletions(-)

diff --git a/PortageUtils.py b/PortageUtils.py
index c27dc79..4877cbd 100644
--- a/PortageUtils.py
+++ b/PortageUtils.py
@@ -56,13 +56,6 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
         # In case of error, print the whole emerge command
         raise InstallException(cl)
     
-    # Unpack the archive onto the given root directory
-    archive = pkgdir + pkg + '.tbz2'
-    os.path.exists(root) or os.makedirs(root)
-    so = cmd.getstatusoutput("tar xjf " + archive + " -C " + root);
-    if so[0] != 0:
-        raise InstallException(so[1])
-    
 if __name__ == '__main__':
     # Just a test
-    print available_packages('blas-reference')
\ No newline at end of file
+    print available_packages('blas-reference')

diff --git a/blas.py b/blas.py
index 2cf1ec8..4a3def1 100644
--- a/blas.py
+++ b/blas.py
@@ -5,10 +5,33 @@ import subprocess as sp
 run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
 
 class Module:
-    def __init__(self, Print, libdir):
+    def __init__(self, Print, libdir, args):
         self.Print = Print
         self.libdir = libdir
-    
+        self.test1 = False
+        self.test2 = False
+        self.test3 = False
+        for a in args:
+            if str(a) == str(1):
+                self.test1 = True
+                continue
+            if str(a) == str(2):
+                self.test2 = True
+                continue
+            if str(a) == str(3):
+                self.test3 = True
+                continue
+            raise Exception('Not recognized argument: %s' % a)
+        
+        self.tests = []
+        if self.test1:
+            self.tests += ['axpy', 'axpby', 'rot']
+        if self.test2:
+            self.tests += ['matrix_vector', 'atv', 'symv', 'syr2', 'ger',\
+              'trisolve_vector']
+        if self.test3:
+            self.tests += ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm']
+
     @staticmethod
     def get_impls(root):
         return [i for i in os.listdir(root + "/etc/env.d/alternatives/blas") \
@@ -18,22 +41,19 @@ class Module:
         Print = self.Print
         libdir = self.libdir
         name = 'blas'
-        files = ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in (
-              'axpy', 'axpby', 'matrix_vector', 'atv', 'symv',
-              'syr2', 'ger', 'rot', 'matrix_matrix', 'aat',
-              'trisolve_vector', 'trisolve_matrix', 'trmm')]
+        files = ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in self.tests]
         
         # Create dir. If all results already exist use them, otherwise
         # remove old results
         runtests = False
         if os.path.exists(testdir):
-             runtests = all([os.path.exists(i) for i in files])
+            runtests = not all([os.path.exists(i) for i in files])
         else:
             os.makedirs(testdir)
             runtests = True
         
         if not runtests:
-            Print("Not testing: result exist")
+            Print("Not testing: results exist")
             return files
         
         for i in files:
@@ -47,7 +67,11 @@ class Module:
               (os.environ.has_key(v) and (os.environ[v],) or (None,))[0]
         os.environ['LIBRARY_PATH'] = root + libdir
         os.environ['INCLUDE_PATH'] = root + '/usr/include'
-        os.environ['LD_LIBRARY_PATH']= root+libdir+":"+oldenv['LD_LIBRARY_PATH']
+        if oldenv['LD_LIBRARY_PATH'] != None:
+            os.environ['LD_LIBRARY_PATH'] = \
+              root + libdir + ":" + oldenv['LD_LIBRARY_PATH']
+        else:
+            os.environ['LD_LIBRARY_PATH'] = root + libdir
         
         # Retrieve pkgconfig settings and map the directories to the new root
         os.environ['PKG_CONFIG_PATH'] = \
@@ -76,8 +100,12 @@ class Module:
             raise Exception("Compilation failed: " + cl)
         Print("Compilation successful: %s" % cl)
         
-        # Run test        
-        proc = sp.Popen(exe, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
+        # Run test
+        args = [exe]
+        self.test1 and args.append('1')
+        self.test2 and args.append('2')
+        self.test3 and args.append('3')
+        proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
           cwd = testdir)
         results = []
         while True:
@@ -105,4 +133,4 @@ class Module:
                 os.environ[v] = oldenv[v]
             elif os.environ.has_key(v):
                 del os.environ[v]
-        return files
\ No newline at end of file
+        return files

diff --git a/btl/libs/BLAS/main.cpp b/btl/libs/BLAS/main.cpp
index ebe1966..37b8f81 100644
--- a/btl/libs/BLAS/main.cpp
+++ b/btl/libs/BLAS/main.cpp
@@ -33,40 +33,46 @@
 
 BTL_MAIN;
 
-int main()
+int main(int argv, char **argc)
 {
+  bool test_1=false, test_2=false, test_3=false;
+  for (int i = 0; i < argv; ++i) {
+    switch(argc[i][0]) {
+      case '1':
+        test_1 = true;
+        break;
+      case '2':
+        test_2 = true;
+        break;
+      case '3':
+        test_3 = true;
+        break;
+    }
+  }
 
-  bench<Action_axpy<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
-  bench<Action_axpby<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  if (test_1) {
+    bench<Action_axpy<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+    bench<Action_axpby<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+    bench<Action_rot<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  }
 
-  bench<Action_matrix_vector_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-  bench<Action_atv_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-  bench<Action_symv<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-  bench<Action_syr2<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+  if (test_2) {
+    bench<Action_matrix_vector_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+    bench<Action_atv_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+    bench<Action_symv<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+    bench<Action_syr2<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+    bench<Action_ger<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+    bench<Action_trisolve<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+  }
 
-  bench<Action_ger<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-  bench<Action_rot<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  if (test_3) {
+    bench<Action_matrix_matrix_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+    bench<Action_aat_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+    bench<Action_trisolve_matrix<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+    bench<Action_trmm<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+  }
 
-  bench<Action_matrix_matrix_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-//   bench<Action_ata_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_aat_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
 
-  bench<Action_trisolve<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_trisolve_matrix<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-
-  bench<Action_trmm<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-/*
-  bench<Action_cholesky<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_partial_lu<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-
-  #ifdef HAS_LAPACK
-  bench<Action_lu_decomp<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_hessenberg<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_tridiagonalization<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  #endif
-
-  //bench<Action_lu_solve<blas_LU_solve_interface<REAL_TYPE> > >(MIN_LU,MAX_LU,NB_POINT);
-*/
   return 0;
 }
 

diff --git a/main.py b/main.py
index 5f2f0d3..c9f1b5b 100644
--- a/main.py
+++ b/main.py
@@ -1,6 +1,7 @@
 import os, sys, shlex
 import commands as cmd
 from PortageUtils import *
+import subprocess as sp
   
 class _Print:
     def __init__(self):
@@ -41,24 +42,31 @@ def tests_from_input(input):
     tests = {}
     for line in input.split('\n'):
         line = line.strip()
-        spl = shlex.split(line)
+        spl = [i.strip() for i in shlex.split(line)]
         if len(spl) < 2:
             continue
-        package = available_packages(spl[1])
+        if line[0] == '#':
+            continue
+        avail = available_packages(spl[1])
         env = {}
         for var in spl[2:]:
             s = var.split('=')
             env[s[0]] = s[1]
-        tests[spl[0]] = {'package' : package , 'env' : env}
+	avail = available_packages(spl[1])
+	if len(avail) > 1:
+            for n,p in enumerate(avail):
+	        tests[spl[0]+"_%2i"%n] = {'package':p , 'env':env}
+	else:
+	    tests[spl[0]] = {'package':avail[0] , 'env':env}
     return tests
     
     
 # Import the desired module or print help and exit
 try:
     tmp = __import__(sys.argv[1], fromlist = ['Module'])
-    mod = tmp.Module(Print, libdir)
+    mod = tmp.Module(Print, libdir, sys.argv[2:])
     del tmp
-except:
+except ImportError:
     print_usage()
     exit(1)
 
@@ -111,14 +119,14 @@ dictionary; the line has to contain:
 """
 input = '''
 abcde blas-reference-3.3.1-r1 FC=gfortran
-fghij dev-cpp/eigen-3.0.0-r1 CXX=gcc CXXFLAGS='-O2'
-klmno dev-cpp/eigen-3.0.0-r1 CXX=icc CXXFLAGS='-O3'
-pqrst sci-libs/blas-reference-3.3.1-r1 FC=ifort
+fghij dev-cpp/eigen-3.0.0-r1 CXX=g++ CXXFLAGS='-O2'
+#klmno dev-cpp/eigen-3.0.0-r1 CXX=icpc CXXFLAGS='-O3'
+#pqrst sci-libs/blas-reference-3.3.1-r1 FC=ifort
 '''
 tests = tests_from_input(input)
 
 for tn,(name,test) in enumerate(tests.items(),1):
-    Print("BEGIN TEST %i" % tn)
+    Print("BEGIN TEST %i - %s" % (tn, name))
     
     pkgdir = "%s/%s/" % (pkgsdir, name)
     root = "%s/%s/" % (rootsdir, name)
@@ -126,13 +134,22 @@ for tn,(name,test) in enumerate(tests.items(),1):
     # Emerge package
     Print.down()
     package = "%s/%s-%s-%s" % test['package']
+    archive = pkgdir+package+".tbz2"
     Print("Emerging package %s" % package)
-    if os.exists(pkgdir+package+".tbz2"):
+    if os.path.exists(archive):
         Print("Package already emerged - skipping")
     else:
         try:
             install_package( \
               test['package'], env=test['env'], root=root, pkgdir=pkgdir)
+            # Unpack the archive onto the given root directory
+            archive = pkgdir + pkg + '.tbz2'
+            os.path.exists(root) or os.makedirs(root)
+            tarcmd = "tar xjf " + archive + " -C " + root
+            so=sp.Popen(tarcmd, stdout=sp.PIPE).communicate()[0]
+            if so[0] != 0:
+                raise InstallException(tarcmd)
+                
         except InstallException as e:
             Print("Package %s failed to emerge: %s" % (package, e.command))
             Print.up()
@@ -142,6 +159,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
     
     # Find implementations
     impls = mod.get_impls(root)
+    test['implementations'] = impls
       
     # Test every implementation
     test['results'] = {}
@@ -158,5 +176,10 @@ for tn,(name,test) in enumerate(tests.items(),1):
     print
     
 
-print tests
-exit(0)
+results = {}
+for (name,test) in tests.items():
+    for impl in test['implementations']:
+        results[(name, impl)] = test['results'][impl]
+
+for r,rr in results.items():
+    print r, rr



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/auto-numerical-bench:master commit in: /, btl/libs/BLAS/
@ 2011-06-09  0:43 Andrea Arteaga
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Arteaga @ 2011-06-09  0:43 UTC (permalink / raw
  To: gentoo-commits

commit:     6fbea9e9eb755b2ca0336b54daf52ffc365f72b6
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Thu Jun  9 00:37:29 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Thu Jun  9 00:37:29 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=6fbea9e9

Input from file added. Finished CBLAS suite. Added Base module for BLAS and CBLAS. Support for selecting single tests. Modified BTL main.cpp.
Many bugs solved. Porting to subprocess almost finished.

---
 PortageUtils.py                      |    9 +---
 blas.py                              |  108 +++------------------------------
 btl/libs/BLAS/blas_interface.hh      |   31 ++++------
 btl/libs/BLAS/blas_interface_impl.hh |   72 ----------------------
 btl/libs/BLAS/main.cpp               |   81 ++++++++++++++++++--------
 main.py                              |   69 +++++++++++++++-------
 6 files changed, 127 insertions(+), 243 deletions(-)

diff --git a/PortageUtils.py b/PortageUtils.py
index c27dc79..4877cbd 100644
--- a/PortageUtils.py
+++ b/PortageUtils.py
@@ -56,13 +56,6 @@ def install_package(package, env={}, root='/', pkgdir='usr/portage/packages'):
         # In case of error, print the whole emerge command
         raise InstallException(cl)
     
-    # Unpack the archive onto the given root directory
-    archive = pkgdir + pkg + '.tbz2'
-    os.path.exists(root) or os.makedirs(root)
-    so = cmd.getstatusoutput("tar xjf " + archive + " -C " + root);
-    if so[0] != 0:
-        raise InstallException(so[1])
-    
 if __name__ == '__main__':
     # Just a test
-    print available_packages('blas-reference')
\ No newline at end of file
+    print available_packages('blas-reference')

diff --git a/blas.py b/blas.py
index 2cf1ec8..295e833 100644
--- a/blas.py
+++ b/blas.py
@@ -1,108 +1,20 @@
-import os
-import commands as cmd
+import os, blasbase
 import subprocess as sp
 
-run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
-
-class Module:
-    def __init__(self, Print, libdir):
-        self.Print = Print
-        self.libdir = libdir
-    
+class Module(blasbase.ModuleBase): 
     @staticmethod
     def get_impls(root):
         return [i for i in os.listdir(root + "/etc/env.d/alternatives/blas") \
           if i[0] != '_']
-          
-    def run_test(self, root, impl, testdir):
-        Print = self.Print
-        libdir = self.libdir
-        name = 'blas'
-        files = ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in (
-              'axpy', 'axpby', 'matrix_vector', 'atv', 'symv',
-              'syr2', 'ger', 'rot', 'matrix_matrix', 'aat',
-              'trisolve_vector', 'trisolve_matrix', 'trmm')]
-        
-        # Create dir. If all results already exist use them, otherwise
-        # remove old results
-        runtests = False
-        if os.path.exists(testdir):
-             runtests = all([os.path.exists(i) for i in files])
-        else:
-            os.makedirs(testdir)
-            runtests = True
-        
-        if not runtests:
-            Print("Not testing: result exist")
-            return files
-        
-        for i in files:
-            if os.path.exists(i): os.remove(i)
-        
-        # Setup environment for testing
-        oldenv = {}
-        for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'):
-            # Backup old environment variables
-            oldenv[v] = \
-              (os.environ.has_key(v) and (os.environ[v],) or (None,))[0]
-        os.environ['LIBRARY_PATH'] = root + libdir
-        os.environ['INCLUDE_PATH'] = root + '/usr/include'
-        os.environ['LD_LIBRARY_PATH']= root+libdir+":"+oldenv['LD_LIBRARY_PATH']
-        
+           
+    def _get_flags(self, root, impl, libdir):
         # Retrieve pkgconfig settings and map the directories to the new root
-        os.environ['PKG_CONFIG_PATH'] = \
+        path = \
           "%s/etc/env.d/alternatives/blas/%s/%s/pkgconfig" % (root,impl,libdir)
-        pkgconf = cmd.getoutput('pkg-config --libs --cflags blas')
-        del os.environ['PKG_CONFIG_PATH']
+        pkgconf = sp.Popen('pkg-config --libs --cflags blas', shell=True, \
+          stdout=sp.PIPE, env={'PKG_CONFIG_PATH':path}).communicate()[0]
         pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
         pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
-        
-        # Compile
-        exe = testdir + "/test"
-        inc = """
-        -Ibtl/actions
-        -Ibtl/generic_bench
-        -Ibtl/generic_bench/utils
-        -Ibtl/libs/BLAS
-        -Ibtl/libs/STL
-        """.replace('\n', ' ')
-        libs = "-lrt -L" + root+libdir
-        cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
-        defines = "-DCBLASNAME=" + name
-        cl = "g++ %s %s %s %s %s btl/libs/BLAS/main.cpp -o %s" \
-            % (pkgconf, inc, libs, cxxflags, defines, exe)
-        so = cmd.getstatusoutput(cl)
-        if so[0] != 0:
-            raise Exception("Compilation failed: " + cl)
-        Print("Compilation successful: %s" % cl)
-        
-        # Run test        
-        proc = sp.Popen(exe, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
-          cwd = testdir)
-        results = []
-        while True:
-            errline = proc.stderr.readline()
-            if not errline:
-                break
-            resfile = errline.split()[-1]
-            results.append(resfile)
-            Print(resfile)
-            Print.down()
-            for i in xrange(100):
-                outline = proc.stdout.readline().rstrip()
-                Print(outline)
-            Print.up()
-        Print.up()
-        proc.wait()
-        if proc.returncode != 0:
-            Print('Test failed')
-        else:
-            Print('Test successful')
-        
-        # Restore old environment variables
-        for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'):
-            if oldenv[v] != None:
-                os.environ[v] = oldenv[v]
-            elif os.environ.has_key(v):
-                del os.environ[v]
-        return files
\ No newline at end of file
+        return pkgconf + " -DBLAS_INTERFACE"
+
+del blasbase

diff --git a/btl/libs/BLAS/blas_interface.hh b/btl/libs/BLAS/blas_interface.hh
index 6510546..86881a2 100644
--- a/btl/libs/BLAS/blas_interface.hh
+++ b/btl/libs/BLAS/blas_interface.hh
@@ -25,22 +25,8 @@
 extern "C"
 {
 #include "blas.h"
-
-  // Cholesky Factorization
-//   void spotrf_(const char* uplo, const int* n, float *a, const int* ld, int* info);
-//   void dpotrf_(const char* uplo, const int* n, double *a, const int* ld, int* info);
-  void ssytrd_(char *uplo, const int *n, float *a, const int *lda, float *d, float *e, float *tau, float *work, int *lwork, int *info );
-  void dsytrd_(char *uplo, const int *n, double *a, const int *lda, double *d, double *e, double *tau, double *work, int *lwork, int *info );
-  void sgehrd_( const int *n, int *ilo, int *ihi, float *a, const int *lda, float *tau, float *work, int *lwork, int *info );
-  void dgehrd_( const int *n, int *ilo, int *ihi, double *a, const int *lda, double *tau, double *work, int *lwork, int *info );
-
-  // LU row pivoting
-//   void dgetrf_( int *m, int *n, double *a, int *lda, int *ipiv, int *info );
-//   void sgetrf_(const int* m, const int* n, float *a, const int* ld, int* ipivot, int* info);
-  // LU full pivoting
-  void sgetc2_(const int* n, float *a, const int *lda, int *ipiv, int *jpiv, int*info );
-  void dgetc2_(const int* n, double *a, const int *lda, int *ipiv, int *jpiv, int*info );
-#ifdef HAS_LAPACK
+#ifdef CBLAS_INTERFACE
+#  include "cblas.h"
 #endif
 }
 
@@ -63,17 +49,24 @@ static char left = 'L';
 static int intone = 1;
 
 
-
 #define SCALAR        float
 #define SCALAR_PREFIX s
-#include "blas_interface_impl.hh"
+#ifdef CBLAS_INTERFACE
+#  include "cblas_interface_impl.hh"
+#else
+#  include "blas_interface_impl.hh"
+#endif
 #undef SCALAR
 #undef SCALAR_PREFIX
 
 
 #define SCALAR        double
 #define SCALAR_PREFIX d
-#include "blas_interface_impl.hh"
+#ifdef CBLAS_INTERFACE
+#  include "cblas_interface_impl.hh"
+#else
+#  include "blas_interface_impl.hh"
+#endif
 #undef SCALAR
 #undef SCALAR_PREFIX
 

diff --git a/btl/libs/BLAS/blas_interface_impl.hh b/btl/libs/BLAS/blas_interface_impl.hh
index 0e84df0..97fb631 100644
--- a/btl/libs/BLAS/blas_interface_impl.hh
+++ b/btl/libs/BLAS/blas_interface_impl.hh
@@ -46,10 +46,6 @@ public :
     BLAS_FUNC(gemm)(&notrans,&notrans,&N,&N,&N,&fone,A,&N,B,&N,&fzero,X,&N);
   }
 
-//   static inline void ata_product(gene_matrix & A, gene_matrix & X, int N){
-//     ssyrk_(&lower,&trans,&N,&N,&fone,A,&N,&fzero,X,&N);
-//   }
-
   static inline void aat_product(gene_matrix & A, gene_matrix & X, int N){
     BLAS_FUNC(syrk)(&lower,&notrans,&N,&N,&fone,A,&N,&fzero,X,&N);
   }
@@ -63,25 +59,6 @@ public :
     BLAS_FUNC(axpy)(&N,&a,X,&intone,Y,&intone);
   }
 
-  static inline void cholesky(const gene_matrix & X, gene_matrix & C, int N){
-    int N2 = N*N;
-    BLAS_FUNC(copy)(&N2, X, &intone, C, &intone);
-    char uplo = 'L';
-    int info = 0;
-    BLAS_FUNC(potrf)(&uplo, &N, C, &N, &info);
-    if(info!=0) std::cerr << "potrf_ error " << info << "\n";
-  }
-
-  static inline void partial_lu_decomp(const gene_matrix & X, gene_matrix & C, int N){
-    int N2 = N*N;
-    BLAS_FUNC(copy)(&N2, X, &intone, C, &intone);
-    char uplo = 'L';
-    int info = 0;
-    int * ipiv = (int*)alloca(sizeof(int)*N);
-    BLAS_FUNC(getrf)(&N, &N, C, &N, ipiv, &info);
-    if(info!=0) std::cerr << "getrf_ error " << info << "\n";
-  }
-  
   static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
     BLAS_FUNC(copy)(&N, B, &intone, X, &intone);
     BLAS_FUNC(trsv)(&lower, &notrans, &nonunit, &N, L, &N, X, &intone);
@@ -96,55 +73,6 @@ public :
     BLAS_FUNC(trmm)(&left, &lower, &notrans,&nonunit, &N,&N,&fone,A,&N,B,&N);
   }
 
-  #ifdef HAS_LAPACK
-
-  static inline void lu_decomp(const gene_matrix & X, gene_matrix & C, int N){
-    int N2 = N*N;
-    BLAS_FUNC(copy)(&N2, X, &intone, C, &intone);
-    char uplo = 'L';
-    int info = 0;
-    int * ipiv = (int*)alloca(sizeof(int)*N);
-    int * jpiv = (int*)alloca(sizeof(int)*N);
-    BLAS_FUNC(getc2)(&N, C, &N, ipiv, jpiv, &info);
-  }
-
-
-
-  static inline void hessenberg(const gene_matrix & X, gene_matrix & C, int N){
-    {
-      int N2 = N*N;
-      int inc = 1;
-      BLAS_FUNC(copy)(&N2, X, &inc, C, &inc);
-    }
-    int info = 0;
-    int ilo = 1;
-    int ihi = N;
-    int bsize = 64;
-    int worksize = N*bsize;
-    SCALAR* d = new SCALAR[N+worksize];
-    BLAS_FUNC(gehrd)(&N, &ilo, &ihi, C, &N, d, d+N, &worksize, &info);
-    delete[] d;
-  }
-
-  static inline void tridiagonalization(const gene_matrix & X, gene_matrix & C, int N){
-    {
-      int N2 = N*N;
-      int inc = 1;
-      BLAS_FUNC(copy)(&N2, X, &inc, C, &inc);
-    }
-    char uplo = 'U';
-    int info = 0;
-    int ilo = 1;
-    int ihi = N;
-    int bsize = 64;
-    int worksize = N*bsize;
-    SCALAR* d = new SCALAR[3*N+worksize];
-    BLAS_FUNC(sytrd)(&uplo, &N, C, &N, d, d+N, d+2*N, d+3*N, &worksize, &info);
-    delete[] d;
-  }
-  
-  #endif // HAS_LAPACK
-
 };
 
 SCALAR blas_interface<SCALAR>::fone = SCALAR(1);

diff --git a/btl/libs/BLAS/main.cpp b/btl/libs/BLAS/main.cpp
index ebe1966..7cea4b6 100644
--- a/btl/libs/BLAS/main.cpp
+++ b/btl/libs/BLAS/main.cpp
@@ -17,56 +17,89 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 //
+
+#ifndef BLAS_INTERFACE
+#  ifndef CBLAS_INTERFACE
+#    define BLAS_INTERFACE
+#  endif
+#endif
+
 #include "utilities.h"
 #include "blas_interface.hh"
 #include "bench.hh"
 #include "basic_actions.hh"
-
-#include "action_cholesky.hh"
-#include "action_lu_decomp.hh"
-#include "action_partial_lu.hh"
 #include "action_trisolve_matrix.hh"
 
-#ifdef HAS_LAPACK
-#include "action_hessenberg.hh"
-#endif
+#include <string>
 
 BTL_MAIN;
 
-int main()
+int main(int argv, char **argc)
 {
+  bool
+  axpy=false, axpby=false, rot=false,
+  matrix_vector=false, atv=false, symv=false, syr2=false, ger=false, trisolve_vector=false,
+  matrix_matrix=false, aat=false, trisolve_matrix=false, trmm=false  
+  ;
+  
+  
+  for (int i = 1; i < argv; ++i) {
+    std::string arg = argc[i];
+    if (arg == "axpy") axpy = true;
+    else if (arg == "axpby") axpby = true;
+    else if (arg == "rot") rot = true;
+    else if (arg == "matrix_vector") matrix_vector = true;
+    else if (arg == "atv") atv = true;
+    else if (arg == "symv") symv = true;
+    else if (arg == "syr2") syr2 = true;
+    else if (arg == "ger") ger = true;
+    else if (arg == "trisolve_vector") trisolve_vector = true;
+    else if (arg == "matrix_matrix") matrix_matrix = true;
+    else if (arg == "aat") aat = true;
+    else if (arg == "trisolve_matrix") trisolve_matrix = true;
+    else if (arg == "trmm") trmm = true;
+    
+    else if (arg[0] == '1' && arg[1] == '\0') {
+      axpy = true; axpby = true; rot = true;
+    }
+    else if (arg[0] == '2' && arg[1] == '\0') {
+      matrix_vector=true; atv=true; symv=true; syr2=true; ger=true; trisolve_vector=true;
+    }
+    else if (arg[0] == '3' && arg[1] == '\0') {
+      matrix_matrix=true; aat=true; trisolve_matrix=true; trmm=true;
+    }
+  }
 
+  if (axpy)
   bench<Action_axpy<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  if (axpby)
   bench<Action_axpby<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  if (rot)
+  bench<Action_rot<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
 
+  if (matrix_vector)
   bench<Action_matrix_vector_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+  if (atv)
   bench<Action_atv_product<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+  if (symv)
   bench<Action_symv<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
+  if (syr2)
   bench<Action_syr2<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-
+  if (ger)
   bench<Action_ger<blas_interface<REAL_TYPE> > >(MIN_MV,MAX_MV,NB_POINT);
-  bench<Action_rot<blas_interface<REAL_TYPE> > >(MIN_AXPY,MAX_AXPY,NB_POINT);
+  if (trisolve_vector)
+  bench<Action_trisolve<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
 
+  if (matrix_matrix)
   bench<Action_matrix_matrix_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-//   bench<Action_ata_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+  if (aat)
   bench<Action_aat_product<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-
-  bench<Action_trisolve<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
+  if (trisolve_matrix)
   bench<Action_trisolve_matrix<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-
+  if (trmm)
   bench<Action_trmm<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-/*
-  bench<Action_cholesky<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_partial_lu<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
 
-  #ifdef HAS_LAPACK
-  bench<Action_lu_decomp<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_hessenberg<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  bench<Action_tridiagonalization<blas_interface<REAL_TYPE> > >(MIN_MM,MAX_MM,NB_POINT);
-  #endif
 
-  //bench<Action_lu_solve<blas_LU_solve_interface<REAL_TYPE> > >(MIN_LU,MAX_LU,NB_POINT);
-*/
   return 0;
 }
 

diff --git a/main.py b/main.py
index 5f2f0d3..7b3c3a9 100644
--- a/main.py
+++ b/main.py
@@ -1,12 +1,15 @@
 import os, sys, shlex
-import commands as cmd
 from PortageUtils import *
+import subprocess as sp
   
 class _Print:
-    def __init__(self):
+    def __init__(self, maxlevel=10):
         self._level = 0
+        self._maxlevel = maxlevel
     
     def __call__(self, arg):
+        if self._level > self._maxlevel:
+            return
         if self._level <= 0:
             print str(arg)
             return
@@ -18,7 +21,7 @@ class _Print:
     def down(self, n=1):
         self._level = max(self._level+n, 0)
      
-Print = _Print()
+Print = _Print(2)
     
     
 # Retrieve relevant directories
@@ -28,37 +31,48 @@ else:
     pkgsdir = os.environ['HOME'] + "/.benchmarks/packages/"
 rootsdir = "/var/tmp/benchmarks/roots/"
 testsdir = "/var/tmp/benchmarks/tests/"
-libdir = cmd.getoutput \
-  ('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/')
+libdir = sp.Popen \
+  ('ABI=$(portageq envvar ABI); echo /usr/`portageq envvar LIBDIR_$ABI`/', \
+  stdout=sp.PIPE, shell=True).communicate()[0].strip()
 
 
 
 def print_usage():
-    print "Usage: benchmarks [blas|cblas|lapack]"
+    print "Usage: benchmarks [blas|cblas|lapack] file args"
     
     
 def tests_from_input(input):
     tests = {}
     for line in input.split('\n'):
         line = line.strip()
-        spl = shlex.split(line)
+        spl = [i.strip() for i in shlex.split(line)]
         if len(spl) < 2:
             continue
-        package = available_packages(spl[1])
+        if line[0] == '#':
+            continue
+        avail = available_packages(spl[1])
         env = {}
+        # TODO: add @file for env set based on external file
+        # TODO: add -impl for skipping implementation
         for var in spl[2:]:
             s = var.split('=')
             env[s[0]] = s[1]
-        tests[spl[0]] = {'package' : package , 'env' : env}
+	avail = available_packages(spl[1])
+	if len(avail) > 1:
+            for n,p in enumerate(avail):
+	            tests[spl[0]+"_%02i"%n] = {'package':p , 'env':env}
+	else:
+	    tests[spl[0]] = {'package':avail[0] , 'env':env}
     return tests
     
     
 # Import the desired module or print help and exit
 try:
     tmp = __import__(sys.argv[1], fromlist = ['Module'])
-    mod = tmp.Module(Print, libdir)
+    mod = tmp.Module(Print, libdir, sys.argv[3:])
     del tmp
-except:
+    testsfname = sys.argv[2]
+except ImportError, IndexError:
     print_usage()
     exit(1)
 
@@ -101,7 +115,7 @@ which can contain any type of data and will be used for the final report.
 
 
 """
-The test variable is generated from a string which can be read from input.
+The test variable is generated from a string which can be read from the file.
 Here is an example of the parsed input.
 Every line contains a configuration and will be an entry in the tests
 dictionary; the line has to contain:
@@ -109,16 +123,11 @@ dictionary; the line has to contain:
 - a package description, which can, but does not must to, contain a version
 - a list of environment variables separated by means of spaces 
 """
-input = '''
-abcde blas-reference-3.3.1-r1 FC=gfortran
-fghij dev-cpp/eigen-3.0.0-r1 CXX=gcc CXXFLAGS='-O2'
-klmno dev-cpp/eigen-3.0.0-r1 CXX=icc CXXFLAGS='-O3'
-pqrst sci-libs/blas-reference-3.3.1-r1 FC=ifort
-'''
+input = file(testsfname).read()
 tests = tests_from_input(input)
 
 for tn,(name,test) in enumerate(tests.items(),1):
-    Print("BEGIN TEST %i" % tn)
+    Print("BEGIN TEST %i - %s" % (tn, name))
     
     pkgdir = "%s/%s/" % (pkgsdir, name)
     root = "%s/%s/" % (rootsdir, name)
@@ -126,13 +135,23 @@ for tn,(name,test) in enumerate(tests.items(),1):
     # Emerge package
     Print.down()
     package = "%s/%s-%s-%s" % test['package']
+    archive = pkgdir+package+".tbz2"
     Print("Emerging package %s" % package)
-    if os.exists(pkgdir+package+".tbz2"):
+    if os.path.exists(archive):
         Print("Package already emerged - skipping")
     else:
         try:
             install_package( \
               test['package'], env=test['env'], root=root, pkgdir=pkgdir)
+            # Unpack the archive onto the given root directory
+            archive = pkgdir + package + '.tbz2'
+            os.path.exists(root) or os.makedirs(root)
+            tarcmd = "tar xjf " + archive + " -C " + root
+            tarp = sp.Popen(tarcmd, stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
+            tarp.communicate()
+            if tarp.returncode != 0:
+                raise InstallException(tarcmd)
+                
         except InstallException as e:
             Print("Package %s failed to emerge: %s" % (package, e.command))
             Print.up()
@@ -142,6 +161,7 @@ for tn,(name,test) in enumerate(tests.items(),1):
     
     # Find implementations
     impls = mod.get_impls(root)
+    test['implementations'] = impls
       
     # Test every implementation
     test['results'] = {}
@@ -158,5 +178,10 @@ for tn,(name,test) in enumerate(tests.items(),1):
     print
     
 
-print tests
-exit(0)
+results = {}
+for (name,test) in tests.items():
+    for impl in test['implementations']:
+        results[(name, impl)] = test['results'][impl]
+
+for r,rr in results.items():
+    print r, rr



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [gentoo-commits] proj/auto-numerical-bench:master commit in: /, btl/libs/BLAS/
@ 2011-06-09 10:51 Andrea Arteaga
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Arteaga @ 2011-06-09 10:51 UTC (permalink / raw
  To: gentoo-commits

commit:     b8648d805ca33c4de52ed8e5570858e7f1dc8a4c
Author:     Andrea Arteaga <spiros <AT> MyBookWorld <DOT> (none)>
AuthorDate: Thu Jun  9 10:51:08 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Thu Jun  9 10:51:08 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=b8648d80

Finishing yesterday's commit.

---
 blasbase.py                           |  126 +++++++++++++++++++++++++++++++++
 blastests.in                          |    4 +
 btl/libs/BLAS/cblas_interface_impl.hh |   79 ++++++++++++++++++++
 cblas.py                              |   20 +++++
 cblastests.in                         |    2 +
 5 files changed, 231 insertions(+), 0 deletions(-)

diff --git a/blasbase.py b/blasbase.py
new file mode 100644
index 0000000..1f8abb1
--- /dev/null
+++ b/blasbase.py
@@ -0,0 +1,126 @@
+import os, shlex
+import commands as cmd
+import subprocess as sp
+
+run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
+
+class ModuleBase:
+    def __init__(self, Print, libdir, args):
+        self.Print = Print
+        self.libdir = libdir
+        
+        avail1 = ['axpy', 'axpby', 'rot']
+        avail2 = ['matrix_vector','atv','symv','syr2','ger','trisolve_vector']
+        avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm']
+        
+        tests = []
+        for i in args:
+            if i == '1':
+                tests += avail1
+                continue
+            if i == '2':
+                tests += avail2
+                continue
+            if i == '3':
+                tests += avail3
+                continue
+            if i in avail1 + avail2 + avail3:
+                tests.append(i)
+                continue
+            raise Exception("Argument not recognized: " + i)
+        self.tests = [i for i in avail1+avail2+avail3 if i in tests]
+        
+        if len(self.tests) == 0:
+            self.tests = ['axpy', 'matrix_vector', \
+              'trisolve_vector', 'matrix_matrix']
+        
+          
+    def run_test(self, root, impl, testdir):
+        Print = self.Print
+        libdir = self.libdir
+        name = 'blas'
+        files = ['%s/bench_%s_%s.dat' %(testdir, op, name) for op in self.tests]
+        
+        # Create dir. If all results already exist use them, otherwise
+        # remove old results
+        runtests = False
+        if os.path.exists(testdir):
+            runtests = not all([os.path.exists(i) for i in files])
+        else:
+            os.makedirs(testdir)
+            runtests = True
+        
+        if not runtests:
+            Print("Not testing: results exist")
+            return files
+        
+        for i in files:
+            if os.path.exists(i): os.remove(i)
+        
+        # Setup environment for testing
+        oldenv = {}
+        for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'):
+            # Backup old environment variables
+            oldenv[v] = \
+              (os.environ.has_key(v) and (os.environ[v],) or (None,))[0]
+        os.environ['LIBRARY_PATH'] = root + libdir
+        os.environ['INCLUDE_PATH'] = root + '/usr/include'
+        if oldenv['LD_LIBRARY_PATH'] != None:
+            os.environ['LD_LIBRARY_PATH'] = \
+              root + libdir + ":" + oldenv['LD_LIBRARY_PATH']
+        else:
+            os.environ['LD_LIBRARY_PATH'] = root + libdir
+        
+        # Compile
+        exe = testdir + "/test"
+        inc = """
+        -Ibtl/actions
+        -Ibtl/generic_bench
+        -Ibtl/generic_bench/utils
+        -Ibtl/libs/BLAS
+        -Ibtl/libs/STL
+        """.replace('\n', '')
+        libs = "-lrt -L" + root+libdir
+        cxxflags = run_cmd(['portageq', 'envvar', 'CXXFLAGS']).strip()
+        defines = "-DCBLASNAME=" + name
+        implflags = self._get_flags(root, impl, libdir)
+        cl = "g++ %s %s %s %s %s btl/libs/BLAS/main.cpp -o %s" \
+            % (inc, libs, cxxflags, defines, implflags, exe)
+        cl = shlex.split(cl)
+        cp = sp.Popen(cl, stdout=sp.PIPE, stderr=sp.PIPE)
+        cp.communicate()
+        if cp.returncode != 0:
+            raise Exception("Compilation failed: " + " ".join(cl))
+        Print("Compilation successful: %s" % " ".join(cl))
+        
+        # Run test
+        args = [exe] + self.tests
+        proc = sp.Popen(args, bufsize=1, stdout=sp.PIPE, stderr=sp.PIPE, 
+          cwd = testdir)
+        results = []
+        while True:
+            errline = proc.stderr.readline()
+            if not errline:
+                break
+            resfile = errline.split()[-1]
+            results.append(resfile)
+            Print(resfile)
+            Print.down()
+            for i in xrange(100):
+                outline = proc.stdout.readline().rstrip()
+                Print(outline)
+            Print.up()
+        Print.up()
+        proc.wait()
+        if proc.returncode != 0:
+            Print('Test failed')
+        else:
+            Print('Test successful')
+        
+        # Restore old environment variables
+        for v in ('LIBRARY_PATH', 'INCLUDE_PATH', 'LD_LIBRARY_PATH'):
+            if oldenv[v] != None:
+                os.environ[v] = oldenv[v]
+            elif os.environ.has_key(v):
+                del os.environ[v]
+        return files

diff --git a/blastests.in b/blastests.in
new file mode 100644
index 0000000..c9462e3
--- /dev/null
+++ b/blastests.in
@@ -0,0 +1,4 @@
+abcde blas-reference-3.3.1-r1 FC=gfortran
+fghij dev-cpp/eigen-3.0.0-r1 CXX=g++ CXXFLAGS='-O2'
+#klmno dev-cpp/eigen-3.0.0-r1 CXX=icpc CXXFLAGS='-O3'
+#pqrst sci-libs/blas-reference-3.3.1-r1 FC=ifort

diff --git a/btl/libs/BLAS/cblas_interface_impl.hh b/btl/libs/BLAS/cblas_interface_impl.hh
new file mode 100644
index 0000000..e481c57
--- /dev/null
+++ b/btl/libs/BLAS/cblas_interface_impl.hh
@@ -0,0 +1,79 @@
+
+#define BLAS_FUNC(NAME) CAT(cblas_,CAT(SCALAR_PREFIX,NAME))
+
+template<> class blas_interface<SCALAR> : public c_interface_base<SCALAR>
+{
+
+public :
+  
+  static SCALAR fone;
+  static SCALAR fzero;
+
+  static inline std::string name()
+  {
+    return MAKE_STRING(CBLASNAME);
+  }
+
+  static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+    BLAS_FUNC(gemv)(CblasRowMajor,CblasNoTrans,N,N,fone,A,N,B,intone,fzero,X,intone);
+  }
+
+  static inline void symv(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+    BLAS_FUNC(symv)(CblasRowMajor,CblasLower,N,fone,A,N,B,intone,fzero,X,intone);
+  }
+
+  static inline void syr2(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+    BLAS_FUNC(syr2)(CblasRowMajor,CblasLower,N,fone,B,intone,X,intone,A,N);
+  }
+
+  static inline void ger(gene_matrix & A, gene_vector & X, gene_vector & Y, int N){
+    BLAS_FUNC(ger)(CblasRowMajor,N,N,fone,X,intone,Y,intone,A,N);
+  }
+
+  static inline void rot(gene_vector & A,  gene_vector & B, SCALAR c, SCALAR s, int N){
+    BLAS_FUNC(rot)(N,A,intone,B,intone,c,s);
+  }
+
+  static inline void atv_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
+    BLAS_FUNC(gemv)(CblasRowMajor,CblasTrans,N,N,fone,A,N,B,intone,fzero,X,intone);
+  }
+
+  static inline void matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+    BLAS_FUNC(gemm)(CblasRowMajor,CblasNoTrans,CblasNoTrans,N,N,N,fone,A,N,B,N,fzero,X,N);
+  }
+
+  static inline void transposed_matrix_matrix_product(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+    BLAS_FUNC(gemm)(CblasRowMajor,CblasTrans,CblasNoTrans,N,N,N,fone,A,N,B,N,fzero,X,N);
+  }
+
+  static inline void aat_product(gene_matrix & A, gene_matrix & X, int N){
+    BLAS_FUNC(syrk)(CblasRowMajor,CblasLower,CblasNoTrans,N,N,fone,A,N,fzero,X,N);
+  }
+
+  static inline void axpy(SCALAR coef, const gene_vector & X, gene_vector & Y, int N){
+    BLAS_FUNC(axpy)(N,coef,X,intone,Y,intone);
+  }
+
+  static inline void axpby(SCALAR a, const gene_vector & X, SCALAR b, gene_vector & Y, int N){
+    BLAS_FUNC(scal)(N,b,Y,intone);
+    BLAS_FUNC(axpy)(N,a,X,intone,Y,intone);
+  }
+
+  static inline void trisolve_lower(const gene_matrix & L, const gene_vector& B, gene_vector & X, int N){
+    BLAS_FUNC(copy)(N, B, intone, X, intone);
+    BLAS_FUNC(trsv)(CblasRowMajor,CblasLower, CblasNoTrans, CblasNonUnit, N, L, N, X, intone);
+  }
+
+  static inline void trisolve_lower_matrix(const gene_matrix & L, const gene_matrix& B, gene_matrix & X, int N){
+    BLAS_FUNC(copy)(N, B, intone, X, intone);
+    BLAS_FUNC(trsm)(CblasRowMajor,CblasRight, CblasLower, CblasNoTrans, CblasNonUnit, N, N, fone, L, N, X, N);
+  }
+
+  static inline void trmm(gene_matrix & A, gene_matrix & B, gene_matrix & X, int N){
+    BLAS_FUNC(trmm)(CblasRowMajor,CblasLeft, CblasLower, CblasNoTrans,CblasNonUnit, N,N,fone,A,N,B,N);
+  }
+
+};
+
+SCALAR blas_interface<SCALAR>::fone = SCALAR(1);
+SCALAR blas_interface<SCALAR>::fzero = SCALAR(0);

diff --git a/cblas.py b/cblas.py
new file mode 100644
index 0000000..c3140bd
--- /dev/null
+++ b/cblas.py
@@ -0,0 +1,20 @@
+import os, blasbase
+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] != '_']
+          
+    def _get_flags(self, root, impl, libdir):
+        # Retrieve pkgconfig settings and map the directories to the new root
+        path = \
+          "%s/etc/env.d/alternatives/cblas/%s/%s/pkgconfig" % (root,impl,libdir)
+        pkgconf = sp.Popen('pkg-config --libs --cflags cblas', shell=True, \
+          stdout=sp.PIPE, env={'PKG_CONFIG_PATH':path}).communicate()[0]
+        pkgconf = pkgconf.replace('-L/', '-L'+root+'/')
+        pkgconf = pkgconf.replace('-I/', '-I'+root+'/')
+        return pkgconf + " -DCBLAS_INTERFACE"
+
+del blasbase

diff --git a/cblastests.in b/cblastests.in
new file mode 100644
index 0000000..c1b41ea
--- /dev/null
+++ b/cblastests.in
@@ -0,0 +1,2 @@
+gsl-gcc gsl-1.15-r1 CC=gcc CFLAGS=-O2
+gsl-icc gsl-1.15-r1 CC=gcc CFLAGS=-O3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-09 10:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-09  0:43 [gentoo-commits] proj/auto-numerical-bench:master commit in: /, btl/libs/BLAS/ Andrea Arteaga
  -- strict thread matches above, loose matches on Subject: below --
2011-06-09 10:51 Andrea Arteaga
2011-06-07 23:14 Andrea Arteaga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox