[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Math, BLAS/LAPACK m4 checks



Hello,

Just FYI, here's something which may be useful to authors of autoconf-using math software, with a particular bent to the way BLAS/LAPACK is done on Debian, and attention to Alpha issues such as -mieee and the Q (er, HPaq?) math libs, etc. It's a rough draft of a very small thing, feel free to use and modify, share and enjoy, comment or criticize, etc., and if you have something better, I'd love to hear about it.

BTW, I'd like to have my cxml package provide blas2 and/or lapack2, but can't quite figure how to do that. If I make symlinks from /usr/lib/libblas2.so etc. then that's not a problem at build-time, but what about runtime? Do I need to symlink /usr/lib/libblas.so.2 to libcxml.so? In that case, will it conflict with blas and lapack?

Zeen,
--

-Adam P.

GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6

Welcome to the best software in the world today cafe! <http://lyre.mit.edu/%7Epowell/The_Best_Stuff_In_The_World_Today_Cafe.ogg>

dnl Math and linear algebra checks by Adam Powell last modified 2002-08-07.
dnl Copyright 2000 Adam Powell, redistributable under the terms of the GNU
dnl General Public License version 2 or later.
dnl
dnl Then again, since none of this is "incorporated" in any software generated
dnl except perhaps a configure script, its application to non-GPL-compatible
dnl software packages is not clear at this point... in that regard, use at your
dnl own risk.

AC_DEFUN([MATH_BLASLAPACK_CHECKS],[
	dnl ffm is free fast math by Joachim Wesner and Kazushige Goto for
	dnl Linux/Alpha.
	AC_CHECK_HEADERS(libffm.h)
	AC_CHECK_LIB(ffm, dsqrtiv,
		MATH_LIBS="$MATH_LIBS -lffm" MATH_INCLUDES="-DFFM")

	dnl Alphas need this sometimes
	AC_CHECKING([whether -mieee is needed to avoid SIGFPE on divide by zero])
	case $build/$CC in
		alpha*/gcc* )
			MIEEE_CFLAGS="-mieee"
			AC_MSG_RESULT([yes])
			;;
		* )
			MIEEE_CFLAGS=""
			AC_MSG_RESULT([not needed])
			;;
	esac
	AC_SUBST(MIEEE_CFLAGS)

	dnl Used to check for IRIX multi-processor BLAS, but result was
	dnl EXTREMELY slow (here just for historical purposes)
	dnl AC_CHECK_LIB(blas_mp, dgemm_, BLAS_LIBS="-mp -lblas_mp", [
	dnl   AC_CHECK_LIB(f77blas, dgemm_, BLAS_LIBS="-lf77blas -latlas", [
	dnl     LIBS="$aLIBS $MATH_LIBS $FLIBS"])])
	dnl For some reason, the Debian BLAS/LAPACK maintainer decided blas2
	dnl and lapack2 are good names for the alternatives symlinks; I'm
	dnl prefering those over blas and lapack.  For now, I don't see a need
	dnl for mixed blas/lapack2 or blas2/lapack, only blas2/lapack2 and
	dnl blas/lapack are checked.
	AC_F77_LIBRARY_LDFLAGS
	aLIBS="$LIBS"
	LIBS="$aLIBS $FLIBS"
	AC_CHECK_LIB(blas2, dgemm_, [
		HAVE_BLAS="yes" LIBS="-lblas2 $aLIBS $FLIBS"
		AC_CHECK_LIB(lapack2, dgetrf_,
			HAVE_LAPACK="yes"
			BLASLAPACK_LIBS="-lblas2 -llapack2 $FLIBS",
			BLASLAPACK_LIBS="-lblas2 $FLIBS")], [
		AC_CHECK_LIB(blas, dgemm_, [
			HAVE_BLAS="yes" LIBS="$aLIBS -lblas $FLIBS"
			AC_CHECK_LIB(lapack, dgetrf_,
				HAVE_LAPACK="yes"
				BLASLAPACK_LIBS="-lblas -llapack $FLIBS",
				BLASLAPACK_LIBS="-lblas $FLIBS")])])
	LIBS="$aLIBS"

	dnl cpml is the Compaq Portable Math Library for Linux/Alpha, and often
	dnl comes with cxml which has superfast blas/lapack included, so this
	dnl overrides the above BLAS and LAPACK checks.
	aLIBS="$LIBS"
	LIBS="$aLIBS -lots"
	AC_CHECK_LIB(cpml, sqrt,
		MATH_LIBS="$MATH_LIBS -lots -lcpml" MATH_INCLUDES=""
		LIBS="$aLIBS -lots -lcpml" [
			AC_CHECK_LIB(cxml, dgemm_,
				BLASLAPACK_LIBS="$MATH_LIBS -lcxml"
				HAVE_BLAS="yes" HAVE_LAPACK="yes",
				MATH_LIBS="$MATH_LIBS -lm" MATH_INCLUDES="")])
	LIBS="$aLIBS"

	AC_SUBST(MATH_LIBS)
	AC_SUBST(MATH_INCLUDES)
	AC_SUBST(BLASLAPACK_LIBS)
	AC_SUBST(HAVE_BLAS)
	AC_SUBST(HAVE_LAPACK)
])

Reply to: