From 723823dd50a4f4323781cadb223de316de9bf6c7 Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Thu, 5 Nov 2026 20:32:26 +0100 Subject: [PATCH] configure.ac - search for openblas too --- configure.ac | 43 ++++++++++++++++++++++++++++++++++++------- doc/building.tex | 9 +++++++-- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 920d933..8dffb1f 100755 --- a/configure.ac +++ b/configure.ac @@ -40,14 +40,41 @@ then MKLOPT="-DHAS_MKL" AC_SUBST([MKLOPT]) else - echo "MKL LIBRARY OR HEADER NOT FOUND, will try ATLAS next!" + echo "MKL LIBRARY OR HEADER NOT FOUND, will try OpenBLAS next!" +fi + +FORINTOPT="" +forint64="" +AC_ARG_ENABLE([fortran64int],[ --enable-fortran64int to link with 64-bit-integer-BLAS+LAPACK ],[forint64=${enableval}],) +AC_ARG_ENABLE([fotran64int],[ --enable-fotran64int old misspelled alias of --enable-fortran64int ],[forint64=${enableval}],) + +# OpenBLAS (with LAPACK and CBLAS included) is preferred if MKL is not present; not for 64-bit integers +openblas_present=0 +AC_ARG_WITH([openblas],[ --without-openblas do not use OpenBLAS even if found (use ATLAS or reference BLAS)],[],[with_openblas=yes]) +case "${forint64}" in + ""|no) ;; + *) with_openblas=no ;; +esac +if test $mkl_present == 0 -a "${with_openblas}" != no +then +AC_CHECK_LIB([openblas], [dgeev_], [AC_CHECK_LIB([openblas], [cblas_dgemm], [openblas_present=1])]) +fi +if test $openblas_present == 1 +then + echo "OPENBLAS FOUND" + BLASLIB="-lopenblas" + AC_SUBST([BLASLIB]) + CLAPACKOPT=-DNONCLAPACK + AC_SUBST([CLAPACKOPT]) +else + echo "OPENBLAS NOT FOUND OR NOT USED, will try ATLAS next!" fi # Checks for mandatory libraries. ATLASLIB="" -if test $mkl_present == 0 +if test $mkl_present == 0 -a $openblas_present == 0 then AC_CHECK_LIB([atlas], [ATL_zgemv],ATLASLIB="-lblas -latlas", [ echo "ATLAS not found, I hope you are using some other efficient BLAS!" @@ -75,7 +102,13 @@ AC_ARG_ENABLE([matptr],[ --enable-matptr switch to double** matrix representa CBLASLIB="" CBLASOPT="" -if test $mkl_present == 0 +if test $openblas_present == 1 +then +AC_CHECK_HEADER([cblas.h],,[CBLASOPT=-DNONCBLAS], AC_INCLUDES_DEFAULT) +AC_SUBST([CBLASOPT]) +fi + +if test $mkl_present == 0 -a $openblas_present == 0 then AC_CHECK_LIB([cblas], [cblas_ddot], [CBLASLIB="-lcblas"], [CBLASOPT=-DNONCBLAS],[$ATLASLIB]) AC_CHECK_HEADER([cblas.h],,[CBLASOPT=-DNONCBLAS CBLASLIB=""], AC_INCLUDES_DEFAULT) @@ -107,10 +140,6 @@ AC_SUBST([MATPTROPT]) #process options -FORINTOPT="" -forint64="" -AC_ARG_ENABLE([fortran64int],[ --enable-fortran64int to link with 64-bit-integer-BLAS+LAPACK ],[forint64=${enableval}],) -AC_ARG_ENABLE([fotran64int],[ --enable-fotran64int old misspelled alias of --enable-fortran64int ],[forint64=${enableval}],) if test -n "${forint64}"; then case "${forint64}" in yes) FORINTOPT="-DLONG_FORTRAN_INT" diff --git a/doc/building.tex b/doc/building.tex index 7765416..5456064 100644 --- a/doc/building.tex +++ b/doc/building.tex @@ -5,7 +5,7 @@ \begin{itemize} \item a C++11 capable compiler (the library is developed with GNU g++), \item BLAS and LAPACK (Fortran interface); optionally the C interfaces CBLAS and CLAPACK, - or Intel MKL, or ATLAS, + or Intel MKL, or OpenBLAS, or ATLAS, \item GNU autotools (autoconf, automake, libtool) when building from the git repository, \item optionally NVIDIA CUBLAS (experimental, section~\ref{sec:concepts:gpu}), \item optionally doxygen for the generated source code reference, which is independent of this manual. @@ -29,6 +29,10 @@ accordingly: \begin{enumerate} \item Intel MKL (\code{mkl_intel_lp64}, \code{mkl_sequential}, \code{mkl_core} and the header \header{mkl_cblas.h}); if found, \code{-DHAS_MKL -DNONCLAPACK} is used; +\item otherwise OpenBLAS, if \code{libopenblas} contains LAPACK (\code{dgeev_}) and CBLAS (\code{cblas_dgemm}): only + \code{-lopenblas} is linked, \code{-DNONCLAPACK} is used and \code{-DNONCBLAS} if \header{cblas.h} is missing; skipped + with \code{--without-openblas} and with \code{--enable-fortran64int}. A threaded OpenBLAS uses all cores unless + \code{OPENBLAS_NUM_THREADS} is set; \item otherwise ATLAS (optional) and the reference BLAS (mandatory), CBLAS (if \code{cblas_ddot} and \header{cblas.h} are not found, \code{-DNONCBLAS} is set) and LAPACK (mandatory; if the C interface \code{clapack_dgesv} with \header{clapack.h} is not found, \code{-DNONCLAPACK} is set); @@ -47,7 +51,8 @@ accordingly: \code{--enable-optimize=} & compiler optimization flags, default \code{-O3 -finline-limit=1000}; \code{--disable-optimize} for none \\ \code{--enable-profile} & compile with \code{-pg} \\ \code{--enable-matptr} & define \code{MATPTR}: \code{NRMat} stores an array of row pointers (\code{T**}), see chapter~\ref{ch:mat}; incompatible with CUDA \\ -\code{--enable-fortran64int} & define \code{LONG_FORTRAN_INT} to link with BLAS and LAPACK using 64-bit integers; implies \code{NONCBLAS} and \code{NONCLAPACK} (the old misspelling \code{--enable-fotran64int} is accepted as an alias) \\ +\code{--enable-fortran64int} & define \code{LONG_FORTRAN_INT} to link with BLAS and LAPACK using 64-bit integers; implies \code{NONCBLAS} and \code{NONCLAPACK} (the old misspelling \code{--enable-fotran64int} is accepted as an alias); OpenBLAS is then not used \\ +\code{--without-openblas} & do not use OpenBLAS even if found (ATLAS or the reference BLAS is used) \\ \bottomrule \end{longtable}