Commits

jeremy_barnes  committed 3226612

fixed lapack version detection so that version 3.2 is properly detected

  • Participants
  • Parent commits 600c097

Comments (0)

Files changed (3)

File src/algebra/algebra.mk

+# Library to provide the weak definition of slarfp_ needed to determine if
+# LAPACK 3.2 or later is installed.  Needs to be in a separate library so
+# that the strong version from lapack can be picked up if it exists.
+$(eval $(call library,lapack_detect,lapack_detect.cc,))
+
 LIBALGEBRA_SOURCES := \
         least_squares.cc \
         irls.cc \
 
 $(eval $(call add_sources,$(LIBALGEBRA_SOURCES)))
 
-LIBALGEBRA_LINK :=	utils lapack blas gfortran db
+LIBALGEBRA_LINK :=	utils lapack blas gfortran db lapack_detect
 
 $(eval $(call library,algebra,$(LIBALGEBRA_SOURCES),$(LIBALGEBRA_LINK)))
 

File src/algebra/lapack.cc

                 const int * ldb, const double * beta, double * c, const int * ldc,
                 int * info);
 
-    /* Dummy (weak) implementation */
-    static void slarfp_dummy(const int * n, float * alpha, float * X, const int * incx,
-                      float * tau)
-    {
-        if (*n != -234)
-            throw ML::Exception("wrong version of slarfp called; this weak "
-                                "version should have been overridden");
-        
-        *tau = 1.0;
-    }
-
     /* Elementary reflector.  Used to detect version 3.2 of the LAPACK.  Most
        important thing is that if n < 0, it will return zero in tau. */
     void slarfp_(const int * n, float * alpha, float * X, const int * incx,
-                 float * tau) __attribute__ ((__weak__, __alias__ ("slarfp_dummy")));
-
-
-}
+                 float * tau);
+} // extern "C"
 
 namespace ML {
 namespace LAPack {
 
     slarfp_(&n, &alpha, &x, &incx, &tau);
 
+    cerr << "tau = " << tau << endl;
+
     // If the dummy slarfp function ran, it will return 1.0, which means that
     // we are using a version of lapack 3.1 or lower.  If the lapack
     // 3.2 version ran, it will return 0.0.
     {
         need_lock = !lapack_version_3_2_or_later();
         
+        cerr << "need_lock = " << need_lock << endl;
+
         // ilaenv isn't thread safe (it can return different results if it's
         // called for the first time twice from two different threads; see
         // http://icl.cs.utk.edu/lapack-forum/archives/lapack/msg00342.html

File src/algebra/lapack_detect.cc

+/** lapack_detect.cc
+    Jeremy Barnes, 11 June 2010
+    Copyright (c) 2010 Jeremy Barnes.  All rights reserved.
+
+    Code to detect the LAPACK version.
+*/
+
+#include "jml/arch/exception.h"
+
+extern "C" {
+
+    /* Dummy (weak) implementation */
+    static void slarfp_dummy(const int * n, float * alpha, float * X, const int * incx,
+                      float * tau)
+    {
+        if (*n != -234)
+            throw ML::Exception("wrong version of slarfp called; this weak "
+                                "version should have been overridden");
+        
+        *tau = 1.0;
+    }
+
+    /* Elementary reflector.  Used to detect version 3.2 of the LAPACK.  Most
+       important thing is that if n < 0, it will return zero in tau. */
+    void slarfp_(const int * n, float * alpha, float * X, const int * incx,
+                 float * tau) __attribute__ ((__weak__, __alias__ ("slarfp_dummy")));
+
+
+} // extern "C"
+