public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Andrea Arteaga" <andyspiros@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/auto-numerical-bench:master commit in: /
Date: Wed, 15 Jun 2011 12:56:19 +0000 (UTC)	[thread overview]
Message-ID: <bb92ba7dd4ebb313038d5ea0452c06787d3998c0.spiros@gentoo> (raw)

commit:     bb92ba7dd4ebb313038d5ea0452c06787d3998c0
Author:     spiros <andyspiros <AT> gmail <DOT> com>
AuthorDate: Wed Jun 15 12:55:43 2011 +0000
Commit:     Andrea Arteaga <andyspiros <AT> gmail <DOT> com>
CommitDate: Wed Jun 15 12:55:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/auto-numerical-bench.git;a=commit;h=bb92ba7d

Introduced LAPACK, cleanup of btlbase (former blasbase). Some changes
to main.

---
 blas.py                   |   70 ++++++++++++++++++++++++-----
 blasbase.py => btlbase.py |  109 ++++++++++++++++++++++++---------------------
 cblas.py                  |   72 ++++++++++++++++++++++++-----
 lapack.py                 |   56 +++++++++++++++++++++++
 lapacktests.in            |    2 +
 main.py                   |   26 +++++-----
 6 files changed, 246 insertions(+), 89 deletions(-)

diff --git a/blas.py b/blas.py
index b9d6ed8..52bb221 100644
--- a/blas.py
+++ b/blas.py
@@ -1,23 +1,69 @@
-import os, blasbase
+import os, btlbase
 import subprocess as sp
+import shlex
 
-class Module(blasbase.ModuleBase): 
+class Module(btlbase.BTLBase):
+    def _initialize(self):
+        self.libname = "blas"
+        self.avail1 = ['axpy', 'axpby', 'rot']
+        self.avail2 = ['matrix_vector','atv','symv','syr2','ger',
+          'trisolve_vector']
+        self.avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm']
+        self.avail = self.avail1 + self.avail2 + self.avail3
+    
+    def _parse_args(self, args):     
+        # Parse arguments
+        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 self.avail:
+                tests.append(i)
+                continue
+            raise Exception("Argument not recognized: " + i)
+        
+        # Sort tests
+        self.tests = [i for i in self.avail if i in tests]
+        
+        # If no test is specified, then choose four standard tests
+        if len(self.tests) == 0:
+            self.tests = ['axpy', 'matrix_vector', \
+              'trisolve_vector', 'matrix_matrix']
+    
     @staticmethod
-    def get_impls(root):
-        output = sp.Popen(
-          ['eselect', '--no-color', '--brief', 'blas', 'list'],
-          env={'ROOT' : root}, stdout=sp.PIPE
-        ).communicate()[0]
-        return output.strip().split('\n')
+    def _btl_source():
+        return "/libs/BLAS/main.cpp"
+    
+    @staticmethod
+    def _btl_includes():
+        return ["/libs/BLAS"]
+    
+    def _btl_defines(self):
+        return ["CBLASNAME=" + self.libname, "BLAS_INTERFACE"]
            
     def _get_flags(self, root, impl, libdir):
         # Retrieve pkgconfig settings and map the directories to the new root
-        path = \
-          "%s/etc/env.d/alternatives/blas/%s/%s/pkgconfig" % (root,impl,libdir)
+        path = "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \
+          (root, self.libname, impl, libdir)
         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+'/')
-        return pkgconf + " -DBLAS_INTERFACE"
+        return shlex.split(pkgconf)
+        
+        
+    def get_impls(self, root):
+        output = sp.Popen(
+          ['eselect', '--no-color', '--brief', self.libname, 'list'],
+          env={'ROOT' : root}, stdout=sp.PIPE
+        ).communicate()[0]
+        return output.strip().split('\n')
 
-del blasbase
+del btlbase

diff --git a/blasbase.py b/btlbase.py
similarity index 66%
rename from blasbase.py
rename to btlbase.py
index 36413c7..ecb74d9 100644
--- a/blasbase.py
+++ b/btlbase.py
@@ -5,62 +5,49 @@ import subprocess as sp
 try:
     import matplotlib.pyplot as plt
     import numpy as np
+    with_images = True
 except ImportError:
     sys.stderr.write('Error: matplotlib and numpy are needed' + \
       'in order to generate the reports!\n')
-    sys.stderr.write('Continue anyway.\n')    
+    sys.stderr.write('Continue anyway.\n\n')    
+    with_images = False
     
 import btlutils as btl
 
 run_cmd = lambda c : sp.Popen(c, stdout=sp.PIPE).communicate()[0]
 
-class ModuleBase:
+class BTLBase:
     def __init__(self, Print, libdir, args):
         self.Print = Print
         self.libdir = libdir
         self.summary = False
         self.summary_only = False
         
-        avail1 = ['axpy', 'axpby', 'rot']
-        avail2 = ['matrix_vector','atv','symv','syr2','ger','trisolve_vector']
-        avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm']
+        self._initialize()
         
-        tests = []
+        passargs = []
         for i in args:
             if i == '-S':
                 self.summary_only = True
                 continue
-            if i == '-s':
+            elif i == '-s':
                 self.summary = True
                 continue
-            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]
+            else:
+                passargs += [i]
         
-        if len(self.tests) == 0:
-            self.tests = ['axpy', 'matrix_vector', \
-              'trisolve_vector', 'matrix_matrix']
+        self._parse_args(passargs)
         
           
-    def run_test(self, root, impl, testdir):
+    def run_test(self, root, impl, testdir, env):
+        # Convenient renames and definition of report files 
         Print = self.Print
         libdir = self.libdir
-        name = 'blas'
+        name = self.libname
         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
+        # Create dir. If all results already exist use them and do not perform
+        # the tests, otherwise remove every old results.
         runtests = False
         if os.path.exists(testdir):
             runtests = not all([os.path.exists(i) for i in files])
@@ -77,31 +64,44 @@ class ModuleBase:
         
         for i in files:
             if os.path.exists(i): os.remove(i)
+            
+        # Prepare the environment
+        if env.has_key('LIBRARY_PATH'):
+            env['LIBRARY_PATH'] = root+libdir + ":" + env['LIBRARY_PATH']
+        else:
+            env['LIBRARY_PATH'] = root+libdir
+            
+        if env.has_key('INCLUDE_PATH'):
+            env['INCLUDE_PATH'] = root+"/usr/include" +":"+ env['INCLUDE_PATH']
+        else:
+            env['INCLUDE_PATH'] = root+"/usr/include"
+            
+        if env.has_key('LD_LIBRARY_PATH'):
+            env['LD_LIBRARY_PATH'] = root+libdir + ":" + env['LD_LIBRARY_PATH']
+        else:
+            env['LD_LIBRARY_PATH'] = root+libdir
         
-        # Setup environment for testing
+        # Backup the environment
         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
+        for k in env.keys():
+            oldenv[k] = \
+              (os.environ.has_key(k) and (os.environ[k],) or (None,))[0]
+        
+        # Set the environment
+        for k,v in env.items():
+            os.environ[k] = v
         
         # Compile
+        btldir = 'btl/'
         returncode, compilecl = btl.btlcompile(
           exe = testdir + "/test",
-          source = "btl/libs/BLAS/main.cpp",
-          btldir = 'btl/',
-          includes = ['btl/libs/BLAS'],
-          defines = ["CBLASNAME=" + name],
+          source = btldir + self._btl_source(),
+          btldir = btldir,
+          includes = [btldir+d for d in self._btl_includes()],
+          defines = self._btl_defines(),
           libs = [],
           libdirs = [root+libdir],
-          other = [self._get_flags(root, impl, libdir)]
+          other = self._get_flags(root, impl, libdir)
         )
         if returncode != 0:
             raise Exception("Compilation failed: " + compilecl)
@@ -132,15 +132,20 @@ class ModuleBase:
         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]
+        # Restore the old environment
+        for k in env.keys():
+            if oldenv[k] != None:
+                os.environ[k] = oldenv[k]
+            elif os.environ.has_key(k):
+                del os.environ[k]
         return results
     
     def save_results(self, results, figdir):
+        if not with_images:
+            self.Print("Report generation skipped - missing libraries")
+            return
+    
+        # Re-order the result dictionary
         newresults = {}
         for test in self.tests:
             newresults[test] = {}
@@ -149,6 +154,7 @@ class ModuleBase:
                 resdat = results[nameimpl][test]
                 newresults[test][nameimplstr] = resdat       
         
+        # Generate summary - a single image with all plots
         if self.summary or self.summary_only:
             # Save summary figure
             sprows = (len(self.tests)+1)/2
@@ -165,6 +171,7 @@ class ModuleBase:
             plt.savefig(fname, format='png')
             self.Print('Summary figure saved: ' + fname)
                 
+        # Generate plots
         if not self.summary_only:
             for test in self.tests:
                 plt.figure(figsize=(12,9), dpi=300)

diff --git a/cblas.py b/cblas.py
index ad47c65..c3d0342 100644
--- a/cblas.py
+++ b/cblas.py
@@ -1,23 +1,69 @@
-import os, blasbase
+import os, btlbase
 import subprocess as sp
+import shlex
 
-class Module(blasbase.ModuleBase):
+class Module(btlbase.BTLBase):
+    def _initialize(self):
+        self.libname = "cblas"
+        self.avail1 = ['axpy', 'axpby', 'rot']
+        self.avail2 = ['matrix_vector','atv','symv','syr2','ger',
+          'trisolve_vector']
+        self.avail3 = ['matrix_matrix', 'aat', 'trisolve_matrix', 'trmm']
+        self.avail = self.avail1 + self.avail2 + self.avail3
+    
+    def _parse_args(self, args):     
+        # Parse arguments
+        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 self.avail:
+                tests.append(i)
+                continue
+            raise Exception("Argument not recognized: " + i)
+        
+        # Sort tests
+        self.tests = [i for i in self.avail if i in tests]
+        
+        # If no test is specified, then choose four standard tests
+        if len(self.tests) == 0:
+            self.tests = ['axpy', 'matrix_vector', \
+              'trisolve_vector', 'matrix_matrix']
+    
     @staticmethod
-    def get_impls(root):
-        output = sp.Popen(
-          ['eselect', '--no-color', '--brief', 'cblas', 'list'],
-          env={'ROOT' : root}, stdout=sp.PIPE
-        ).communicate()[0]
-        return output.strip().split('\n')
-          
+    def _btl_source():
+        return "/libs/BLAS/main.cpp"
+    
+    @staticmethod
+    def _btl_includes():
+        return ["/libs/BLAS"]
+    
+    def _btl_defines(self):
+        return ["CBLASNAME=" + self.libname, "CBLAS_INTERFACE"]
+           
     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)
+        path = "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \
+          (root, self.libname, 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"
+        return shlex.split(pkgconf)
+        
+        
+    def get_impls(self, root):
+        output = sp.Popen(
+          ['eselect', '--no-color', '--brief', self.libname, 'list'],
+          env={'ROOT' : root}, stdout=sp.PIPE
+        ).communicate()[0]
+        return output.strip().split('\n')
 
-del blasbase
+del btlbase

diff --git a/lapack.py b/lapack.py
new file mode 100644
index 0000000..1d2f3cb
--- /dev/null
+++ b/lapack.py
@@ -0,0 +1,56 @@
+import os, blasbase
+import subprocess as sp
+import shlex
+
+class Module(blasbase.BTLBase):
+    def _initialize(self):
+        self.libname = "lapack"
+        self.avail = ['general_solve', 'least_squares', 'lu_decomp', \
+          'cholesky', 'symm_ev']
+    
+    def _parse_args(self, args):     
+        # Parse arguments
+        tests = []
+        for i in args:
+            if i in self.avail:
+                tests.append(i)
+                continue
+            raise Exception("Argument not recognized: " + i)
+        
+        # Sort tests
+        self.tests = [i for i in self.avail if i in tests]
+        
+        # If no test is specified, run everything
+        if len(self.tests) == 0:
+            self.tests = self.avail
+    
+    @staticmethod
+    def _btl_source():
+        return "/libs/LAPACK/main.cpp"
+    
+    @staticmethod
+    def _btl_includes():
+        return ["/libs/BLAS", "libs/LAPACK"]
+    
+    def _btl_defines(self):
+        return ["LAPACKNAME=" + self.libname]
+           
+    def _get_flags(self, root, impl, libdir):
+        # Retrieve pkgconfig settings and map the directories to the new root
+        path = "%s/etc/env.d/alternatives/%s/%s/%s/pkgconfig" % \
+          (root, self.libname, impl, libdir)
+        pkgconf = sp.Popen('pkg-config --libs --cflags lapack', 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 shlex.split(pkgconf)
+        
+        
+    def get_impls(self, root):
+        output = sp.Popen(
+          ['eselect', '--no-color', '--brief', self.libname, 'list'],
+          env={'ROOT' : root}, stdout=sp.PIPE
+        ).communicate()[0]
+        return output.strip().split('\n')
+
+del blasbase

diff --git a/lapacktests.in b/lapacktests.in
new file mode 100644
index 0000000..1dfcfb6
--- /dev/null
+++ b/lapacktests.in
@@ -0,0 +1,2 @@
+reference-O2 sci-libs/lapack-reference-3.3.1-r1 FFLAGS=-O2
+reference-O3 sci-libs/lapack-reference-3.3.1-r1 FFLAGS=-O3

diff --git a/main.py b/main.py
index feeef86..8933834 100644
--- a/main.py
+++ b/main.py
@@ -80,11 +80,6 @@ try:
 except ImportError, IndexError:
     print_usage()
     exit(1)
-    
-#tmp = __import__(sys.argv[1], fromlist = ['Module'])
-#mod = tmp.Module(Print, libdir, sys.argv[3:])
-#del tmp
-#testsfname = sys.argv[2]
 
 
 """
@@ -102,22 +97,22 @@ After the tests every successful tested item will contain the item "result",
 which can contain any type of data and will be used for the final report.
 """
 #tests = {
-#    "abcde" : {
+#    "reference-gfortran" : {
 #        "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'),
 #        "env" : {'FC' : 'gfortran'}
 #    },
 #         
-#    "fghij" : {
+#    "eigen-gcc" : {
 #        "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'),
-#        "env" : {'CXX' : 'gcc', 'CXXFLAGS' : '-O2'}
+#        "env" : {'CXX' : 'g++', 'CXXFLAGS' : '-O2'}
 #    },
 #         
-#    "klmno" : {
+#    "eigen-icc" : {
 #        "package" : ('dev-cpp', 'eigen', '3.0.0', 'r1'),
 #        "env" : {'CXX' : 'icc', 'CXXFLAGS' : '-O3'}
 #    },
 #
-#    "pqrst" : {
+#    "reference-ifort" : {
 #        "package" : ('sci-libs', 'blas-reference', '3.3.1', 'r1'),
 #        "env" : {'FC' : 'ifort'}
 #    }
@@ -136,13 +131,17 @@ dictionary; the line has to contain:
 input = file(testsfname).read()
 tests = tests_from_input(input)
 
+# Write summary
+print 60*'='
 print "The following tests will be run:"
 for tname, ttest in tests.items():
-    print "Tests: " + tname
+    print "Test: " + tname
     print " - Package: " + "%s/%s-%s-%s" % ttest['package']
     print " - Environment: " + \
       ' '.join([n+'="'+v+'"' for n,v in ttest['env'].items()])
     print
+print 60*'='
+print
 
 for tn,(name,test) in enumerate(tests.items(),1):
     Print("BEGIN TEST %i - %s" % (tn, name))
@@ -187,9 +186,10 @@ for tn,(name,test) in enumerate(tests.items(),1):
         Print("Testing " + impl)
         Print.down()
         
-        # Compile/link the test suite against the library
+        # Run the test suite
         testdir = "%s/%s/%s" % (testsdir, name, impl)
-        test['results'][impl] = mod.run_test(root, impl, testdir)
+        test['results'][impl] = \
+          mod.run_test(root=root, impl=impl, testdir=testdir, env=test['env'])
         Print.up()
             
     Print.up()



             reply	other threads:[~2011-06-15 12:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 12:56 Andrea Arteaga [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-09-02 11:41 [gentoo-commits] proj/auto-numerical-bench:master commit in: / Andrea Arteaga
2012-08-11 18:00 Andrea Arteaga
2012-08-04  1:11 Andrea Arteaga
2012-04-09 22:58 Andrea Arteaga
2012-03-05 15:48 Andrea Arteaga
2012-02-28 19:20 Andrea Arteaga
2012-02-24 17:22 Andrea Arteaga
2011-08-22 18:15 Andrea Arteaga
2011-08-16 23:38 Andrea Arteaga
2011-08-15 21:57 Andrea Arteaga
2011-08-14 12:59 Andrea Arteaga
2011-08-14 12:35 Andrea Arteaga
2011-08-12 22:56 Andrea Arteaga
2011-08-09  0:00 Andrea Arteaga
2011-08-09  0:00 Andrea Arteaga
2011-07-17  0:21 Andrea Arteaga
2011-07-13 21:48 Andrea Arteaga
2011-06-15 23:25 Andrea Arteaga
2011-06-13 23:53 Andrea Arteaga
2011-06-13 14:12 Andrea Arteaga
2011-06-10  1:02 Andrea Arteaga
2011-06-10  0:52 Andrea Arteaga
2011-06-06 20:05 Andrea Arteaga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb92ba7dd4ebb313038d5ea0452c06787d3998c0.spiros@gentoo \
    --to=andyspiros@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox