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

numpy-svn@scip... numpy-svn@scip...
Tue Nov 6 00:19:53 CST 2007


Author: cdavid
Date: 2007-11-06 00:19:44 -0600 (Tue, 06 Nov 2007)
New Revision: 4399

Modified:
   branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
   branches/numpy.scons/numpy/distutils/scons/checkers/support.py
   branches/numpy.scons/numpy/scons_fake/checkers/SConstruct
   branches/numpy.scons/test.sh
Log:
CBLAS and LAPACK checkers are refactored to use ConfigOpts

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-06 04:39:41 UTC (rev 4398)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-06 06:19:44 UTC (rev 4399)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Tue Nov 06 01:00 PM 2007 J
+# Last Change: Tue Nov 06 02:00 PM 2007 J
 
 # Module for custom, common checkers for numpy (and scipy)
 import sys
@@ -17,6 +17,9 @@
 from perflib import CheckMKL, CheckATLAS, CheckSunperf, CheckAccelerate
 from support import check_include_and_run
 
+# XXX: many perlib can be used from both C and F (Atlas being a notable
+# 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):
     """This checker tries to find optimized library for cblas.
 
@@ -71,7 +74,7 @@
             st, res = CheckMKL(context, autoadd)
             if st:
                 st = check_include_and_run(context, 'CBLAS (MKL)', res.cfgopts,
-                                           [], cblas_src, autoadd)
+                                           ['mkl.h'], cblas_src, autoadd)
                 if st:
                     add_info(env, 'cblas', res)
                 return st
@@ -98,6 +101,14 @@
             return 0
 
 def CheckLAPACK(context, autoadd = 1):
+    """This checker tries to find optimized library for lapack.
+
+    This test is pretty strong: it first detects an optimized library, and then
+    tests that a simple cblas program can be run using this lib.
+    
+    It looks for the following libs:
+        - Mac OS X: Accelerate, and then vecLib.
+        - Others: MKL, then ATLAS."""
     env = context.env
 
     # If section lapack is in site.cfg, use those options. Otherwise, use default
@@ -112,6 +123,7 @@
             import warnings
             warning.warn('FIXME: LAPACK checks not implemented yet on win32')
             return 0
+
         if sys.platform == 'darwin':
             st, opts = CheckAccelerate(context, autoadd)
             if st:
@@ -125,7 +137,7 @@
                 return st
 
         else:
-            # Get fortran stuff
+            # Get fortran stuff (See XXX at the top on F77 vs C)
             if not env.has_key('F77_NAME_MANGLER'):
                 if not CheckF77Mangling(context):
                     return 0
@@ -133,41 +145,28 @@
                 if not CheckF77Clib(context):
                     return 0
 
-            # XXX: all the code below is a mess, refactor it with new code from
-            # support module.
-
             # Get the mangled name of our test function
             sgesv_string = env['F77_NAME_MANGLER']('sgesv')
             test_src = lapack_sgesv % sgesv_string
 
             # Check MKL
-            st, opts = CheckMKL(context, autoadd = 1)
+            st, res = CheckMKL(context, autoadd)
             if st:
-                fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
-                fdict['LIBS'].append('lapack')
-                if env.has_key('LIBS'):
-                    fdict['LIBS'].extend(context.env['LIBS'])
-                if env.has_key('LIBPATH'):
-                    fdict['LIBPATH'].extend(context.env['LIBPATH'])
-                st = check_include_and_run(context, 'LAPACK (MKL)', [], [],
-                        test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
+                # Intel recommends linking lapack before mkl, guide and co
+                res.cfgopts['libs'].insert(0, 'lapack')
+                st = check_include_and_run(context, 'LAPACK (MKL)', res.cfgopts,
+                                           [], test_src, autoadd)
                 if st:
-                    add_info(env, 'lapack', opts)
+                    add_info(env, 'lapack', res)
                 return st
 
             # Check ATLAS
             st, opts = CheckATLAS(context, autoadd = 1)
             if st:
-                fdict = env.ParseFlags(context.env['F77_LDFLAGS'])
-                fdict['LIBS'].append('lapack')
-                if env.has_key('LIBS'):
-                    fdict['LIBS'].extend(context.env['LIBS'])
-                if env.has_key('LIBPATH'):
-                    fdict['LIBPATH'].extend(context.env['LIBPATH'])
-                st = check_include_and_run(context, 'LAPACK (ATLAS)', [], [],
-                        test_src, fdict['LIBS'], fdict['LIBPATH'], [], [], autoadd = 1)
+                st = check_include_and_run(context, 'LAPACK (ATLAS)', res.cfgopts,
+                                           [], test_src, autoadd)
                 if st:
-                    add_info(env, 'lapack', opts)
+                    add_info(env, 'lapack', res)
                 # XXX: Check complete LAPACK or not. (Checking for not
                 # implemented lapack symbols ?)
                 return st

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/support.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-11-06 04:39:41 UTC (rev 4398)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/support.py	2007-11-06 06:19:44 UTC (rev 4399)
@@ -200,14 +200,12 @@
     #------------------------------
     saved = save_and_set(env, opts)
     try:
-        # XXX: reenable this
-        ## HACK: we add libpath and libs at the end of the source as a comment, to
-        ## add dependency of the check on those.
-        #src = '\n'.join(['#include <%s>' % h for h in headers] +\
-        #                [run_src, '#if 0', '%s' % libpath, 
-        #                 '%s' % headers, '%s' % libs, '#endif'])
-        ret = context.TryRun(src, '.c')
-    except:
+        # HACK: we add libpath and libs at the end of the source as a comment, to
+        # add dependency of the check on those.
+        src = '\n'.join([r'#include <%s>' % h for h in headers] +\
+                        [run_src, r'#if  0', r'%s' % str(opts), r'#endif', '\n'])
+        ret, out = context.TryRun(src, '.c')
+    finally:
         if (not ret or not autoadd):
             # If test failed or autoadd is disabled, restore everything
             restore(env, saved)

Modified: branches/numpy.scons/numpy/scons_fake/checkers/SConstruct
===================================================================
--- branches/numpy.scons/numpy/scons_fake/checkers/SConstruct	2007-11-06 04:39:41 UTC (rev 4398)
+++ branches/numpy.scons/numpy/scons_fake/checkers/SConstruct	2007-11-06 06:19:44 UTC (rev 4399)
@@ -2,7 +2,7 @@
 from numpy.distutils.scons import GetNumpyEnvironment
 from numpy.distutils.scons.checkers.perflib import \
         CheckATLAS, CheckAccelerate, CheckMKL, CheckSunperf
-from numpy.distutils.scons.checkers.custom_checkers import CheckCBLAS
+from numpy.distutils.scons.checkers.custom_checkers import CheckCBLAS, CheckLAPACK
 
 env = GetNumpyEnvironment(ARGUMENTS)
 
@@ -18,23 +18,17 @@
     'CheckMKL' : CheckMKL,
     'CheckAccelerate' : CheckAccelerate,
     'CheckCBLAS' : CheckCBLAS,
+    'CheckLAPACK' : CheckLAPACK,
     'CheckSunperf' : CheckSunperf})
 
 do_check = 1
 if do_check:
     st, opts = config.CheckATLAS(autoadd = 0)
-    if st:
-        print opts
     st, opts = config.CheckMKL(autoadd = 0)
-    if st:
-        print opts
     st, opts = config.CheckAccelerate(autoadd = 0)
-    if st:
-        print opts
     st, opts = config.CheckSunperf(autoadd = 0)
-    if st:
-        print opts
     st = config.CheckCBLAS(autoadd = 0)
+    st = config.CheckLAPACK(autoadd = 0)
 
     if env.has_key('LIBS'):
         print "LIBS of env is %s" % env.Dump('LIBS')

Modified: branches/numpy.scons/test.sh
===================================================================
--- branches/numpy.scons/test.sh	2007-11-06 04:39:41 UTC (rev 4398)
+++ branches/numpy.scons/test.sh	2007-11-06 06:19:44 UTC (rev 4399)
@@ -1,5 +1,5 @@
 PREFIX=$PWD
 rm -rf $PREFIX/build
 rm -rf $PREFIX/tmp
-MKL=None python setup.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)")
+python setup.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()")



More information about the Numpy-svn mailing list