# HG changeset patch # User John W. Eaton # Date 1531915485 14400 # Node ID 171d90967f16277562a668b3f9e61ec9087dd891 # Parent b96ab99e67bb4386abb64271b216f6d47ded0716 fix test for 8-byte integer BLAS lib on big-endian systems (bug #53853) * octave_blas_f77_func.m4: Pass different integer values to DDOT so that the test will work on either big- or little-endian systems. diff -r b96ab99e67bb -r 171d90967f16 m4/octave_blas_f77_func.m4 --- a/m4/octave_blas_f77_func.m4 Tue Jul 17 15:44:50 2018 +0200 +++ b/m4/octave_blas_f77_func.m4 Wed Jul 18 08:04:45 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])