diff options
author | bacon <bacon@pkgsrc.org> | 2020-10-12 21:51:57 +0000 |
---|---|---|
committer | bacon <bacon@pkgsrc.org> | 2020-10-12 21:51:57 +0000 |
commit | afefcaa6e54efd2e5b8f95abf655d5d040ae36be (patch) | |
tree | 301b42c86078439d0507aa5e1cb691c3fb6da5d2 /mk | |
parent | 064b357d6f40e50256ec30d40eeb2381a21baa63 (diff) | |
download | pkgsrc-afefcaa6e54efd2e5b8f95abf655d5d040ae36be.tar.gz |
math/blas, math/lapack: Install interchangeable BLAS system
Install the new interchangeable BLAS system created by Thomas Orgis,
currently supporting Netlib BLAS/LAPACK, OpenBLAS, cblas, lapacke, and
Apple's Accelerate.framework. This system allows the user to select any
BLAS implementation without modifying packages or using package options, by
setting PKGSRC_BLAS_TYPES in mk.conf. See mk/blas.buildlink3.mk for details.
This commit should not alter behavior of existing packages as the system
defaults to Netlib BLAS/LAPACK, which until now has been the only supported
implementation.
Details:
Add new mk/blas.buildlink3.mk for inclusion in dependent packages
Install compatible Netlib math/blas and math/lapack packages
Update math/blas and math/lapack MAINTAINER approved by adam@
OpenBLAS, cblas, and lapacke will follow in separate commits
Update direct dependents to use mk/blas.buildlink3.mk
Perform recursive revbump
Diffstat (limited to 'mk')
-rw-r--r-- | mk/blas.buildlink3.mk | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/mk/blas.buildlink3.mk b/mk/blas.buildlink3.mk new file mode 100644 index 00000000000..92ffa0a3c08 --- /dev/null +++ b/mk/blas.buildlink3.mk @@ -0,0 +1,108 @@ +# $NetBSD: blas.buildlink3.mk,v 1.1 2020/10/12 21:51:57 bacon Exp $ +# +# This Makefile fragment is meant to be included by packages that use any BLAS +# (Basic Linear Algebra System) implementation instead of one particular one. +# +# Since pkgsrc always ships BLAS and LAPACK together (as upstream +# implementations do), this adds both BLAS_LIBS and LAPACK_LIBS to the linker +# flags. Often, they will be identical or at least redundant. It is a matter +# of style to stay consistent in their use. +# +# Keywords: blas lapack atlas openblas mkl +# +# === User-settable variables === +# +# PKGSRC_BLAS_TYPES +# This value specifies an exhaustive list of BLAS implementations we wish to +# use in this pkgsrc installation, in descending order of preference. +# The implementation selected for a build will be the first one in +# PKGSRC_BLAS_TYPES that also appears in BLAS_ACCEPTED (see below). +# Typically set in mk.conf. +# +# Possible: one or more of netlib, openblas, openblas_pthread, +# openblas_openmp, and Apple's accelerate.framework +# (to come: Intel MKL, other external optimized builds) +# +# Default: All currently supported implementations (${_BLAS_TYPES}) +# +# === Package-settable variables === +# +# BLAS_ACCEPTED +# This is a list of blas packages that are compatible with the current +# package. If not set, any BLAS implementation is OK. +# Typically set in package Makefile. +# +# === Variables automatically set here for use in package builds === +# +# BLAS_TYPE +# This is the BLAS implementation chosen for a particular package build from +# PKGSRC_BLAS_TYPES and BLAS_ACCEPTED. If PKGSRC_BLAS_TYPES and +# BLAS_ACCEPTED have no implementations in common, it defaults to none +# and the build fails. +# BLAS_LIBS +# Linker flags used for linking to BLAS library +# LAPACK_LIBS +# Linker flags used for linking to LAPACK library + +.if !defined(MK_BLAS_BUILDLINK3_MK) +MK_BLAS_BUILDLINK3_MK= + +BUILD_DEFS+= PKGSRC_BLAS_TYPES +BUILD_DEFS_EFFECTS+= BLAS_TYPE BLAS_LIBS LAPACK_LIBS + +# TODO: Upon commit change to: .include "bsd.prefs.mk" +.include "../../mk/bsd.prefs.mk" + +# List of all possible BLAS choices, in order of *DEFAULT* preference. +# netlib is the reference implementation to which all others conform and +# should come first by default for maximum compatibility. It is also the +# slowest and not desirable in many situations. Users can override by setting +# PKGSRC_BLAS_TYPES. (See comment above) +_BLAS_TYPES= netlib openblas openblas_pthread openblas_openmp +# Darwin +.if exists(/System/Library/Frameworks/Accelerate.framework) +_BLAS_TYPES+= accelerate.framework +.endif + +BLAS_ACCEPTED?= ${_BLAS_TYPES} +PKGSRC_BLAS_TYPES?= ${_BLAS_TYPES} + +_BLAS_MATCH= +.for b in ${PKGSRC_BLAS_TYPES} +_BLAS_MATCH+= ${BLAS_ACCEPTED:M${b}} +.endfor +.if !empty(_BLAS_MATCH) +BLAS_TYPE= ${_BLAS_MATCH:[1]} +.else +BLAS_TYPE= none +.endif + +.if ${BLAS_TYPE} == "netlib" +_BLAS_PKGPATH= math/lapack +BLAS_LIBS= -lblas +LAPACK_LIBS= -llapack ${BLAS_LIBS} +.elif ${BLAS_TYPE} == "openblas" +_BLAS_PKGPATH= math/openblas +BLAS_LIBS= -lopenblas +LAPACK_LIBS= ${BLAS_LIBS} +.elif ${BLAS_TYPE} == "openblas_pthread" +_BLAS_PKGPATH= math/openblas_pthread +BLAS_LIBS= -lopenblas_pthread +LAPACK_LIBS= ${BLAS_LIBS} +.elif ${BLAS_TYPE} == "openblas_openmp" +_BLAS_PKGPATH= math/openblas_openmp +BLAS_LIBS= -lopenblas_openmp +LAPACK_LIBS= ${BLAS_LIBS} +.elif ${BLAS_TYPE} == "accelerate.framework" +BLAS_LIBS= -framework Accelerate +LAPACK_LIBS= ${BLAS_LIBS} +.else # invalid or unimplemented type +PKG_FAIL_REASON+= \ + "There is no acceptable BLAS for ${PKGNAME} in: ${PKGSRC_BLAS_TYPES}." +.endif + +.if defined(_BLAS_PKGPATH) +.include "../../${_BLAS_PKGPATH}/buildlink3.mk" +.endif + +.endif # BLAS_BUILDLINK3_MK |