changeset 25633:f89bf246dcd4

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 18 Jul 2018 08:07:36 -0400
parents d1216d085280 (current diff) 171d90967f16 (diff)
children 6ff900fd15cb
files
diffstat 1 files changed, 43 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/m4/octave_blas_f77_func.m4	Tue Jul 17 08:58:10 2018 -0700
+++ b/m4/octave_blas_f77_func.m4	Wed Jul 18 08:07:36 2018 -0400
@@ -154,26 +154,54 @@
 # FIXME: this may fail with things like -ftrapping-math.
         AC_MSG_CHECKING([BLAS library integer size])
         AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[
-      integer*8 n
-      integer*4 n4
-      real s,a(1),b(1),sdot
+      integer*8 two, n
+      integer*4 n2(2)
+      double precision d, a(1), b(1), ddot
+      equivalence (n, n2)
+
       a(1) = 1.0
       b(1) = 1.0
-c Generate -2**33 + 1.  With BLAS compiled to use 64-bit integers, SDOT
-c will return early, setting the result to 0.  With BLAS compiled to use
-c 32-bit integers, this value should be interpreted as 1 and SDOT will
-c return 1.
-      n = 2
-      n = -4 * (n ** 30)
-      n = n + 1
-c Check that our expectation about the type conversion is correct.
-      n4 = n
-      if (n4 .ne. 1) then
+
+c Generate 2**32 + 1 in an 8-byte integer.  Whether we have a big
+c endian or little endian system, both 4-byte words of this value
+c should be 1.
+
+      two = 2
+      n = (two ** 32) + 1
+
+c Check that our expectation about the type conversions are correct.
+
+      if (n2(1) .ne. 1 .or. n2(2) .ne. 1) then
         print *, 'invalid assumption about integer type conversion'
         stop 2
       endif
-      s = sdot(n,a,1,b,1)
-      if (s .ne. 0.0) stop 1
+
+*     print *, n, n2(1), n2(2)
+*     print *, a(1), b(1)
+
+c DDOT will either see 1 or a large value for N.  Since INCX and INCY
+c are both 0, we will never increment the index, so A and B only need to
+c have a single element.  If N is interpreted as 1 (BLAS compiled with 4
+c byte integers) then the result will be 1.  If N is interpreted as a
+c large value (BLAS compiled with 8 byte integers) then the result will
+c be the summation a(1)*b(1) 2^32+1 times.  This will also take some
+c time to compute, but at least for now it is the unusual case so we are
+c much more likely to exit quickly after detecting that the BLAS library
+c was compiled with 4-byte integers.
+
+      d = ddot (n, a, 0, b, 0)
+
+*     print *, a(1), b(1), d
+
+c Success (0 exit status) means we detected BLAS compiled with
+c 8-byte integers.
+
+      if (d .eq. 1.0) then
+        stop 1
+      else
+        stop 1
+      endif
+
        ]]),[ax_blas_integer_size=8],
         [ax_blas_integer_size=4])
         AC_MSG_RESULT([$ax_blas_integer_size])