Mercurial > jwe > octave
annotate m4/octave_blas.m4 @ 31142:6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
* m4/octave-blas.m4: Allow setting BLAS integer size as configure argument when
cross compiling.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 10 Jul 2022 17:34:12 +0200 |
parents | 1d61c36bb34a |
children |
rev | line source |
---|---|
31138
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
1 dnl -------------------------------------------------------------------- |
31134
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
2 dnl |
31138
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
3 dnl Copyright (C) 2022 The Octave Project Developers |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
4 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
5 dnl See the file COPYRIGHT.md in the top-level directory of this |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
6 dnl distribution or <https://octave.org/copyright/>. |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
7 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
8 dnl This file is part of Octave. |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
9 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
10 dnl Octave is free software: you can redistribute it and/or modify it |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
11 dnl under the terms of the GNU General Public License as published by |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
12 dnl the Free Software Foundation, either version 3 of the License, or |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
13 dnl (at your option) any later version. |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
14 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
15 dnl Octave is distributed in the hope that it will be useful, but |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
16 dnl WITHOUT ANY WARRANTY; without even the implied warranty of |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
17 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
18 dnl GNU General Public License for more details. |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
19 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
20 dnl You should have received a copy of the GNU General Public License |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
21 dnl along with Octave; see the file COPYING. If not, see |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
22 dnl <https://www.gnu.org/licenses/>. |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
23 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
24 dnl -------------------------------------------------------------------- |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
25 dnl |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
26 dnl Check for BLAS library and, if valid, determine integer size of library |
31134
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
27 dnl |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
28 AC_DEFUN([OCTAVE_BLAS], [ |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
29 AC_PREREQ(2.50) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
30 dnl Call reference macro to find BLAS library |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
31 AX_BLAS |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
32 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
33 if test "$cross_compiling" = yes ; then |
31142
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
34 dnl Assume BLAS library exists when cross compiling |
31134
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
35 ax_blas_ok=yes |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
36 AC_MSG_CHECKING([BLAS can be called from Fortran]) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
37 AC_MSG_RESULT([yes assumed for cross compilation]) |
31142
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
38 dnl Assume generic 4-byte BLAS library if not specified |
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
39 AC_MSG_CHECKING([BLAS library integer size]) |
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
40 if test -z "$ax_cv_blas_integer_size" ; then |
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
41 ax_cv_blas_integer_size=4 |
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
42 fi |
6308ce73bdca
build: Allow setting BLAS integer size as configure argument (bug #62715).
Markus Mützel <markus.muetzel@gmx.de>
parents:
31138
diff
changeset
|
43 AC_MSG_RESULT([$ax_cv_blas_integer_size assumed for cross compilation]) |
31138
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
44 elif test $ax_blas_ok = yes; then |
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
45 ac_octave_save_LIBS="$LIBS" |
31134
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
46 LIBS="$BLAS_LIBS $LIBS" |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
47 AC_LANG_PUSH(Fortran 77) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
48 ## Check BLAS library integer size. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
49 ## If it does not appear to be 8 bytes, we assume it is 4 bytes. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
50 ## FIXME: this may fail with options like -ftrapping-math. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
51 AC_CACHE_CHECK([BLAS library integer size], |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
52 [ax_cv_blas_integer_size], |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
53 [AC_RUN_IFELSE([AC_LANG_PROGRAM(,[[ |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
54 integer*8 two, n |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
55 integer*4 n2(2) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
56 double precision d, a(1), b(1), ddot |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
57 equivalence (n, n2) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
58 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
59 a(1) = 1.0 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
60 b(1) = 1.0 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
61 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
62 c Generate 2**32 + 1 in an 8-byte integer. Whether we have a big |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
63 c endian or little endian system, both 4-byte words of this value |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
64 c should be 1. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
65 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
66 two = 2 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
67 n = (two ** 32) + 1 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
68 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
69 c Check that our expectation about the type conversions are correct. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
70 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
71 if (n2(1) .ne. 1 .or. n2(2) .ne. 1) then |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
72 print *, 'invalid assumption about integer type conversion' |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
73 stop 2 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
74 endif |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
75 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
76 * print *, n, n2(1), n2(2) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
77 * print *, a(1), b(1) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
78 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
79 c DDOT will either see 1 or a large value for N. Since INCX and INCY |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
80 c are both 0, we will never increment the index, so A and B only need to |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
81 c have a single element. If N is interpreted as 1 (BLAS compiled with |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
82 c 4-byte integers) then the result will be 1. If N is interpreted as a |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
83 c large value (BLAS compiled with 8-byte integers) then the result will |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
84 c be the summation a(1)*b(1) 2^32+1 times. This will also take some |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
85 c time to compute, but at least for now it is the unusual case so we are |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
86 c much more likely to exit quickly after detecting that the BLAS library |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
87 c was compiled with 4-byte integers. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
88 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
89 d = ddot (n, a, 0, b, 0) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
90 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
91 * print *, a(1), b(1), d |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
92 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
93 c Success (0 exit status) means we detected BLAS compiled with |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
94 c 8-byte integers. |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
95 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
96 if (d .eq. 1.0) then |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
97 stop 1 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
98 endif |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
99 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
100 ]])], |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
101 ax_cv_blas_integer_size=8, |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
102 ax_cv_blas_integer_size=4) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
103 ]) |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
104 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
105 AC_LANG_POP(Fortran 77) |
31138
1d61c36bb34a
build: Uspdate Copyright notices for acinclude.m4, octave_blas.m4.
Rik <rik@octave.org>
parents:
31134
diff
changeset
|
106 LIBS="$ac_octave_save_LIBS" |
31134
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
107 fi |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
108 |
4dc326899f65
build: simplify BLAS library detection in configure (bug #62715)
Rik <rik@octave.org>
parents:
diff
changeset
|
109 ]) |