Skip to content

Commit 8a9b0ad

Browse files
committed
build: Check if BLAS functions correctly return single-precision floating point.
* m4/octave_blas.m4 (OCTAVE_BLAS): Add check for return type of BLAS function SDOT. Some implementations (e.g., Apple Accelerate) erroneously return a double-precision floating point value for this function (and all other BLAS functions that should return a single-precision floating point value). Fail the configuration if that error is detected in the used BLAS implementation.
1 parent 2c7ab23 commit 8a9b0ad

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

m4/octave_blas.m4

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,40 @@ AC_DEFUN([OCTAVE_BLAS], [
4545
ac_octave_save_LIBS="$LIBS"
4646
LIBS="$BLAS_LIBS $LIBS"
4747
AC_LANG_PUSH(Fortran 77)
48+
# Check if BLAS functions with single precision return value work
49+
# correctly
50+
AC_CACHE_CHECK([whether BLAS functions with single precision return value work correctly],
51+
[octave_cv_working_blas_single_precision],
52+
[AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[
53+
implicit none
54+
real d
55+
real x(2), y(2)
56+
real sdot
57+
58+
data x /1.0, 2.0/
59+
data y /3.0, 4.0/
60+
61+
d = sdot (2, x, 1, y, 1)
62+
* print *, 'result: ', d
63+
64+
c Some implementations of BLAS (e.g., the one from Apple Accelerate)
65+
c erroneously return a *double*-precision floating point value for functions
66+
c that should be returning a single-precision floating point value.
67+
c Check if the result for SDOT is correct if we (correctly) assume that it
68+
c returns a single-precision floating point value.
69+
70+
if (d .ne. 11.0) then
71+
stop 1
72+
endif
73+
74+
]])],
75+
octave_cv_working_blas_single_precision=yes,
76+
octave_cv_working_blas_single_precision=no)
77+
])
78+
if test "$octave_cv_working_blas_single_precision" != yes; then
79+
AC_MSG_ERROR([The function SDOT does not work correctly with the selected BLAS library. Use a different implementation of BLAS.])
80+
fi
81+
4882
## Check BLAS library integer size.
4983
## If it does not appear to be 8 bytes, we assume it is 4 bytes.
5084
## FIXME: this may fail with options like -ftrapping-math.

0 commit comments

Comments
 (0)