Date: Sun, 8 Feb 2015 18:44:41 +0100 From: Roland Smith <rsmith@xs4all.nl> To: freebsd-python@freebsd.org Subject: Updating numpy port to use blaslapack Message-ID: <20150208174441.GA73775@slackbox.erewhon.home>
index | next in thread | raw e-mail
[-- Attachment #1 --] 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@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) [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJU16CJAAoJEED21dyjijPgjVcQAKMQNOhbZQqJUUKCGAaIqaNT beSA2/irix5l7VeZCgUj5gSYsDrKDxYaRK2comuKtG0jIykxLChPIYdM4gSTIFvL XWpAC9xTh46QoaDEEAzNLe1orJCFBq+cqJr4RsME8R+vcVOVUtT6f9cuDLoYRTkY JBy7bxL5kt//2L81GZalE4gokiWSf54jBd9fI8dTakll5hFYwlxMx/5493UWywhQ 2IGTVkJmN0QqRUzpiMm5yMFQhayeHB1c4/I8snssa+ks4QkJXplJw66ayrnSILoe 5gtdbyIMfGon9ZdvHPM3b8NDhhV3zmLcPSU9tURfymW6/QEDcJxUNNmxDUDjR/h9 i7hxoNaH0bhGtbkB5x/XWyxmA9UlWqRn291MRgKiv0la2UFpU//3kWE52/NkgB6d n0XPuNMvoO1up0f1AleBngA5DpLSrDOiJktxghZANBmrMIh6gvFTktcDIW32l57K 43vQ+0dXH5RsaEBEYxILdishbLeMPKBtgAnwGBmgrr13j+8PZ2kCxYmJW2vpo7TU CNyM8vTmPuKgT/Q7k4dJdip9EyxQN298HDYZdQPpTeTzkX8kRKBRhVgyFHG+8QC3 LZPGpjTBzlEToNWBDx7vd17CV0Xwe8bTqAOhQSUH5ZMyHOfwUuu5e7UmmrOLWW18 MvmMESn3IvVhY49v/ARK =kFTV -----END PGP SIGNATURE-----help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150208174441.GA73775>
