1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
|
dnl @synopsis ACX_BLAS
dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
dnl @author Adam Piatyszek <ediap@users.sourceforge.net>
dnl @version 2007-02-15
dnl
dnl This macro looks for a library that implements the BLAS
dnl linear-algebra interface (see http://www.netlib.org/blas/). On
dnl success, it sets the BLAS_LIBS output variable to hold the
dnl requisite library linkages. Besides, it defines HAVE_BLAS.
dnl
dnl To link with BLAS, you should link with:
dnl
dnl $BLAS_LIBS $LIBS
dnl
dnl Many libraries are searched for, e.g. MKL, ACML or ATLAS. The
dnl user may also use --with-blas=<lib> in order to use some specific
dnl BLAS library <lib>. In order to link successfully, however, be
dnl aware that you will probably need to use the same Fortran compiler
dnl (which can be set via the F77 env. var.) as was used to compile the
dnl BLAS library.
dnl
dnl This macro requires autoconf 2.50 or later.
AC_DEFUN([ACX_BLAS], [
AC_PREREQ(2.50)
test "x$sgemm" = x && sgemm=sgemm_
test "x$dgemm" = x && dgemm=dgemm_
# Initialise local variables
acx_blas_ok=no
blas_mkl_ok=no
blas_acml_ok=no
blas_atlas_ok=no
acx_zdotu=auto
# Parse "--with-blas=<lib>" option
AC_ARG_WITH(blas,
[AS_HELP_STRING([--with-blas@<:@=LIB@:>@],
[use BLAS library, optionally specified by LIB])])
case $with_blas in
yes | "") ;;
no) acx_blas_ok=disabled ;;
-* | */* | *.a | *.so | *.so.* | *.o) BLAS_LIBS="$with_blas" ;;
*) BLAS_LIBS="-l$with_blas" ;;
esac
# First, check BLAS_LIBS environment variable
if test "$acx_blas_ok" = no; then
if test "x$BLAS_LIBS" != x; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS])
AC_TRY_LINK_FUNC($sgemm, [acx_blas_ok=yes])
AC_MSG_RESULT($acx_blas_ok)
# Try to use MY_FLIBS
if test "$acx_blas_ok" = no; then
LIBS="$LIBS$MY_FLIBS"
AC_MSG_CHECKING([for $sgemm in $BLAS_LIBS$MY_FLIBS])
AC_TRY_LINK_FUNC($sgemm,
[acx_blas_ok=yes; BLAS_LIBS="$BLAS_LIBS$MY_FLIBS"],
[BLAS_LIBS=""])
AC_MSG_RESULT($acx_blas_ok)
fi
LIBS="$save_LIBS"
fi
fi
# # BLAS linked to by default? (happens on some supercomputers)
# if test $acx_blas_ok = no; then
# save_LIBS="$LIBS"; LIBS="$LIBS"
# AC_CHECK_FUNC($sgemm, [acx_blas_ok=yes])
# LIBS="$save_LIBS"
# fi
# BLAS in MKL library?
# (http://www.intel.com/cd/software/products/asmo-na/eng/perflib/mkl/index.htm)
if test "$acx_blas_ok" = no; then
AC_CHECK_LIB([mkl], [$sgemm],
[acx_blas_ok=yes; blas_mkl_ok=yes; acx_zdotu=void;
BLAS_LIBS="-lmkl -lguide -lpthread"],
[],
[-lguide -lpthread])
fi
# BLAS in ACML library? (http://developer.amd.com/acml.aspx)
# +------------+-----------+---------------------+
# | | 32-bit | 64-bit |
# +------------+-----------+---------------------+
# | GCC < 4.2 | -lacml | -lacml -lacml_mv |
# | GCC >= 4.2 | -lacml_mp | -lacml_mp -lacml_mv |
# +------------+-----------+---------------------+
if test "$acx_blas_ok" = no; then
save_LIBS="$LIBS"; LIBS="$LIBS$MY_FLIBS"
AC_CHECK_LIB([acml], [$sgemm],
[acx_blas_ok=yes; blas_acml_ok=yes; BLAS_LIBS="-lacml$MY_FLIBS"],
[AC_CHECK_LIB([acml_mp], [$sgemm],
[acx_blas_ok=yes; blas_acml_ok=yes; BLAS_LIBS="-lacml_mp$MY_FLIBS"],
[AC_CHECK_LIB([acml], [$dgemm],
[acx_blas_ok=yes; blas_acml_ok=yes;
BLAS_LIBS="-lacml -lacml_mv$MY_FLIBS"],
[AC_CHECK_LIB([acml_mp], [$dgemm],
[acx_blas_ok=yes; blas_acml_ok=yes;
BLAS_LIBS="-lacml_mp -lacml_mv$MY_FLIBS"],
[], [-lacml_mv])],
[], [-lacml_mv])],
[])],
[])
LIBS="$save_LIBS"
fi
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
if test "$acx_blas_ok" = no; then
save_LIBS="$LIBS"; LIBS="$LIBS$MY_FLIBS"
AC_CHECK_LIB(atlas, ATL_xerbla,
[AC_CHECK_LIB(f77blas, $sgemm,
[AC_CHECK_LIB(cblas, cblas_dgemm,
[acx_blas_ok=yes; blas_atlas_ok=yes;
BLAS_LIBS="-lcblas -lf77blas -latlas$MY_FLIBS"],
[], [-lf77blas -latlas])],
[], [-latlas])])
LIBS="$save_LIBS"
fi
# # BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(blas, $sgemm,
# [AC_CHECK_LIB(dgemm, $dgemm,
# [AC_CHECK_LIB(sgemm, $sgemm,
# [acx_blas_ok=yes; BLAS_LIBS="-lsgemm -ldgemm -lblas"],
# [], [-lblas])],
# [], [-lblas])])
# fi
# # BLAS in Alpha CXML library?
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(cxml, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lcxml"])
# fi
# # BLAS in Alpha DXML library? (now called CXML, see above)
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(dxml, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-ldxml"])
# fi
# # BLAS in Sun Performance library?
# if test $acx_blas_ok = no; then
# if test "x$GCC" != xyes; then # only works with Sun CC
# AC_CHECK_LIB(sunmath, acosp,
# [AC_CHECK_LIB(sunperf, $sgemm,
# [acx_blas_ok=yes; BLAS_LIBS="-xlic_lib=sunperf -lsunmath"], [],
# [-lsunmath])])
# fi
# fi
# # BLAS in SCSL library? (SGI/Cray Scientific Library)
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(scs, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lscs"])
# fi
# # BLAS in SGIMATH library?
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(complib.sgimath, $sgemm,
# [acx_blas_ok=yes; BLAS_LIBS="-lcomplib.sgimath"])
# fi
# # BLAS in IBM ESSL library? (requires generic BLAS lib, too)
# if test $acx_blas_ok = no; then
# AC_CHECK_LIB(blas, $sgemm,
# [AC_CHECK_LIB(essl, $sgemm,
# [acx_blas_ok=yes; BLAS_LIBS="-lessl -lblas"], [], [-lblas $FLIBS])])
# fi
# Generic BLAS library?
if test "$acx_blas_ok" = no; then
AC_CHECK_LIB(blas, $sgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas"],
[AC_CHECK_LIB(blas, $dgemm, [acx_blas_ok=yes; BLAS_LIBS="-lblas$MY_FLIBS"],
[], [$MY_FLIBS])])
fi
# if BLAS is found check what kind of BLAS it is
if test "$acx_blas_ok" = yes && test "$blas_mkl_ok" = no \
&& test "$blas_acml_ok" = no && test "$blas_atlas_ok" = no; then
save_LIBS="$LIBS"; LIBS="$BLAS_LIBS $LIBS"
AC_MSG_CHECKING([for MKLGetVersion in $BLAS_LIBS])
AC_TRY_LINK_FUNC(MKLGetVersion, [blas_mkl_ok=yes; acx_zdotu=void])
AC_MSG_RESULT($blas_mkl_ok)
if test "$blas_mkl_ok" = no; then
AC_MSG_CHECKING([for acmlversion in $BLAS_LIBS])
AC_TRY_LINK_FUNC(acmlversion, [blas_acml_ok=yes])
AC_MSG_RESULT($blas_acml_ok)
fi
if test "$blas_mkl_ok" = no && test "$blas_acml_ok" = no; then
AC_MSG_CHECKING([for ATL_xerbla in $BLAS_LIBS])
AC_TRY_LINK_FUNC(ATL_xerbla, [blas_atlas_ok=yes])
AC_MSG_RESULT($blas_atlas_ok)
fi
LIBS="$save_LIBS"
fi
# Parse "--with-zdotu=..." option
AC_ARG_WITH(zdotu,
[AS_HELP_STRING([--with-zdotu=@<:@zdotusub|void|none@:>@],
[use zdotu_ with a specified calling method])])
case $with_zdotu in
zdotusub) acx_zdotu=zdotusub ;;
void) acx_zdotu=void ;;
none | no) acx_zdotu=disabled ;;
*) ;;
esac
# Check if zdotusub_ Fortran wrapper should be used
if test "$acx_blas_ok" = yes; then
case $acx_zdotu in
zdotusub)
if test "x$F77" = x; then
AC_MSG_ERROR([a Fortran compiler is required to use zdotusub_ wrapper])
fi
AC_DEFINE(HAVE_ZDOTUSUB, 1, [Define to use zdotusub_ Fortran wrapper.]) ;;
void)
AC_DEFINE(HAVE_ZDOTU_VOID, 1, [Define to use "void zdotu_()".]) ;;
disabled) ;;
auto)
if test "x$F77" != x; then
AC_DEFINE(HAVE_ZDOTUSUB, 1, [Define to use zdotusub_ Fortran wrapper.])
acx_zdotu=zdotusub
else
AC_MSG_WARN([do not know how to call the zdotu_ BLAS function.
Not using this function in the Vec::dot() method. You might want to use
"--with-zdotu=@<:@zdotusub|void|none@:>@" option to explicitly set the
proper calling method of this BLAS function. Please report this problem
on the IT++ Help forum.])
acx_zdotu=no
fi
;;
esac
fi
AC_SUBST(BLAS_LIBS)
# Finally, define HAVE_BLAS
if test "$acx_blas_ok" = yes; then
AC_DEFINE(HAVE_BLAS, 1, [Define if you have a BLAS library.])
if test "$blas_mkl_ok" = yes; then
AC_DEFINE(HAVE_BLAS_MKL, 1, [Define if you have an MKL BLAS library.])
fi
if test "$blas_acml_ok" = yes; then
AC_DEFINE(HAVE_BLAS_ACML, 1, [Define if you have an ACML BLAS library.])
fi
if test "$blas_atlas_ok" = yes; then
AC_DEFINE(HAVE_BLAS_ATLAS, 1, [Define if you have an ATLAS BLAS library.])
fi
else
if test "$acx_blas_ok" != disabled; then
AC_MSG_ERROR([cannot find any BLAS library, which is required by LAPACK.
You can override this error by using "--without-blas" option, but the
functionality of the IT++ library will be limited. You have been warned!])
fi
fi
])dnl ACX_BLAS
|