tech-pkg archive

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

Please consider inclusion of my mk/blas.buildlink3.mk and the wip/openblas{,_pthread,_openmp} packages



TL;DR:
	1. Please import attached file to pkgsrc/mk/blas.buildlink3.mk .
	2. Please import wip/openblas{,_pthread,_openmp} .

Hi,

I am finally getting around fixing up the BLAS situation in pkgsrc.
There is a new set of packages to replace and extend the current
math/lapack and wip/cblas:

wip/lapack-ng: liblapack.so and libblas.so from netlib reference code
wip/cblas-ng: C interface to any BLAS library
wip/lapacke-ng: C interface to any LAPACK library

Attached is my mk/blas.buildlink3.mk that I am testing right now with
a patched (simplified) math/R. It reads a variable BLAS_TYPE and then
includes the matching package's buildlink3.mk, also setting BLAS_LIBS
and LAPACK_LIBS to help configure things.

It's clear that it is rather late in the release cycle to push the
upated wip/lapack over math/lapack and math/blas (what would be a clean
way to deprecate the latter?). But I would like to ease further
development (me pushing changes in wip that rely on it) by including
the attached file in the main pkgsrc tree.

Reminder about the removal of math/blas: We're building LAPACK and
BLAS together from one source as it is customary for optimized BLAS
implementations to also include (partially) optimized LAPACK. It makes
no sense separating these two and two packages for the netlib code
would make things rather difficult for changing the implementation.
Also, we do support all implementations being installed next to each
other, with the name libblas.so being reserved for the netlib code.
Including mk/blas.buildlink3.mk helps choosing one of them for a build.

I opted for offering wip/cblas-ng and wip/lapacke-ng from the netlib
code to ensure that we have one source for the rather straightforward C
wrapper libraries. Both are also often included with optimized BLAS
libraries, but I think there is value in keeping the API clear by using
the reference implementations.

Also, I think it makes sense to finally import wip/openblas,
wip/openblas_pthread, and wip/openblas_openmp. They have been sitting
around on the previous version for over half a year. I just made some
small changes to bring the version up to date. If they are imported,
the paths in the attached blas.buildlink3.mk need adjustment, of course.

Of course, feel free to discuss things to pieces before including
anything. I just wanted to sound optimistic for a start;-)


Alrighty then,

Thomas

-- 
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 ===
#
# BLAS_TYPE
#	This value represents the type of BLAS we wish to use on the system.
#
#	Possible: netlib, openblas, openblas_pthread, openblas_openmp
#	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.

.if !defined(BLAS_BUILDLINK3_MK)
BLAS_BUILDLINK3_MK=	# define it

.include "../../mk/bsd.prefs.mk"

# List of all possible BLAS choices.
_BLAS_TYPES=	netlib openblas openblas_pthread openblas_openmp
# Add Accelerate framework on Darwin (pulled from math/R).
.if exists(/System/Library/Frameworks/Accelerate.framework)
_BLAS_TYPES+=	accelerate.framework
.endif
# Currently chosen type.
# Default is the standard, slow, easily available.
BLAS_TYPE?=	netlib
BLAS_LIBS=
BLAS_ACCEPTED?= ${_BLAS_TYPES}

.  if !empty(BLAS_ACCEPTED:M${BLAS_TYPE})
_BLAS_TYPE=     ${BLAS_TYPE}
.  else
_BLAS_TYPE=     none
.  endif

.if $(_BLAS_TYPE) == "netlib"
_BLAS_PACKAGE=	wip/lapack-ng
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+=	\
	"${BLAS_TYPE} is not an acceptable BLAS type for ${PKGNAME}."
.endif

.if defined(_BLAS_PACKAGE)
.include "../../${_BLAS_PACKAGE}/buildlink3.mk"
.endif

.endif	# BLAS_BUILDLINK3_MK


Home | Main Index | Thread Index | Old Index