3
# Generate Fortran 77 conftest for BLAS.
4
AC_DEFUN([GA_F77_BLAS_TEST], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([],
6
INTEGER M, N, K, LDA, LDB, LDC
7
COMPLEX CA(20,40), CB(20,30), CC(40,30), Calpha, Cbeta
8
DOUBLE COMPLEX ZA(20,40), ZB(20,30), ZC(40,30), Zalpha, Zbeta
9
REAL SA(20,40), SB(20,30), SC(40,30), Salpha, Sbeta
10
DOUBLE PRECISION DA(20,40), DB(20,30), DC(40,30), Dalpha, Dbeta
29
CALL CGEMM ('T','N',M,N,K,Calpha,CA,LDA,CB,LDB,Cbeta,CC,LDC)
30
CALL ZGEMM ('T','N',M,N,K,Zalpha,ZA,LDA,ZB,LDB,Zbeta,ZC,LDC)
31
CALL SGEMM ('T','N',M,N,K,Salpha,SA,LDA,SB,LDB,Sbeta,SC,LDC)
32
CALL DGEMM ('T','N',M,N,K,Dalpha,DA,LDA,DB,LDB,Dbeta,DC,LDC)]])])
37
# Generate C conftest for BLAS.
38
AC_DEFUN([GA_C_BLAS_TEST], [AC_LANG_CONFTEST([AC_LANG_PROGRAM(
50
[[char cresult = cgemm ();
51
char dresult = dgemm ();
52
char sresult = sgemm ();
53
char zresult = zgemm ();
60
# Clears BLAS_LIBS on failure. Sets ga_blas_ok=yes on success.
61
AC_DEFUN([GA_C_RUN_BLAS_TEST], [
64
AC_LINK_IFELSE([], [ga_blas_ok=yes], [BLAS_LIBS=])
68
# GA_F77_RUN_BLAS_TEST
69
# --------------------
70
# Test the Fortran 77 linker.
71
# Clears BLAS_LIBS on failure. Sets ga_blas_ok=yes on success.
72
AC_DEFUN([GA_F77_RUN_BLAS_TEST], [
73
AC_LANG_PUSH([Fortran 77])
75
AC_LINK_IFELSE([], [ga_blas_ok=yes], [BLAS_LIBS=])
76
AC_LANG_POP([Fortran 77])
82
# Clears BLAS_LIBS on failure. Sets ga_blas_ok=yes on success.
83
AC_DEFUN([GA_RUN_BLAS_TEST], [
84
AS_IF([test "x$enable_f77" = xno],
87
AC_LINK_IFELSE([], [ga_blas_ok=yes], [BLAS_LIBS=])
89
[AC_LANG_PUSH([Fortran 77])
91
AC_LINK_IFELSE([], [ga_blas_ok=yes], [BLAS_LIBS=])
92
AC_LANG_POP([Fortran 77])])
95
# GA_BLAS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
96
# -------------------------------------------------
97
# Parse the --with-blas argument and test for all *gemm routines. We use
98
# different tests depending on whether Fortran sources are enabled. There are
99
# many flavors of BLAS that we test for explicitly, although the list could
100
# probably be reduced based on currently available systems.
102
# Apparently certain compilers on BGP define sgemm and dgemm, so we must
103
# test for a different BLAS routine. cgemm seems okay.
105
[AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS])
109
[AS_HELP_STRING([--with-blas[[=ARG]]],
110
[use external BLAS library; attempt to detect sizeof(INTEGER)])],
111
[blas_size_hack=yes])
113
[AS_HELP_STRING([--with-blas4[[=ARG]]],
114
[use external BLAS library compiled with sizeof(INTEGER)==4])],
115
[blas_size=4; with_blas="$with_blas4"])
117
[AS_HELP_STRING([--with-blas8[[=ARG]]],
118
[use external BLAS library compiled with sizeof(INTEGER)==8])],
119
[blas_size=8; with_blas="$with_blas8"])
122
AS_IF([test "x$with_blas" = xno], [ga_blas_ok=skip])
124
# Parse --with-blas argument. Clear previous values first.
128
GA_ARG_PARSE([with_blas], [BLAS_LIBS], [BLAS_LDFLAGS], [BLAS_CPPFLAGS])
130
# Get fortran linker names of BLAS functions to check for.
137
ga_save_LDFLAGS="$LDFLAGS"; LDFLAGS="$BLAS_LDFLAGS $LDFLAGS"
138
ga_save_CPPFLAGS="$CPPFLAGS"; CPPFLAGS="$BLAS_CPPFLAGS $CPPFLAGS"
140
AC_MSG_NOTICE([Attempting to locate BLAS library])
142
# First, check environment/command-line variables.
143
# If failed, erase BLAS_LIBS but maintain BLAS_LDFLAGS and BLAS_CPPFLAGS.
144
AS_IF([test $ga_blas_ok = no],
145
[AC_MSG_CHECKING([for BLAS with user-supplied flags])
146
LIBS="$BLAS_LIBS $LIBS"
149
AS_IF([test $ga_blas_ok = yes],
150
[AS_IF([test $blas_size_hack = yes],
151
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
152
[*ilp64*], [blas_size=8], # Intel MKL
153
[*_int64*], [blas_size=8])])]) # AMD ACML
154
AC_MSG_RESULT([$ga_blas_ok])])
156
# AMD Core Math Library (ACML)
157
AS_IF([test $ga_blas_ok = no],
158
[AC_MSG_CHECKING([for BLAS in AMD Core Math Library])
159
# add -lacml to BLAS_LIBS if missing from LIBS
160
AS_CASE([$LIBS], [*acml*], [], [BLAS_LIBS="-lacml"])
161
LIBS="$BLAS_LIBS $LIBS"
164
AS_IF([test "x$ga_blas_ok" = xyes],
165
[AS_IF([test $blas_size_hack = yes],
166
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
167
[*_int64*], [blas_size=8])])])
168
AC_MSG_RESULT([$ga_blas_ok])])
171
AS_IF([test $ga_blas_ok = no],
172
[AC_MSG_CHECKING([for BLAS in Intel Math Kernel Library])
173
# add -lmkl to BLAS_LIBS if missing from LIBS
174
AS_CASE([$LIBS], [*mkl*], [], [BLAS_LIBS="-lmkl"])
175
LIBS="$BLAS_LIBS $LIBS"
178
AS_IF([test "x$ga_blas_ok" = xyes],
179
[AS_IF([test $blas_size_hack = yes],
180
[AS_CASE(["$BLAS_LIBS $LIBS $LDFLAGS $CPPFLAGS"],
181
[*ilp64*], [blas_size=8])])])
182
AC_MSG_RESULT([$ga_blas_ok])])
184
# ATLAS library (http://math-atlas.sourceforge.net/)
185
AS_IF([test $ga_blas_ok = no],
186
[AC_MSG_CHECKING([for BLAS in ATLAS])
187
AS_IF([test "x$enable_f77" = xno],
188
[# add -lcblas if needed but missing from LIBS
189
AS_CASE([$LIBS], [*cblas*], [], [BLAS_LIBS="-lcblas"])],
190
[# add -lf77blas if needed but missing from LIBS
191
AS_CASE([$LIBS], [*f77blas*], [], [BLAS_LIBS="-lf77blas"])])
192
# add -latlas if needed but missing from LIBS
193
AS_CASE([$LIBS], [*atlas*], [], [BLAS_LIBS="$BLAS_LIBS -latlas"])
194
LIBS="$BLAS_LIBS $LIBS"
197
AC_MSG_RESULT([$ga_blas_ok])])
199
# PhiPACK libraries (requires generic BLAS lib, too)
200
AS_IF([test $ga_blas_ok = no],
201
[AC_MSG_CHECKING([for BLAS in PhiPACK libraries])
202
# add -lblas to BLAS_LIBS if missing from LIBS
203
AS_CASE([$LIBS], [*blas*], [], [BLAS_LIBS="-lblas"])
204
# add -ldgemm to BLAS_LIBS if missing from LIBS
205
AS_CASE([$LIBS], [*dgemm*], [], [BLAS_LIBS="-ldgemm $BLAS_LIBS"])
206
# add -lsgemm to BLAS_LIBS if missing from LIBS
207
AS_CASE([$LIBS], [*sgemm*], [], [BLAS_LIBS="-lsgemm $BLAS_LIBS"])
208
LIBS="$BLAS_LIBS $LIBS"
211
AC_MSG_RESULT([$ga_blas_ok])])
213
# Apple Accelerate.framework
214
AS_IF([test $ga_blas_ok = no],
215
[AC_MSG_CHECKING([for BLAS in Apple Accelerate.framework])
216
# add -framework Accelerate to BLAS_LIBS if missing from LIBS
217
AS_CASE([$LIBS], [*Accelerate*], [], [BLAS_LIBS="-framework Accelerate"])
218
LIBS="$BLAS_LIBS $LIBS"
221
AC_MSG_RESULT([$ga_blas_ok])])
223
# Apple vecLib.framework
224
AS_IF([test $ga_blas_ok = no],
225
[AC_MSG_CHECKING([for BLAS in Apple vecLib.framework])
226
# add -framework vecLib to BLAS_LIBS if missing from LIBS
227
AS_CASE([$LIBS], [*vecLib*], [], [BLAS_LIBS="-framework vecLib"])
228
LIBS="$BLAS_LIBS $LIBS"
231
AC_MSG_RESULT([$ga_blas_ok])])
233
# Alpha CXML library (CXML stands for Compaq Extended Math Library)
234
AS_IF([test $ga_blas_ok = no],
235
[AC_MSG_CHECKING([for BLAS in Alpha CXML library])
236
# add -lcxml to BLAS_LIBS if missing from LIBS
237
AS_CASE([$LIBS], [*cxml*], [], [BLAS_LIBS="-lcxml"])
238
LIBS="$BLAS_LIBS $LIBS"
241
AS_IF([test $ga_blas_ok = no],
242
[# add -lcxml to BLAS_LIBS if missing from LIBS
243
AS_CASE([$LIBS], [*cxml*], [], [BLAS_LIBS="-lcxml"])
244
# add -lcpml to BLAS_LIBS if missing from LIBS
245
AS_CASE([$LIBS], [*cpml*], [], [BLAS_LIBS="$BLAS_LIBS -lcpml"])
246
LIBS="$BLAS_LIBS $LIBS"
248
LIBS="$ga_save_LIBS"])
249
AC_MSG_RESULT([$ga_blas_ok])])
251
# Alpha DXML library (now called CXML, see above)
253
# Sun Performance library
254
AS_IF([test $ga_blas_ok = no],
255
[AC_MSG_CHECKING([for BLAS in Sun Performance Library])
256
# add -xlic_lib=sunperf to BLAS_LIBS if missing from LIBS
257
AS_CASE([$LIBS], [*sunperf*], [], [BLAS_LIBS="-xlic_lib=sunperf"])
258
LIBS="$BLAS_LIBS $LIBS"
261
AS_IF([test $ga_blas_ok = no],
262
[# add -xlic_lib=sunperf to BLAS_LIBS if missing from LIBS
263
AS_CASE([$LIBS], [*sunperf*], [], [BLAS_LIBS="-xlic_lib=sunperf"])
264
# add -lsunmath to BLAS_LIBS if missing from LIBS
265
AS_CASE([$LIBS], [*sunmath*], [], [BLAS_LIBS="$BLAS_LIBS -lsunmath"])
266
LIBS="$BLAS_LIBS $LIBS"
268
LIBS="$ga_save_LIBS"])
269
AC_MSG_RESULT([$ga_blas_ok])])
271
# SCSL library (SCSL stands for SGI/Cray Scientific Library)
272
AS_IF([test $ga_blas_ok = no],
273
[AC_MSG_CHECKING([for BLAS in SGI/Cray Scientific Library])
274
# add -lscs to BLAS_LIBS if missing from LIBS
275
AS_CASE([$LIBS], [*scs*], [], [BLAS_LIBS="-lscs"])
276
LIBS="$BLAS_LIBS $LIBS"
279
AC_MSG_RESULT([$ga_blas_ok])])
282
AS_IF([test $ga_blas_ok = no],
283
[AC_MSG_CHECKING([for BLAS in SGIMATH library])
284
# add -lcomplib.sgimath to BLAS_LIBS if missing from LIBS
285
AS_CASE([$LIBS], [*complib.sgimath*], [], [BLAS_LIBS="-lcomplib.sgimath"])
286
LIBS="$BLAS_LIBS $LIBS"
289
AC_MSG_RESULT([$ga_blas_ok])])
291
# IBM ESSL library (requires generic BLAS lib, too)
292
AS_IF([test $ga_blas_ok = no],
293
[AC_MSG_CHECKING([for BLAS in IBM ESSL library])
294
# add -lessl to BLAS_LIBS if missing from LIBS
295
AS_CASE([$LIBS], [*essl*], [], [BLAS_LIBS="-lessl"])
296
# add -lblas to BLAS_LIBS if missing from LIBS
297
AS_CASE([$LIBS], [*blas*], [], [BLAS_LIBS="$BLAS_LIBS -lblas"])
298
LIBS="$BLAS_LIBS $LIBS"
301
AC_MSG_RESULT([$ga_blas_ok])])
303
# Generic BLAS library
304
AS_IF([test $ga_blas_ok = no],
305
[AC_MSG_CHECKING([for BLAS in generic library])
307
LIBS="$BLAS_LIBS $LIBS"
310
AC_MSG_RESULT([$ga_blas_ok])])
312
CPPFLAGS="$ga_save_CPPFLAGS"
313
LDFLAGS="$ga_save_LDFLAGS"
315
AC_SUBST([BLAS_LIBS])
316
AC_SUBST([BLAS_LDFLAGS])
317
AC_SUBST([BLAS_CPPFLAGS])
319
# Tests are complete. Execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
320
AS_IF([test $ga_blas_ok = yes],
323
[AC_MSG_WARN([BLAS library not found, using internal BLAS])
324
blas_size=$ga_cv_f77_integer_size # reset blas integer size to desired
327
AC_DEFINE_UNQUOTED([HAVE_BLAS], [$have_blas],
328
[Define to 1 if using external BLAS library])
329
AC_DEFINE_UNQUOTED([BLAS_SIZE], [$blas_size],
330
[Define to sizeof(INTEGER) used to compile BLAS])
331
AM_CONDITIONAL([HAVE_BLAS], [test $ga_blas_ok = yes])