|
| 1 | +# =========================================================================== |
| 2 | +# https://www.gnu.org/software/autoconf-archive/ax_blas.html |
| 3 | +# =========================================================================== |
| 4 | +# |
1 | 5 | # SYNOPSIS |
2 | 6 | # |
3 | 7 | # AX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) |
|
10 | 14 | # |
11 | 15 | # To link with BLAS, you should link with: |
12 | 16 | # |
13 | | -# $BLAS_LIBS $LIBS |
14 | | -# |
15 | | -# in that order. |
| 17 | +# $BLAS_LIBS $LIBS $FLIBS |
16 | 18 | # |
17 | | -# To call a BLAS function, use the F77_FUNC macro, defined in config.h |
| 19 | +# in that order. FLIBS is the output variable of the |
| 20 | +# AC_F77_LIBRARY_LDFLAGS macro (called if necessary by AX_BLAS), and is |
| 21 | +# sometimes necessary in order to link with F77 libraries. Users will also |
| 22 | +# need to use AC_F77_DUMMY_MAIN (see the autoconf manual), for the same |
| 23 | +# reason. |
18 | 24 | # |
19 | 25 | # Many libraries are searched for, from ATLAS to CXML to ESSL. The user |
20 | 26 | # may also use --with-blas=<lib> in order to use some specific BLAS |
21 | | -# library <lib>. |
| 27 | +# library <lib>. In order to link successfully, however, be aware that you |
| 28 | +# will probably need to use the same Fortran compiler (which can be set |
| 29 | +# via the F77 env. var.) as was used to compile the BLAS library. |
22 | 30 | # |
23 | 31 | # ACTION-IF-FOUND is a list of shell commands to run if a BLAS library is |
24 | 32 | # found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is |
25 | 33 | # not found. If ACTION-IF-FOUND is not specified, the default action will |
26 | 34 | # define HAVE_BLAS. |
27 | 35 | # |
28 | | -# This macro requires autoconf 2.50 or later. |
29 | | -# |
30 | | -# The macro is a modified version of ACX_BLAS, from the autoconf macro |
31 | | -# archive. The original macro depends on a Fortran compiler, and this |
32 | | -# version does not. This version has not been tested extensively, but |
33 | | -# it is known to work with ATLAS and vecLib. |
34 | | -# |
35 | | -# LAST MODIFICATION |
| 36 | +# LICENSE |
36 | 37 | # |
37 | | -# 2008-12-29 |
38 | | -# |
39 | | -# COPYLEFT |
40 | | -# |
41 | | -# Copyright (c) 2008 Patrick O. Perry <[email protected]> |
42 | 38 | # Copyright (c) 2008 Steven G. Johnson <[email protected]> |
| 39 | +# Copyright (c) 2019 Geoffrey M. Oxberry <[email protected]> |
43 | 40 | # |
44 | 41 | # This program is free software: you can redistribute it and/or modify it |
45 | 42 | # under the terms of the GNU General Public License as published by the |
|
52 | 49 | # Public License for more details. |
53 | 50 | # |
54 | 51 | # You should have received a copy of the GNU General Public License along |
55 | | -# with this program. If not, see <http://www.gnu.org/licenses/>. |
| 52 | +# with this program. If not, see <https://www.gnu.org/licenses/>. |
56 | 53 | # |
57 | 54 | # As a special exception, the respective Autoconf Macro's copyright owner |
58 | 55 | # gives unlimited permission to copy, distribute and modify the configure |
|
63 | 60 | # all other use of the material that constitutes the Autoconf Macro. |
64 | 61 | # |
65 | 62 | # This special exception to the GPL applies to versions of the Autoconf |
66 | | -# Macro released by the Autoconf Macro Archive. When you make and |
67 | | -# distribute a modified version of the Autoconf Macro, you may extend this |
68 | | -# special exception to the GPL to apply to your modified version as well. |
| 63 | +# Macro released by the Autoconf Archive. When you make and distribute a |
| 64 | +# modified version of the Autoconf Macro, you may extend this special |
| 65 | +# exception to the GPL to apply to your modified version as well. |
69 | 66 |
|
| 67 | +#serial 21 |
| 68 | + |
| 69 | +AU_ALIAS([ACX_BLAS], [AX_BLAS]) |
70 | 70 | AC_DEFUN([AX_BLAS], [ |
71 | | -AC_PREREQ([2.69]) |
| 71 | +AC_PREREQ([2.55]) |
| 72 | +AC_REQUIRE([AC_CANONICAL_HOST]) |
72 | 73 | ax_blas_ok=no |
73 | 74 |
|
74 | 75 | AC_ARG_WITH(blas, |
75 | | - [AS_HELP_STRING([--with-blas=<lib>],[use BLAS library <lib>])]) |
| 76 | + [AS_HELP_STRING([--with-blas=<lib>], [use BLAS library <lib>])]) |
76 | 77 | case $with_blas in |
77 | | - yes | "") ;; |
78 | | - no) acx_blas_ok=disable ;; |
79 | | - -* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;; |
80 | | - *) BLAS_LIBS="-l$with_blas" ;; |
| 78 | + yes | "") ;; |
| 79 | + no) ax_blas_ok=disable ;; |
| 80 | + -* | */* | *.a | *.so | *.so.* | *.dylib | *.dylib.* | *.o) |
| 81 | + BLAS_LIBS="$with_blas" |
| 82 | + ;; |
| 83 | + *) BLAS_LIBS="-l$with_blas" ;; |
81 | 84 | esac |
82 | 85 |
|
83 | | -_AX_BLAS(gemm_, [ax_blas_ok=yes; ax_blas_underscore=yes], |
84 | | - [_AX_BLAS(gemm, [ax_blas_ok=yes; ax_blas_underscore=no], |
85 | | - [_AX_BLAS(gemm__, [ax_blas_ok=yes; ax_blas_underscore=yes2])] )] |
86 | | - ) |
87 | | -
|
88 | | -AC_SUBST(BLAS_LIBS) |
89 | | -DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --with-blas=$with_blas" |
90 | | -if test x"$ax_blas_ok" = xyes; then |
91 | | - ifelse([$1],, [ |
92 | | - AC_DEFINE(HAVE_BLAS,1, [Define if you have a BLAS library.]) |
93 | | - AH_TEMPLATE([F77_FUNC], |
94 | | - [Define to a macro mangling the given Fortan function name]) |
95 | | - if test x"$ax_blas_underscore" = xyes; then |
96 | | - AC_DEFINE([F77_FUNC(name)], [name ## _]) |
97 | | - else |
98 | | - AC_DEFINE([F77_FUNC(name)], [name]) |
99 | | - fi |
100 | | - ], |
101 | | - [$1]) |
102 | | - : |
103 | | -else |
104 | | - ax_blas_ok=no |
105 | | - $2 |
106 | | -fi |
107 | | -
|
108 | | -])dnl AX_BLAS |
109 | | - |
110 | | - |
111 | | -# _AX_BLAS(GEMM, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) |
112 | | -# -------------------------------------------------------- |
113 | | -# Look for a BLAS library in all of the standard places by checking for the |
114 | | -# functions s$GEMM and d$GEMM. On success, define BLAS_LIBS, set |
115 | | -# ax_blas_ok to yes, and execute ACTION-IF-FOUND. On failure, set ax_blas_ok |
116 | | -# to no and execute ACTION-IF-NOT-FOUND. |
117 | | -AC_DEFUN([_AX_BLAS], [ |
118 | | -AC_PREREQ([2.69]) |
119 | | -ax_blas_ok=no |
120 | | -
|
121 | 86 | # Get fortran linker names of BLAS functions to check for. |
122 | | -sgemm=s$1 |
123 | | -dgemm=d$1 |
| 87 | +#AC_F77_FUNC(daxpy) |
| 88 | +#AC_F77_FUNC(dgemm) |
| 89 | +#daxpy="daxpy DAXPY daxpy_ daxpy__ _daxpy DAXPY_ _DAXPY" |
| 90 | +#dgemm="dgemm DGEMM dgemm_ dgemm__ _dgemm DGEMM_ _DGEMM" |
| 91 | +#daxpy="daxpy_" |
| 92 | +#dgemm="dgemm_" |
124 | 93 |
|
125 | 94 | ax_blas_save_LIBS="$LIBS" |
126 | 95 | LIBS="$LIBS $FLIBS" |
127 | 96 |
|
128 | 97 | # First, check BLAS_LIBS environment variable |
129 | 98 | if test $ax_blas_ok = no; then |
130 | 99 | if test "x$BLAS_LIBS" != x; then |
131 | | - save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" |
132 | | - AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS]) |
133 | | - AC_TRY_LINK_FUNC($sgemm, [ax_blas_ok=yes], [BLAS_LIBS=""]) |
134 | | - AC_MSG_RESULT($ax_blas_ok) |
135 | | - LIBS="$save_LIBS" |
| 100 | + save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS" |
| 101 | + AC_MSG_CHECKING([for $daxpy in $BLAS_LIBS]) |
| 102 | + AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes], [BLAS_LIBS=""]) |
| 103 | + AC_MSG_RESULT($ax_blas_ok) |
| 104 | + LIBS="$save_LIBS" |
136 | 105 | fi |
137 | 106 | fi |
138 | 107 |
|
139 | 108 | # BLAS linked to by default? (happens on some supercomputers) |
140 | 109 | if test $ax_blas_ok = no; then |
141 | | - save_LIBS="$LIBS"; LIBS="$LIBS" |
142 | | - AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes]) |
143 | | - LIBS="$save_LIBS" |
| 110 | + save_LIBS="$LIBS"; LIBS="$LIBS" |
| 111 | + AC_MSG_CHECKING([if $daxpy is being linked in already]) |
| 112 | + AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes]) |
| 113 | + AC_MSG_RESULT($ax_blas_ok) |
| 114 | + LIBS="$save_LIBS" |
144 | 115 | fi |
145 | 116 |
|
146 | | -# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
| 117 | +# BLAS linked to by flexiblas? (Default on FC33+ and RHEL9+) |
| 118 | +
|
147 | 119 | if test $ax_blas_ok = no; then |
148 | | - AC_CHECK_LIB(atlas, ATL_xerbla, |
149 | | - [AC_CHECK_LIB(f77blas, $sgemm, |
150 | | - [AC_CHECK_LIB(cblas, cblas_dgemm, |
151 | | - [ax_blas_ok=yes |
152 | | - BLAS_LIBS="-lcblas -lf77blas -latlas"], |
153 | | - [], [-lf77blas -latlas])], |
154 | | - [], [-latlas])]) |
| 120 | + AC_CHECK_LIB(flexiblas, $daxpy, [ax_blas_ok=yes |
| 121 | + BLAS_LIBS="-lflexiblas"]) |
155 | 122 | fi |
156 | 123 |
|
157 | | -# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
| 124 | +# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/) |
158 | 125 | if test $ax_blas_ok = no; then |
159 | | - AC_CHECK_LIB(blas, $sgemm, |
160 | | - [AC_CHECK_LIB(dgemm, $dgemm, |
161 | | - [AC_CHECK_LIB(sgemm, $sgemm, |
162 | | - [ax_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"], |
163 | | - [], [-lblas])], |
164 | | - [], [-lblas])]) |
| 126 | + AC_CHECK_LIB(openblas, $daxpy, [ax_blas_ok=yes |
| 127 | + BLAS_LIBS="-lopenblas"]) |
165 | 128 | fi |
166 | 129 |
|
167 | | -# BLAS in Intel MKL library? |
| 130 | +# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) |
168 | 131 | if test $ax_blas_ok = no; then |
169 | | - case $host_os in |
170 | | - darwin*) |
171 | | - AC_CHECK_LIB(mkl_intel_lp64, $sgemm, |
172 | | - [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread"; OPENMP_LDFLAGS=""],, |
173 | | - [-lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread]) |
174 | | - ;; |
175 | | - *) |
176 | | - if test $host_cpu = x86_64; then |
177 | | - AC_CHECK_LIB(mkl_intel_lp64, $sgemm, |
178 | | - [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],, |
179 | | - [-lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl]) |
180 | | - elif test $host_cpu = i686; then |
181 | | - AC_CHECK_LIB(mkl_intel, $sgemm, |
182 | | - [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl"],, |
183 | | - [-lmkl_intel -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl]) |
184 | | - fi |
185 | | - ;; |
186 | | - esac |
| 132 | + AC_CHECK_LIB(atlas, ATL_xerbla, |
| 133 | + [AC_CHECK_LIB(f77blas, $daxpy, |
| 134 | + [AC_CHECK_LIB(cblas, cblas_dgemm, |
| 135 | + [ax_blas_ok=yes |
| 136 | + BLAS_LIBS="-lcblas -lf77blas -latlas"], |
| 137 | + [], [-lf77blas -latlas])], |
| 138 | + [], [-latlas])]) |
187 | 139 | fi |
188 | 140 |
|
189 | | -# BLAS in Intel MKL library? |
| 141 | +# BLAS in PhiPACK libraries? (requires generic BLAS lib, too) |
190 | 142 | if test $ax_blas_ok = no; then |
191 | | - AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl"]) |
| 143 | + AC_CHECK_LIB(blas, $daxpy, |
| 144 | + [AC_CHECK_LIB(dgemm, $dgemm, |
| 145 | + [AC_CHECK_LIB(daxpy, $daxpy, |
| 146 | + [ax_blas_ok=yes; BLAS_LIBS="-ldaxpy -ldgemm -lblas"], |
| 147 | + [], [-lblas])], |
| 148 | + [], [-lblas])]) |
192 | 149 | fi |
193 | 150 |
|
194 | 151 | # BLAS in Intel MKL library? |
195 | 152 | if test $ax_blas_ok = no; then |
196 | | - save_LDFLAGS="$LDFLAGS"; LDFLAGS="-L$MKLROOT/lib/intel64 $LDFLAGS" |
197 | | - AC_CHECK_LIB(mkl_core, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-L$MKLROOT/lib/intel64 -lmkl_core"]) |
198 | | - LDFLAGS="$save_LDFLAGS" |
| 153 | + # MKL for gfortran |
| 154 | + if test x"$ac_cv_cxx_compiler_gnu" = xyes; then |
| 155 | + # 64 bit |
| 156 | + if test $host_cpu = x86_64; then |
| 157 | + AC_CHECK_LIB(mkl_gf_lp64, $daxpy, |
| 158 | + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],, |
| 159 | + [-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread]) |
| 160 | + # 32 bit |
| 161 | + elif test $host_cpu = i686; then |
| 162 | + AC_CHECK_LIB(mkl_gf, $daxpy, |
| 163 | + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],, |
| 164 | + [-lmkl_gf -lmkl_sequential -lmkl_core -lpthread]) |
| 165 | + fi |
| 166 | + # MKL for other compilers (Intel, PGI, ...?) |
| 167 | + else |
| 168 | + # 64-bit |
| 169 | + if test $host_cpu = x86_64; then |
| 170 | + AC_CHECK_LIB(mkl_intel_lp64, $daxpy, |
| 171 | + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -limf -lpthread"],, |
| 172 | + [-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -limf -lpthread]) |
| 173 | + # 32-bit |
| 174 | + elif test $host_cpu = i686; then |
| 175 | + AC_CHECK_LIB(mkl_intel, $daxpy, |
| 176 | + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -limf -lpthread"],, |
| 177 | + [-lmkl_intel -lmkl_sequential -lmkl_core -limf -lpthread]) |
| 178 | + fi |
| 179 | + fi |
| 180 | +fi |
| 181 | +# Old versions of MKL |
| 182 | +if test $ax_blas_ok = no; then |
| 183 | + AC_CHECK_LIB(mkl, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread]) |
199 | 184 | fi |
200 | 185 |
|
201 | 186 | # BLAS in Apple vecLib library? |
202 | 187 | if test $ax_blas_ok = no; then |
203 | | - save_LIBS="$LIBS"; LIBS="-framework vecLib $LIBS" |
204 | | - AC_CHECK_FUNC($sgemm, [ax_blas_ok=yes;BLAS_LIBS="-framework vecLib"]) |
205 | | - LIBS="$save_LIBS" |
| 188 | + save_LIBS="$LIBS"; LIBS="-framework Accelerate $LIBS" |
| 189 | + AC_MSG_CHECKING([for $daxpy in -framework Accelerate]) |
| 190 | + AC_LINK_IFELSE([AC_LANG_CALL([], [$daxpy])], [ax_blas_ok=yes;BLAS_LIBS="-framework Accelerate"]) |
| 191 | + AC_MSG_RESULT($ax_blas_ok) |
| 192 | + LIBS="$save_LIBS" |
206 | 193 | fi |
207 | 194 |
|
208 | 195 | # BLAS in Alpha CXML library? |
209 | 196 | if test $ax_blas_ok = no; then |
210 | | - AC_CHECK_LIB(cxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"]) |
| 197 | + AC_CHECK_LIB(cxml, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-lcxml"]) |
211 | 198 | fi |
212 | 199 |
|
213 | 200 | # BLAS in Alpha DXML library? (now called CXML, see above) |
214 | 201 | if test $ax_blas_ok = no; then |
215 | | - AC_CHECK_LIB(dxml, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"]) |
| 202 | + AC_CHECK_LIB(dxml, $daxpy, [ax_blas_ok=yes;BLAS_LIBS="-ldxml"]) |
216 | 203 | fi |
217 | 204 |
|
218 | 205 | # BLAS in Sun Performance library? |
219 | 206 | if test $ax_blas_ok = no; then |
220 | | - if test "x$GCC" != xyes; then # only works with Sun CC |
221 | | - AC_CHECK_LIB(sunmath, acosp, |
222 | | - [AC_CHECK_LIB(sunperf, $sgemm, |
223 | | - [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" |
| 207 | + if test "x$GCC" != xyes; then # only works with Sun CC |
| 208 | + AC_CHECK_LIB(sunmath, acosp, |
| 209 | + [AC_CHECK_LIB(sunperf, $daxpy, |
| 210 | + [BLAS_LIBS="-xlic_lib=sunperf -lsunmath" |
224 | 211 | ax_blas_ok=yes],[],[-lsunmath])]) |
225 | | - fi |
| 212 | + fi |
226 | 213 | fi |
227 | 214 |
|
228 | 215 | # BLAS in SCSL library? (SGI/Cray Scientific Library) |
229 | 216 | if test $ax_blas_ok = no; then |
230 | | - AC_CHECK_LIB(scs, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lscs"]) |
| 217 | + AC_CHECK_LIB(scs, $daxpy, [ax_blas_ok=yes; BLAS_LIBS="-lscs"]) |
231 | 218 | fi |
232 | 219 |
|
233 | 220 | # BLAS in SGIMATH library? |
234 | 221 | if test $ax_blas_ok = no; then |
235 | | - AC_CHECK_LIB(complib.sgimath, $sgemm, |
236 | | - [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) |
| 222 | + AC_CHECK_LIB(complib.sgimath, $daxpy, |
| 223 | + [ax_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"]) |
237 | 224 | fi |
238 | 225 |
|
239 | 226 | # BLAS in IBM ESSL library? (requires generic BLAS lib, too) |
240 | 227 | if test $ax_blas_ok = no; then |
241 | | - AC_CHECK_LIB(blas, $sgemm, |
242 | | - [AC_CHECK_LIB(essl, $sgemm, |
243 | | - [ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], |
244 | | - [], [-lblas $FLIBS])]) |
| 228 | + AC_CHECK_LIB(blas, $daxpy, |
| 229 | + [AC_CHECK_LIB(essl, $daxpy, |
| 230 | + [ax_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], |
| 231 | + [], [-lblas $FLIBS])]) |
245 | 232 | fi |
246 | 233 |
|
247 | 234 | # Generic BLAS library? |
248 | 235 | if test $ax_blas_ok = no; then |
249 | | - AC_CHECK_LIB(blas, $sgemm, [ax_blas_ok=yes; BLAS_LIBS="-lblas"]) |
| 236 | + AC_CHECK_LIB(blas, $daxpy, [ax_blas_ok=yes; BLAS_LIBS="-lblas"]) |
250 | 237 | fi |
251 | 238 |
|
| 239 | +AC_SUBST(BLAS_LIBS) |
| 240 | +
|
252 | 241 | LIBS="$ax_blas_save_LIBS" |
253 | 242 |
|
254 | 243 | # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: |
255 | 244 | if test x"$ax_blas_ok" = xyes; then |
256 | | - $2 |
257 | | - : |
| 245 | + ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1]) |
| 246 | + : |
258 | 247 | else |
259 | | - ax_blas_ok=no |
260 | | - $3 |
| 248 | + ax_blas_ok=no |
| 249 | + $2 |
261 | 250 | fi |
262 | | -])dnl _AX_BLAS |
| 251 | +])dnl AX_BLAS |
0 commit comments