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: /, btl/libs/BLAS/
Date: Tue,  7 Jun 2011 23:14:51 +0000 (UTC)	[thread overview]
Message-ID: <0321f710f0a735c6536369d7d2b4dea20a5f6d6a.spiros@gentoo> (raw)

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



             reply	other threads:[~2011-06-07 23:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 23:14 Andrea Arteaga [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-06-09  0:43 [gentoo-commits] proj/auto-numerical-bench:master commit in: /, btl/libs/BLAS/ Andrea Arteaga
2011-06-09 10:51 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=0321f710f0a735c6536369d7d2b4dea20a5f6d6a.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