Updating numpy port to use blaslapack
Roland Smith
rsmith at xs4all.nl
Sun Feb 8 17:45:56 UTC 2015
After some experimentation I found that openblas can be significantly faster
than atlas (at least on AMD64). Combined with the recent introduction of
/usr/ports/Mk/Uses/blaslapack.mk it seemed a good idea to update the numpy
port to enable the use of openblas or atlas or netlib.
A patch to do that is given below. When using openblas, it uses the parallel
version. I've tested it with atlas and openblas on 10.1-STABLE AMD64.
Portlint gives no errors.
Before I submit a PR, I'd like to ask volunteers for testing on other
releases/architectures as well as testing with the default netlib BLAS/LAPACK.
----- numpy updated to build with blaslapack -----
diff -ruN py-numpy.orig/Makefile py-numpy/Makefile
--- py-numpy.orig/Makefile 2015-01-02 17:36:43.000000000 +0100
+++ py-numpy/Makefile 2015-02-08 17:17:34.000000000 +0100
@@ -3,7 +3,7 @@
PORTNAME= numpy
PORTVERSION= 1.9.1
-PORTREVISION= 1
+PORTREVISION= 2
PORTEPOCH= 1
CATEGORIES= math python
MASTER_SITES= http://docs.scipy.org/doc/${PORTNAME}/:doc \
@@ -15,7 +15,7 @@
EXTRACT_ONLY= numpy-${PORTVERSION:S/r/rc/}${EXTRACT_SUFX}
MAINTAINER= python at FreeBSD.org
-COMMENT= The New Numeric Extension to Python
+COMMENT= New Numeric Extension to Python
LICENSE= BSD3CLAUSE
@@ -25,9 +25,13 @@
USE_PYTHON= concurrent distutils py3kplist
LDFLAGS+= -shared
-OPTIONS_DEFINE= ATLAS SUITESPARSE DOCS
-OPTIONS_DEFAULT= SUITESPARSE
-ATLAS_DESC= Use optimized blas library
+OPTIONS_DEFINE= SUITESPARSE DOCS
+OPTIONS_DEFAULT= SUITESPARSE CBLAS
+OPTIONS_SINGLE= BLAS
+OPTIONS_SINGLE_BLAS= CBLAS OPENBLAS ATLAS
+CBLAS_DESC= Use math/cblas as BLAS library
+OPENBLAS_DESC= Use math/openblas as (optimized) BLAS library
+ATLAS_DESC= Use math/atlas as (optimized) BLAS library
SUITESPARSE_DESC= Use AMD and UMFPACK in SuiteSparse
PYDISTUTILS_CONFIGUREARGS+= --fcompiler=gnu95
@@ -36,9 +40,9 @@
PORTDOCS= *
WRKSRC= ${WRKDIR}/${DISTNAME:S/r/rc/}
-ATLAS_LIB_DEPENDS= libatlas.so:${PORTSDIR}/math/atlas
-ATLAS_LIB_DEPENDS_OFF= libblas.so:${PORTSDIR}/math/blas \
- liblapack.so:${PORTSDIR}/math/lapack
+ATLAS_USES= blaslapack:atlas
+OPENBLAS_USES= blaslapack:openblas
+CBLAS_USES= blaslapack
SUITESPARSE_LIB_DEPENDS=libumfpack.so:${PORTSDIR}/math/suitesparse
.include <bsd.port.pre.mk>
@@ -50,21 +54,21 @@
post-patch:
${REINPLACE_CMD} -e "s+%%FC%%+${FC}+" ${WRKSRC}/numpy/distutils/fcompiler/gnu.py
- ${CP} ${FILESDIR}/site.cfg ${WRKSRC}/site.cfg
-
-GCCLIBDIR_CMDS= ${FC} -print-file-name=libgfortran.so|${SED} -e s/libgfortran.so//
-
-pre-configure:
.if ${PORT_OPTIONS:MATLAS}
- @${REINPLACE_CMD} -e "s+%%ATLASLIBS%%+alapack, f77blas, cblas, atlas+" ${WRKSRC}/site.cfg
+ ${CP} ${FILESDIR}/site.cfg.atlas ${WRKSRC}/site.cfg
+.elif ${PORT_OPTIONS:MOPENBLAS}
+ ${CP} ${FILESDIR}/site.cfg.openblas ${WRKSRC}/site.cfg
.else
- @${REINPLACE_CMD} -e "s+%%ATLASLIBS%%+lapack, blas+" ${WRKSRC}/site.cfg
+ ${CP} ${FILESDIR}/site.cfg.cblas ${WRKSRC}/site.cfg
.endif
+GCCLIBDIR_CMDS= ${FC} -print-file-name=libgfortran.so|${SED} -e s/libgfortran.so//
+
+pre-configure:
.if !${PORT_OPTIONS:MSUITESPARSE}
@${REINPLACE_CMD} -e "s+:%%LOCALBASE%%/include/suitesparse++" ${WRKSRC}/site.cfg
.endif
@${REINPLACE_CMD} -e "s+%%GCCLIBDIR%%+$$(${GCCLIBDIR_CMDS})+" \
- -e "s+%%LOCALBASE%%+${LOCALBASE}+g" \
+ -e "s+%%LOCALBASE%%+${LOCALBASE}+g" \
${WRKSRC}/site.cfg
@${REINPLACE_CMD} -e "s+%%GCCLIBDIR%%+$$(${GCCLIBDIR_CMDS})+" ${WRKSRC}/numpy/distutils/system_info.py
diff -ruN py-numpy.orig/files/site.cfg py-numpy/files/site.cfg
--- py-numpy.orig/files/site.cfg 2015-01-02 17:36:43.000000000 +0100
+++ py-numpy/files/site.cfg 1970-01-01 01:00:00.000000000 +0100
@@ -1,10 +0,0 @@
-[DEFAULT]
-lapack_type=atlas
-library_dirs = /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%%
-include_dirs = /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/suitesparse
-src_dirs = %%LOCALBASE%%/src
-# search static libraries (.a) in preference to shared ones (.so)
-search_static_first = 0
-[atlas]
-library_dirs = %%LOCALBASE%%/lib:%%GCCLIBDIR%%
-atlas_libs = %%ATLASLIBS%%
diff -ruN py-numpy.orig/files/site.cfg.atlas py-numpy/files/site.cfg.atlas
--- py-numpy.orig/files/site.cfg.atlas 1970-01-01 01:00:00.000000000 +0100
+++ py-numpy/files/site.cfg.atlas 2015-02-08 17:19:17.000000000 +0100
@@ -0,0 +1,9 @@
+[DEFAULT]
+lapack_type=atlas
+library_dirs = /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%%
+include_dirs = /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/suitesparse
+src_dirs = %%LOCALBASE%%/src
+search_static_first = 0
+[atlas]
+library_dirs = %%LOCALBASE%%/lib:%%GCCLIBDIR%%
+atlas_libs = alapack, f77blas, cblas, atlas
diff -ruN py-numpy.orig/files/site.cfg.cblas py-numpy/files/site.cfg.cblas
--- py-numpy.orig/files/site.cfg.cblas 1970-01-01 01:00:00.000000000 +0100
+++ py-numpy/files/site.cfg.cblas 2015-02-08 17:19:30.000000000 +0100
@@ -0,0 +1,5 @@
+[DEFAULT]
+library_dirs = /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%%
+include_dirs = /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/suitesparse
+src_dirs = %%LOCALBASE%%/src
+search_static_first = 0
diff -ruN py-numpy.orig/files/site.cfg.openblas py-numpy/files/site.cfg.openblas
--- py-numpy.orig/files/site.cfg.openblas 1970-01-01 01:00:00.000000000 +0100
+++ py-numpy/files/site.cfg.openblas 2015-02-08 17:19:39.000000000 +0100
@@ -0,0 +1,9 @@
+[DEFAULT]
+lapack_type=openblas
+library_dirs = /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%%
+include_dirs = /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/suitesparse
+src_dirs = %%LOCALBASE%%/src
+search_static_first = 0
+[openblas]
+libraries = openblasp
+library_dirs = %%LOCALBASE%%/lib:%%GCCLIBDIR%%
----- numpy updated to build with blaslapack -----
--
R.F.Smith http://rsmith.home.xs4all.nl/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 5753 3324 1661 B0FE 8D93 FCED 40F6 D5DC A38A 33E0 (keyID: A38A33E0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-python/attachments/20150208/ea1cde31/attachment.sig>
More information about the freebsd-python
mailing list