tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Bring BLAS into pkgsrc, pt. II
Hello again from the scientific computing corner,
I just pushed a new version of wip/mk/blas.buildlink3.mk (also attached
for easier review), incorporating changes from our discussion in March
to May [1].
I really would like to get this from wip into pkgsrc proper. The steps:
1. Import blas.bl3 into pkgsrc/mk
2. Import these packages and make them use mk/blas.bl3 instead of
wip/mk/blas.bl3, where appropriate:
wip/lapack: Netlib reference (libblas.so, liblapack.so)
wip/blas: a dummy that just depends on the above
wip/openblas: single-threaded OpenBLAS (libopenblas.so)
wip/openblas_pthread: threaded OpenBLAS (libopenblas_pthread.so)
wip/openblas_openmp: OpenMP OpenBLAS (libopenblas_openmp.so)
wip/cblas: C wrapper over BLAS
wip/lapacke: C wrapper over LAPACK
3. Start replacing any of
.include "../../math/blas/buildlink3.mk"
.include "../../math/lapack/buildlink3.mk"
with
.include "../../mk/blas.buildlink3.mk"
in packages and possibly add/change machinery to actually support
differing implementations (add BLAS_LIBS to MAKE_ENV, for example).
I have patches ready for math/octave, math/py-numpy, math/R,
math/R-gstat, and math/R-quantreg.
We can pause after each step without breaking existing packages. The
upgrade from an installed math/blas might be uncomfortable, as the
binaries all move to math/lapack. I don't know what I can do about
that. But apart from that, I expect a gentle process.
So, can we make it happen?
Alrighty then,
Thomas
[1] https://mail-index.netbsd.org/tech-pkg/2019/03/26/msg020982.html
--
Dr. Thomas Orgis
HPC @ Universität Hamburg
# $NetBSD$
#
# This Makefile fragment is meant to be included by packages
# that use any BLAS implementation instead of one particular one.
#
# Since we always ship BLAS and LAPACK together (as upstream variants
# do), this sets both BLAS_LIBS to the linker flags needed to pull in
# the BLAS library and LAPACK_LIBS to the flags for the LAPACK library.
# Often, they will be identical or at least redundant. It is a matter
# of style to stay consistent in their use.
# TODO: Also set a variable to find a matching pkg-config file
# to avoid duplicating its contents in BLAS_LIBS?
#
# === User-settable variables ===
#
# PKGSRC_BLAS_PREFERRED
# This value specifies an exhaustive list of BLAS implementations
# we wish to use on the system, in descending order of preference.
#
# Possible: one or more of netlib, openblas, openblas_pthread,
# openblas_openmp, and accelerate.framework
# (to come: Intel MKL, other external optimized builds)
#
# Default: netlib
#
# === Per-package variables ===
#
# BLAS_ACCEPTED
# This is a list of blas packages that are compatible with the current
# package. If not set, any package is OK.
#
# === Variables for package Makefiles to use ===
#
# BLAS_TYPE
# This is the finally selected type of BLAS from BLAS_PREFERRED or none.
# BLAS_LIBS
# linker flags to use for linking to BLAS library
# LAPACK_LIBS
# linker flags to use for linking to LAPACK library
BUILD_DEFS+= PKGSRC_BLAS_PREFERRED
BUILD_DEFS_EFFECTS+= BLAS_TYPE BLAS_LIBS LAPACK_LIBS
.if !defined(BLAS_BUILDLINK3_MK)
BLAS_BUILDLINK3_MK=
.include "../../mk/bsd.prefs.mk"
# List of all possible BLAS choices.
_BLAS_TYPES= netlib openblas openblas_pthread openblas_openmp
.if exists(/System/Library/Frameworks/Accelerate.framework)
_BLAS_TYPES+= accelerate.framework
.endif
BLAS_ACCEPTED?= ${_BLAS_TYPES}
PKGSRC_BLAS_PREFERRED?= netlib openblas
_BLAS_MATCH=
.for b in ${PKGSRC_BLAS_PREFERRED}
_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_PACKAGE= wip/lapack
BLAS_LIBS= -lblas
LAPACK_LIBS= -llapack ${BLAS_LIBS}
.elif ${BLAS_TYPE} == "openblas"
_BLAS_PACKAGE= wip/openblas
BLAS_LIBS= -lopenblas
LAPACK_LIBS= ${BLAS_LIBS}
.elif ${BLAS_TYPE} == "openblas_pthread"
_BLAS_PACKAGE= wip/openblas_pthread
BLAS_LIBS= -lopenblas_pthread
LAPACK_LIBS= ${BLAS_LIBS}
.elif ${BLAS_TYPE} == "openblas_openmp"
_BLAS_PACKAGE= wip/openblas_openmp
BLAS_LIBS= -lopenblas_openmp
LAPACK_LIBS= ${BLAS_LIBS}
.elif ${BLAS_TYPE} == "accelerate.framework"
BLAS_LIBS= -framework Accelerate
LAPACK_LIBS= ${BLAS_LIBS}
# TODO: atlas
# TODO: external BLAS (other OpenBLAS/ATLAS, Intel MKL)
.else # invalid or unimplemented type
PKG_FAIL_REASON+= \
"There is no acceptable BLAS for ${PKGNAME} in: ${PKGSRC_BLAS_PREFERRED}."
.endif
.if defined(_BLAS_PACKAGE)
.include "../../${_BLAS_PACKAGE}/buildlink3.mk"
.endif
.endif # BLAS_BUILDLINK3_MK
Home |
Main Index |
Thread Index |
Old Index