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

numpy-svn@scip... numpy-svn@scip...
Tue Nov 6 01:58:52 CST 2007


Author: cdavid
Date: 2007-11-06 01:58:46 -0600 (Tue, 06 Nov 2007)
New Revision: 4400

Modified:
   branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
   branches/numpy.scons/numpy/distutils/scons/testcode_snippets.py
Log:
LAPACK and CBLAS checkers are now overridable by site.cfg

Modified: branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-06 06:19:44 UTC (rev 4399)
+++ branches/numpy.scons/numpy/distutils/scons/checkers/custom_checkers.py	2007-11-06 07:58:46 UTC (rev 4400)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Tue Nov 06 02:00 PM 2007 J
+# Last Change: Tue Nov 06 04:00 PM 2007 J
 
 # Module for custom, common checkers for numpy (and scipy)
 import sys
@@ -15,11 +15,12 @@
 from numpy.distutils.scons.configuration import add_info
 
 from perflib import CheckMKL, CheckATLAS, CheckSunperf, CheckAccelerate
-from support import check_include_and_run
+from support import check_include_and_run, ConfigOpts, ConfigRes
 
 # 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.
 
@@ -37,16 +38,13 @@
     siteconfig, cfgfiles = get_config()
     (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
     if found:
-        raise NotImplementedError("FIXME: siteconfig for cblas")
-        # XXX: adapt this to libperf refactor
-        headers = ['cblas.h']
-        linkflags = []
-        cflags = []
-        st = check_include_and_run(context, 'CBLAS', [], headers, cblas_src,
-                                      libs, libpath, linkflags, cflags, autoadd)
+        cfg = ConfigOpts(cpppath = cpppath, libs = libs, libpath = libpath,
+                         rpath = libpath)
+        st = check_include_and_run(context, 'CBLAS (from site.cfg) ', cfg,
+                                  [], cblas_src, autoadd)
         if st:
-            add_info(env, 'cblas', opt_info('cblas', site = 1))
-            return st
+            add_info(env, 'cblas', ConfigRes('cblas', cfg, found))
+        return st
     else:
         if sys.platform == 'darwin':
             st, res = CheckAccelerate(context, autoadd)
@@ -116,8 +114,25 @@
     siteconfig, cfgfiles = get_config()
     (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
     if found:
-        raise NotImplementedError("FIXME: siteconfig for lapack")
-        # XXX: adapt this to libperf refactor
+        cfg = ConfigOpts(cpppath = cpppath, libs = libs, libpath = libpath,
+                         rpath = libpath)
+
+        if not env.has_key('F77_NAME_MANGLER'):
+            if not CheckF77Mangling(context):
+                return 0
+        if not env.has_key('F77_LDFLAGS'):
+            if not CheckF77Clib(context):
+                return 0
+
+        # Get the mangled name of our test function
+        sgesv_string = env['F77_NAME_MANGLER']('sgesv')
+        test_src = lapack_sgesv % sgesv_string
+
+        st = check_include_and_run(context, 'LAPACK (from site.cfg) ', cfg,
+                                  [], test_src, autoadd)
+        if st:
+            add_info(env, 'lapack', ConfigRes('lapack', cfg, found))
+        return st
     else:
         if sys.platform == 'nt':
             import warnings
@@ -172,78 +187,3 @@
                 return st
 
     return 0
-
-def _my_try_link(context, src, libs, libpath, autoadd = 0):
-    """Try to link the given text in src with libs and libpath."""
-    env = context.env
-
-    oldLIBS = (env.has_key('LIBS') and deepcopy(env['LIBS'])) or []
-    oldLIBPATH = (env.has_key('LIBPATH') and deepcopy(env['LIBPATH'])) or []
-
-    ret = 0
-    try:
-        env.AppendUnique(LIBS = libs, LIBPATH = libpath)
-        ret = context.TryLink(src, '.c')
-    finally:
-        if not ret or not autoadd:
-            env.Replace(LIBS = oldLIBS, LIBPATH = oldLIBPATH)
-
-    return ret
-
-def CheckGenericBLAS(context, autoadd = 1, section = 'blas'):
-    """Check whether a BLAS library can be found.
-
-    Use site.cfg if found (section given by section argument)."""
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if not found:
-        libs.extend(['blas'])
-
-    env = context.env
-    # Get fortran mangling
-    if not env.has_key('F77_NAME_MANGLER'):
-        if not CheckF77Mangling(context):
-            return 0
-
-    test_func_name = env['F77_NAME_MANGLER']('dgemm')
-    src = get_func_link_src(test_func_name)
-
-    context.Message("Checking for Generic BLAS... ")
-
-    st =  _my_try_link(context, src, libs, libpath, autoadd)
-    if st:
-        env['F77_BLAS_LIBS'] = libs
-        env['F77_BLAS_LIBPATH'] = libpath
-
-    context.Result(st)
-
-    return st
-
-def CheckGenericLAPACK(context, autoadd = 1, section = 'lapack'):
-    """Check whether a LAPACK library can be found.
-
-    Use site.cfg if found (section given by section argument)."""
-    siteconfig, cfgfiles = get_config()
-    (cpppath, libs, libpath), found = get_config_from_section(siteconfig, section)
-    if not found:
-        libs.extend(['lapack'])
-
-    env = context.env
-    # Get fortran mangling
-    if not env.has_key('F77_NAME_MANGLER'):
-        if not CheckF77Mangling(context):
-            return 0
-
-    test_func_name = env['F77_NAME_MANGLER']('dpotri')
-    src = get_func_link_src(test_func_name)
-
-    context.Message("Checking for Generic LAPACK... ")
-
-    st =  _my_try_link(context, src, libs, libpath, autoadd)
-    if st:
-        env['F77_LAPACK_LIBS'] = libs
-        env['F77_LAPACK_LIBPATH'] = libpath
-
-    context.Result(st)
-
-    return st

Modified: branches/numpy.scons/numpy/distutils/scons/testcode_snippets.py
===================================================================
--- branches/numpy.scons/numpy/distutils/scons/testcode_snippets.py	2007-11-06 06:19:44 UTC (rev 4399)
+++ branches/numpy.scons/numpy/distutils/scons/testcode_snippets.py	2007-11-06 07:58:46 UTC (rev 4400)
@@ -1,5 +1,5 @@
 #! /usr/bin/env python
-# Last Change: Mon Oct 29 12:00 PM 2007 J
+# Last Change: Tue Nov 06 04:00 PM 2007 J
 
 # This module should contains useful test code (as strings). They are mainly
 # useful for checkers who need to run the tests (to check the mere presence of
@@ -7,7 +7,14 @@
 
 # Check whether CBLAS sgemm works
 cblas_sgemm = r"""
+enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102};
+enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113};
 
+void cblas_sgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
+                 const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
+                 const int K, const float alpha, const float *A,
+                 const int lda, const float *B, const int ldb,
+                 const float beta, float *C, const int ldc);
 int
 main (void)
 {



More information about the Numpy-svn mailing list