changeset 9600:de6f547574be

BLAS integer size check in acx_blas_f77_func
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 02 Sep 2009 08:35:48 +0200
parents 7be1bddd0f11
children a9b37bae1802
files ChangeLog acx_blas_f77_func.m4
diffstat 2 files changed, 34 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Sep 01 16:50:54 2009 -0400
+++ b/ChangeLog	Wed Sep 02 08:35:48 2009 +0200
@@ -1,3 +1,8 @@
+2009-09-02  Jaroslav Hajek  <highegg@gmail.com>
+
+	* acx_blas_f77_func.m4 (ACX_BLAS_F77_FUNC): Check for correct INTEGER
+	size.
+
 2009-09-01  John W. Eaton  <jwe@octave.org>
 
 	* aclocal.m4 (OCTAVE_REQUIRE_64_BIT_FORTRAN_INTEGERS): New macro.
--- a/acx_blas_f77_func.m4	Tue Sep 01 16:50:54 2009 -0400
+++ b/acx_blas_f77_func.m4	Wed Sep 02 08:35:48 2009 +0200
@@ -143,6 +143,33 @@
       ]]),[acx_blas_zdotu_fcall_ok=yes],
 	[acx_blas_zdotu_fcall_ok=no])
 	AC_MSG_RESULT([$acx_blas_zdotu_fcall_ok])
+# Check for correct integer size
+# FIXME: this may fail with things like -ftrapping-math.
+        AC_MSG_CHECKING([whether the integer size is correct])
+        AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
+      integer n,nn(3)
+      real s,a(1),b(1),sdot
+      a(1) = 1.0
+      b(1) = 1.0
+c Generate -2**33 + 1, if possible
+      n = 2
+      n = -4 * (n ** 30)
+      n = n + 1
+      if (n >= 0) goto 1
+c This means we're on 64-bit integers. Check whether the BLAS is, too.
+      s = sdot(n,a,1,b,1)
+      if (s .ne. 0.0) stop 1
+    1 continue
+c We may be on 32-bit integers, and the BLAS on 64 bits. This is almost bound
+c to have already failed, but just in case, we'll check.
+      nn(1) = -1
+      nn(2) = 1
+      nn(3) = -1
+      s = sdot(nn(2),a,1,b,1)
+      if (s .ne. 1.0) stop 1
+       ]]),[acx_blas_integer_size_ok=yes],
+	[acx_blas_integer_size_ok=no])
+	AC_MSG_RESULT([$acx_blas_integer_size_ok])
 
 	AC_LANG_POP(Fortran 77)
 
@@ -151,7 +178,8 @@
 		-a $acx_blas_sdot_fcall_ok = yes \
 		-a $acx_blas_ddot_fcall_ok = yes \
 		-a $acx_blas_cdotu_fcall_ok = yes \
-		-a $acx_blas_zdotu_fcall_ok = yes ; then
+		-a $acx_blas_zdotu_fcall_ok = yes \
+		-a $acx_blas_integer_size_ok = yes; then
 		acx_blas_f77_func_ok=yes;
 		$1
 	else