[Numpy-svn] r4490 - in branches/numpy.scons: . numpy/distutils/scons numpy/distutils/scons/checkers numpy/scons_fake/checkers

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Nov 22 07:34:06 EST 2007


Author: cdavid
Date: 2007-11-22 06:33:55 -0600 (Thu, 22 Nov 2007)
New Revision: 4490

Modified:
   branches/numpy.scons/numpy/distutils/scons/__init__.py
   branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
   branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
   branches/numpy.scons/numpy/scons_fake/checkers/SConstruct
   branches/numpy.scons/test.sh
Log:
More work on perflib version checkers: implement version getters for atlas/mkl

Modified: branches/numpy.scons/numpy/distutils/scons/__init__.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-11-22 08:34:00 UTC (rev 4489)
+++ branches/numpy.scons/numpy/distutils/scons/__init__.py	2007-11-22 12:33:55 UTC (rev 4490)
@@ -6,6 +6,7 @@
 
 from checkers import CheckCBLAS, CheckCLAPACK, CheckF77BLAS, CheckF77LAPACK, \
                      IsMKL, IsATLAS, IsVeclib, IsAccelerate, IsSunperf
+from checkers.perflib import GetATLASVersion, GetMKLVersion
 
 from fortran_scons import CheckF77Verbose, CheckF77Clib, CheckF77Mangling
 

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-22 08:34:00 UTC (rev 4489)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-22 12:33:55 UTC (rev 4490)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Thu Nov 22 04:00 PM 2007 J
+# Last Change: Thu Nov 22 05:00 PM 2007 J
 
 # Module for custom, common checkers for numpy (and scipy)
 import sys
@@ -22,13 +22,13 @@
 # exception for LAPACK). So shall we make the difference between BLAS, CBLAS,
 # LAPACK and CLAPACK ? How to test for fortran ?
 
-def CheckCBLAS(context, autoadd = 1):
+def CheckCBLAS(context, autoadd = 1, check_version = 0):
     """This checker tries to find optimized library for cblas."""
     libname = 'cblas'
     env = context.env
 
     def check(func, name, suplibs):
-        st, res = func(context, autoadd)
+        st, res = func(context, autoadd, check_version)
         if st:
             for lib in suplibs:
                 res.cfgopts['libs'].insert(0, lib)
@@ -77,7 +77,7 @@
     add_info(env, libname, None)
     return 0
 
-def CheckF77BLAS(context, autoadd = 1):
+def CheckF77BLAS(context, autoadd = 1, check_version = 0):
     """This checker tries to find optimized library for blas (fortran F77)."""
     libname = 'blas'
     env = context.env
@@ -92,7 +92,7 @@
     test_src = c_sgemm2 % {'func' : func_name}
 
     def check(func, name, suplibs):
-        st, res = func(context, autoadd)
+        st, res = func(context, autoadd, check_version)
         if st:
             for lib in suplibs:
                 res.cfgopts['libs'].insert(0, lib)
@@ -143,7 +143,7 @@
     add_info(env, libname, None)
     return 0
 
-def CheckF77LAPACK(context, autoadd = 1):
+def CheckF77LAPACK(context, autoadd = 1, check_version = 0):
     """This checker tries to find optimized library for F77 lapack.
 
     This test is pretty strong: it first detects an optimized library, and then
@@ -167,7 +167,7 @@
     def check(func, name, suplibs):
         # func is the perflib checker, name the printed name for the check, and
         # suplibs a list of libraries to link in addition.
-        st, res = func(context, autoadd)
+        st, res = func(context, autoadd, check_version)
         if st:
             for lib in suplibs:
                 res.cfgopts['libs'].insert(0, lib)
@@ -226,7 +226,7 @@
     add_info(env, libname, None)
     return 0
 
-def CheckCLAPACK(context, autoadd = 1):
+def CheckCLAPACK(context, autoadd = 1, check_version = 0):
     """This checker tries to find optimized library for lapack.
 
     This test is pretty strong: it first detects an optimized library, and then

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-11-22 08:34:00 UTC (rev 4489)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/perflib.py	2007-11-22 12:33:55 UTC (rev 4490)
@@ -93,6 +93,24 @@
     def get_func(self):
         return self.func
 
+class GetVersionFactory:
+    def __init__(self, name):
+        """Name should be one key of _CONFIG."""
+        try:
+            _CONFIG[name]
+        except KeyError, e:
+            raise RuntimeError("name %s is unknown")
+
+        def f(env, libname):
+            if env['NUMPY_PKG_CONFIG'][libname] is None:
+                return 'No version info'
+            else:
+                return env['NUMPY_PKG_CONFIG'][libname].version
+        self.func = f
+
+    def get_func(self):
+        return self.func
+
 #------------------------
 # Generic functionalities
 #------------------------
@@ -166,7 +184,7 @@
     # Check version if requested
     if check_version:
         if version_checker:
-            vst, v = version_checker(env, opts)
+            vst, v = version_checker(context, opts)
             if vst:
                 version = v
             else:
@@ -182,7 +200,8 @@
 #--------------
 # MKL checker
 #--------------
-def _mkl_version_checker(env, opts):
+def _mkl_version_checker(context, opts):
+    env = context.env
     version_code = r"""
 #include <stdio.h>
 #include <mkl.h>
@@ -207,8 +226,10 @@
     finally:
         restore(env, saved)
 
-    if vst and re.search(r'Full version: (\d+[.]\d+[.]\d+)', out):
-        version = m.group(1)
+    if vst:
+        m = re.search(r'Full version: (\d+[.]\d+[.]\d+)', out)
+        if m:
+            version = m.group(1)
     else:
         version = ''
 
@@ -221,11 +242,13 @@
                   cfg.funcs, check_version, _mkl_version_checker, autoadd)
 
 IsMKL = IsFactory('MKL').get_func()
+GetMKLVersion = GetVersionFactory('MKL').get_func()
 
 #---------------
 # ATLAS Checker
 #---------------
-def _atlas_version_checker(env, opts):
+def _atlas_version_checker(context, opts):
+    env = context.env
     version_code = """
 void ATL_buildinfo(void);
 int main(void) {
@@ -259,6 +282,7 @@
                   cfg.funcs, check_version, _atlas_version_checker, autoadd)
 
 IsATLAS = IsFactory('ATLAS').get_func()
+GetATLASVersion = GetVersionFactory('ATLAS').get_func()
 
 #------------------------------
 # Mac OS X Frameworks checkers

Modified: branches/numpy.scons/numpy/scons_fake/checkers/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/checkers/SConstruct	2007-11-22 08:34:00 UTC (rev 4489)
+++ branches/numpy.scons/numpy/scons_fake/checkers/SConstruct	2007-11-22 12:33:55 UTC (rev 4490)
@@ -1,7 +1,8 @@
 # vim:syntax=python
 from numpy.distutils.scons import GetNumpyEnvironment
 from numpy.distutils.scons.checkers.perflib import \
-        CheckATLAS, CheckAccelerate, CheckMKL, CheckSunperf
+        CheckATLAS, CheckAccelerate, CheckMKL, CheckSunperf,\
+        IsMKL, IsATLAS, IsAccelerate, GetATLASVersion
 from numpy.distutils.scons.checkers.custom_checkers import CheckCBLAS, \
         CheckCLAPACK, CheckF77BLAS, CheckF77LAPACK
 from numpy.distutils.scons import CheckF77Mangling
@@ -38,6 +39,11 @@
     st = config.CheckCLAPACK(autoadd = 0)
     st = config.CheckF77Mangling()
 
+    print "Is blas MKL ? %s" % IsMKL(env, 'blas')
+    print "Is cblas MKL ? %s" % IsMKL(env, 'cblas')
+    print "Is blas ATLAS ? %s" % IsATLAS(env, 'blas')
+    print "Is cblas ATLAS ? %s" % IsATLAS(env, 'cblas')
+
     if env.has_key('LIBS'):
         print "LIBS of env is %s" % env.Dump('LIBS')
     else:

Modified: branches/numpy.scons/test.sh
===================================================================
--- branches/numpy.scons/test.sh	2007-11-22 08:34:00 UTC (rev 4489)
+++ branches/numpy.scons/test.sh	2007-11-22 12:33:55 UTC (rev 4490)
@@ -4,15 +4,15 @@
 # MKL=None python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp
 # (cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()")
 
+PREFIX=$PWD
+rm -rf $PREFIX/build
+rm -rf $PREFIX/tmp
+ATLAS=None python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp
+(cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()")
+
 # PREFIX=$PWD
-# rm -rf $PREFIX/build
-# rm -rf $PREFIX/tmp
-# python setupscons.py scons --jobs=4 install --prefix=$PREFIX/tmp
-# (cd $PREFIX/tmp && PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python -c "import numpy; print numpy; numpy.test(level = 9999); numpy.show_config()")
-
-PREFIX=$PWD
-#rm -rf $PREFIX/build
-#rm -rf $PREFIX/tmp
-MKL=None python setupscons.py scons --jobs=4 --silent=2 install --prefix=$PREFIX/tmp
-(cd $PREFIX/tmp/lib/python2.5/site-packages/numpy/distutils/scons/tests/f2pyext/ && \
- PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python setup.py scons)
+# #rm -rf $PREFIX/build
+# #rm -rf $PREFIX/tmp
+# MKL=None python setupscons.py scons --jobs=4 --silent=2 install --prefix=$PREFIX/tmp
+# (cd $PREFIX/tmp/lib/python2.5/site-packages/numpy/distutils/scons/tests/f2pyext/ && \
+#  PYTHONPATH=$PREFIX/tmp/lib/python2.5/site-packages python setup.py scons)




More information about the Numpy-svn mailing list