3
# Generate C conftest for BLAS.
4
AC_DEFUN([COMEX_C_BLAS_TEST], [
5
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
17
[[char cresult = $caxpy ();
18
char dresult = $daxpy ();
19
char sresult = $saxpy ();
20
char zresult = $zaxpy ();
27
# Clears BLAS_LIBS on failure. Sets comex_blas_ok=yes on success.
28
# Tests the common case first of using lowercase+underscore. Some libraries,
29
# such as ACML, have a C interface which uses lowercase+nounderscore. ComEx
30
# assumes it is calling using the Fortran interface.
31
AC_DEFUN([COMEX_RUN_BLAS_TEST], [
34
AS_IF([test "x$comex_blas_ok" = xno],
40
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
41
AS_IF([test "x$comex_blas_ok" = xno],
47
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
48
AS_IF([test "x$comex_blas_ok" = xno],
54
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
55
AS_IF([test "x$comex_blas_ok" = xno],
61
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
62
AS_IF([test "x$comex_blas_ok" = xno],
68
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
69
AS_IF([test "x$comex_blas_ok" = xno],
75
AC_LINK_IFELSE([], [comex_blas_ok=yes], [BLAS_LIBS=])])
76
AS_IF([test "x$comex_blas_ok" = xno],
84
# COMEX_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
85
# -------------------------------------------------
86
# Parse the --with-blas argument and test for all *axpy routines. We use
87
# different tests depending on whether Fortran sources are enabled. There are
88
# many flavors of BLAS that we test for explicitly, although the list could
89
# probably be reduced based on currently available systems.
90
AC_DEFUN([COMEX_BLAS], [
94
[AS_HELP_STRING([--with-blas[[=ARG]]],
95
[use external BLAS library; attempt to detect sizeof(INTEGER)])],
98
[AS_HELP_STRING([--with-blas4[[=ARG]]],
99
[use external BLAS library compiled with sizeof(INTEGER)==4])],
100
[blas_size=4; with_blas="$with_blas4"])
102
[AS_HELP_STRING([--with-blas8[[=ARG]]],
103
[use external BLAS library compiled with sizeof(INTEGER)==8])],
104
[blas_size=8; with_blas="$with_blas8"])
107
AS_IF([test "x$with_blas" = xno], [comex_blas_ok=skip])
109
# Parse --with-blas argument. Clear previous values first.
113
COMEX_ARG_PARSE([with_blas], [BLAS_LIBS], [BLAS_LDFLAGS], [BLAS_CPPFLAGS])
115
comex_save_LIBS="$LIBS"
116
comex_save_LDFLAGS="$LDFLAGS"; LDFLAGS="$BLAS_LDFLAGS $LDFLAGS"
117
comex_save_CPPFLAGS="$CPPFLAGS"; CPPFLAGS="$BLAS_CPPFLAGS $CPPFLAGS"
119
AC_MSG_NOTICE([Attempting to locate BLAS library])
121
# First, check environment/command-line variables.
122
# If failed, erase BLAS_LIBS but maintain BLAS_LDFLAGS and BLAS_CPPFLAGS.
123
AS_IF([test $comex_blas_ok = no],
124
[AC_MSG_CHECKING([for BLAS with user-supplied flags])
125
LIBS="$BLAS_LIBS $LIBS"
126
COMEX_RUN_BLAS_TEST()
127
LIBS="$comex_save_LIBS"
128
AS_IF([test $comex_blas_ok = yes],
129
[AS_IF([test $blas_size_hack = yes],
130
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
131
[*ilp64*], [blas_size=8], # Intel MKL
132
[*_int64*], [blas_size=8])])]) # AMD ACML
133
AC_MSG_RESULT([$comex_blas_ok])])
135
# AMD Core Math Library (ACML)
136
AS_IF([test $comex_blas_ok = no],
137
[AC_MSG_CHECKING([for BLAS in AMD Core Math Library])
138
# add -lacml to BLAS_LIBS if missing from LIBS
139
AS_CASE([$LIBS], [*acml*], [], [BLAS_LIBS="-lacml"])
140
LIBS="$BLAS_LIBS $LIBS"
141
COMEX_RUN_BLAS_TEST()
142
LIBS="$comex_save_LIBS"
143
AS_IF([test "x$comex_blas_ok" = xyes],
144
[AS_IF([test $blas_size_hack = yes],
145
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
146
[*_int64*], [blas_size=8])])])
147
AC_MSG_RESULT([$comex_blas_ok])])
150
AS_IF([test $comex_blas_ok = no],
151
[AC_MSG_CHECKING([for BLAS in Intel Math Kernel Library])
152
# add -lmkl to BLAS_LIBS if missing from LIBS
153
AS_CASE([$LIBS], [*mkl*], [], [BLAS_LIBS="-lmkl"])
154
LIBS="$BLAS_LIBS $LIBS"
155
COMEX_RUN_BLAS_TEST()
156
LIBS="$comex_save_LIBS"
157
AS_IF([test "x$comex_blas_ok" = xyes],
158
[AS_IF([test $blas_size_hack = yes],
159
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
160
[*ilp64*], [blas_size=8])])])
161
AC_MSG_RESULT([$comex_blas_ok])])
163
# ATLAS library (http://math-atlas.sourceforge.net/)
164
AS_IF([test $comex_blas_ok = no],
165
[AC_MSG_CHECKING([for BLAS in ATLAS])
166
AS_IF([test "x$enable_f77" = xno],
167
[# add -lcblas if needed but missing from LIBS
168
AS_CASE([$LIBS], [*cblas*], [], [BLAS_LIBS="-lcblas"])],
169
[# add -lf77blas if needed but missing from LIBS
170
AS_CASE([$LIBS], [*f77blas*], [], [BLAS_LIBS="-lf77blas"])])
171
# add -latlas if needed but missing from LIBS
172
AS_CASE([$LIBS], [*atlas*], [], [BLAS_LIBS="$BLAS_LIBS -latlas"])
173
LIBS="$BLAS_LIBS $LIBS"
174
COMEX_RUN_BLAS_TEST()
175
LIBS="$comex_save_LIBS"
176
AC_MSG_RESULT([$comex_blas_ok])])
178
# PhiPACK libraries (requires generic BLAS lib, too)
179
AS_IF([test $comex_blas_ok = no],
180
[AC_MSG_CHECKING([for BLAS in PhiPACK libraries])
181
# add -lblas to BLAS_LIBS if missing from LIBS
182
AS_CASE([$LIBS], [*blas*], [], [BLAS_LIBS="-lblas"])
183
# add -ldgemm to BLAS_LIBS if missing from LIBS
184
AS_CASE([$LIBS], [*dgemm*], [], [BLAS_LIBS="-ldgemm $BLAS_LIBS"])
185
# add -lsgemm to BLAS_LIBS if missing from LIBS
186
AS_CASE([$LIBS], [*sgemm*], [], [BLAS_LIBS="-lsgemm $BLAS_LIBS"])
187
LIBS="$BLAS_LIBS $LIBS"
188
COMEX_RUN_BLAS_TEST()
189
LIBS="$comex_save_LIBS"
190
AC_MSG_RESULT([$comex_blas_ok])])
192
# Apple Accelerate.framework
193
AS_IF([test $comex_blas_ok = no],
194
[AC_MSG_CHECKING([for BLAS in Apple Accelerate.framework])
195
# add -framework Accelerate to BLAS_LIBS if missing from LIBS
196
AS_CASE([$LIBS], [*Accelerate*], [], [BLAS_LIBS="-framework Accelerate"])
197
LIBS="$BLAS_LIBS $LIBS"
198
COMEX_RUN_BLAS_TEST()
199
LIBS="$comex_save_LIBS"
200
AC_MSG_RESULT([$comex_blas_ok])])
202
# Apple vecLib.framework
203
AS_IF([test $comex_blas_ok = no],
204
[AC_MSG_CHECKING([for BLAS in Apple vecLib.framework])
205
# add -framework vecLib to BLAS_LIBS if missing from LIBS
206
AS_CASE([$LIBS], [*vecLib*], [], [BLAS_LIBS="-framework vecLib"])
207
LIBS="$BLAS_LIBS $LIBS"
208
COMEX_RUN_BLAS_TEST()
209
LIBS="$comex_save_LIBS"
210
AC_MSG_RESULT([$comex_blas_ok])])
212
# Alpha CXML library (CXML stands for Compaq Extended Math Library)
213
AS_IF([test $comex_blas_ok = no],
214
[AC_MSG_CHECKING([for BLAS in Alpha CXML library])
215
# add -lcxml to BLAS_LIBS if missing from LIBS
216
AS_CASE([$LIBS], [*cxml*], [], [BLAS_LIBS="-lcxml"])
217
LIBS="$BLAS_LIBS $LIBS"
218
COMEX_RUN_BLAS_TEST()
219
LIBS="$comex_save_LIBS"
220
AS_IF([test $comex_blas_ok = no],
221
[# add -lcxml to BLAS_LIBS if missing from LIBS
222
AS_CASE([$LIBS], [*cxml*], [], [BLAS_LIBS="-lcxml"])
223
# add -lcpml to BLAS_LIBS if missing from LIBS
224
AS_CASE([$LIBS], [*cpml*], [], [BLAS_LIBS="$BLAS_LIBS -lcpml"])
225
LIBS="$BLAS_LIBS $LIBS"
226
COMEX_RUN_BLAS_TEST()
227
LIBS="$comex_save_LIBS"])
228
AC_MSG_RESULT([$comex_blas_ok])])
230
# Alpha DXML library (now called CXML, see above)
232
# Sun Performance library
233
AS_IF([test $comex_blas_ok = no],
234
[AC_MSG_CHECKING([for BLAS in Sun Performance Library])
235
# add -xlic_lib=sunperf to BLAS_LIBS if missing from LIBS
236
AS_CASE([$LIBS], [*sunperf*], [], [BLAS_LIBS="-xlic_lib=sunperf"])
237
LIBS="$BLAS_LIBS $LIBS"
238
COMEX_RUN_BLAS_TEST()
239
LIBS="$comex_save_LIBS"
240
AS_IF([test $comex_blas_ok = no],
241
[# add -xlic_lib=sunperf to BLAS_LIBS if missing from LIBS
242
AS_CASE([$LIBS], [*sunperf*], [], [BLAS_LIBS="-xlic_lib=sunperf"])
243
# add -lsunmath to BLAS_LIBS if missing from LIBS
244
AS_CASE([$LIBS], [*sunmath*], [], [BLAS_LIBS="$BLAS_LIBS -lsunmath"])
245
LIBS="$BLAS_LIBS $LIBS"
246
COMEX_RUN_BLAS_TEST()
247
LIBS="$comex_save_LIBS"])
248
AC_MSG_RESULT([$comex_blas_ok])])
250
# SCSL library (SCSL stands for SGI/Cray Scientific Library)
251
AS_IF([test $comex_blas_ok = no],
252
[AC_MSG_CHECKING([for BLAS in SGI/Cray Scientific Library])
253
# add -lscs to BLAS_LIBS if missing from LIBS
254
AS_CASE([$LIBS], [*scs*], [], [BLAS_LIBS="-lscs"])
255
LIBS="$BLAS_LIBS $LIBS"
256
COMEX_RUN_BLAS_TEST()
257
LIBS="$comex_save_LIBS"
258
AC_MSG_RESULT([$comex_blas_ok])])
261
AS_IF([test $comex_blas_ok = no],
262
[AC_MSG_CHECKING([for BLAS in SGIMATH library])
263
# add -lcomplib.sgimath to BLAS_LIBS if missing from LIBS
264
AS_CASE([$LIBS], [*complib.sgimath*], [], [BLAS_LIBS="-lcomplib.sgimath"])
265
LIBS="$BLAS_LIBS $LIBS"
266
COMEX_RUN_BLAS_TEST()
267
LIBS="$comex_save_LIBS"
268
AC_MSG_RESULT([$comex_blas_ok])])
270
# IBM ESSL library (requires generic BLAS lib, too)
271
AS_IF([test $comex_blas_ok = no],
272
[AC_MSG_CHECKING([for BLAS in IBM ESSL library])
273
# add -lessl to BLAS_LIBS if missing from LIBS
274
AS_CASE([$LIBS], [*essl*], [], [BLAS_LIBS="-lessl"])
275
# add -lblas to BLAS_LIBS if missing from LIBS
276
AS_CASE([$LIBS], [*blas*], [], [BLAS_LIBS="$BLAS_LIBS -lblas"])
277
LIBS="$BLAS_LIBS $LIBS"
278
COMEX_RUN_BLAS_TEST()
279
LIBS="$comex_save_LIBS"
280
AC_MSG_RESULT([$comex_blas_ok])])
282
# Generic BLAS library
283
AS_IF([test $comex_blas_ok = no],
284
[AC_MSG_CHECKING([for BLAS in generic library])
286
LIBS="$BLAS_LIBS $LIBS"
287
COMEX_RUN_BLAS_TEST()
288
LIBS="$comex_save_LIBS"
289
AC_MSG_RESULT([$comex_blas_ok])])
291
CPPFLAGS="$comex_save_CPPFLAGS"
292
LDFLAGS="$comex_save_LDFLAGS"
294
AC_SUBST([BLAS_LIBS])
295
AC_SUBST([BLAS_LDFLAGS])
296
AC_SUBST([BLAS_CPPFLAGS])
298
# Tests are complete. Execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
299
AS_IF([test $comex_blas_ok = yes],
302
[AC_MSG_WARN([BLAS library not found, using internal BLAS])
306
AC_DEFINE_UNQUOTED([HAVE_BLAS], [$have_blas],
307
[Define to 1 if using external BLAS library])
308
AC_DEFINE_UNQUOTED([BLAS_SIZE], [$blas_size],
309
[Define to sizeof(INTEGER) used to compile BLAS])
310
AC_DEFINE_UNQUOTED([BLAS_CAXPY], [$caxpy],
311
[Define to name of caxpy routine to call from C])
312
AC_DEFINE_UNQUOTED([BLAS_DAXPY], [$daxpy],
313
[Define to name of daxpy routine to call from C])
314
AC_DEFINE_UNQUOTED([BLAS_SAXPY], [$saxpy],
315
[Define to name of saxpy routine to call from C])
316
AC_DEFINE_UNQUOTED([BLAS_ZAXPY], [$zaxpy],
317
[Define to name of zaxpy routine to call from C])
318
AM_CONDITIONAL([HAVE_BLAS], [test $comex_blas_ok = yes])