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>
next in thread | raw e-mail | index | archive | help
--7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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/LAPA= CK. ----- 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 @@ =20 PORTNAME=3D numpy PORTVERSION=3D 1.9.1 -PORTREVISION=3D 1 +PORTREVISION=3D 2 PORTEPOCH=3D 1 CATEGORIES=3D math python MASTER_SITES=3D http://docs.scipy.org/doc/${PORTNAME}/:doc \ @@ -15,7 +15,7 @@ EXTRACT_ONLY=3D numpy-${PORTVERSION:S/r/rc/}${EXTRACT_SUFX} =20 MAINTAINER=3D python@FreeBSD.org -COMMENT=3D The New Numeric Extension to Python +COMMENT=3D New Numeric Extension to Python =20 LICENSE=3D BSD3CLAUSE =20 @@ -25,9 +25,13 @@ USE_PYTHON=3D concurrent distutils py3kplist LDFLAGS+=3D -shared =20 -OPTIONS_DEFINE=3D ATLAS SUITESPARSE DOCS -OPTIONS_DEFAULT=3D SUITESPARSE -ATLAS_DESC=3D Use optimized blas library +OPTIONS_DEFINE=3D SUITESPARSE DOCS +OPTIONS_DEFAULT=3D SUITESPARSE CBLAS +OPTIONS_SINGLE=3D BLAS +OPTIONS_SINGLE_BLAS=3D CBLAS OPENBLAS ATLAS +CBLAS_DESC=3D Use math/cblas as BLAS library +OPENBLAS_DESC=3D Use math/openblas as (optimized) BLAS library +ATLAS_DESC=3D Use math/atlas as (optimized) BLAS library SUITESPARSE_DESC=3D Use AMD and UMFPACK in SuiteSparse =20 PYDISTUTILS_CONFIGUREARGS+=3D --fcompiler=3Dgnu95 @@ -36,9 +40,9 @@ PORTDOCS=3D * WRKSRC=3D ${WRKDIR}/${DISTNAME:S/r/rc/} =20 -ATLAS_LIB_DEPENDS=3D libatlas.so:${PORTSDIR}/math/atlas -ATLAS_LIB_DEPENDS_OFF=3D libblas.so:${PORTSDIR}/math/blas \ - liblapack.so:${PORTSDIR}/math/lapack +ATLAS_USES=3D blaslapack:atlas +OPENBLAS_USES=3D blaslapack:openblas +CBLAS_USES=3D blaslapack SUITESPARSE_LIB_DEPENDS=3Dlibumfpack.so:${PORTSDIR}/math/suitesparse =20 .include <bsd.port.pre.mk> @@ -50,21 +54,21 @@ =20 post-patch: ${REINPLACE_CMD} -e "s+%%FC%%+${FC}+" ${WRKSRC}/numpy/distutils/fcompiler= /gnu.py - ${CP} ${FILESDIR}/site.cfg ${WRKSRC}/site.cfg - -GCCLIBDIR_CMDS=3D ${FC} -print-file-name=3Dlibgfortran.so|${SED} -e s/libg= fortran.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=3D ${FC} -print-file-name=3Dlibgfortran.so|${SED} -e s/libg= fortran.so// + +pre-configure: .if !${PORT_OPTIONS:MSUITESPARSE} @${REINPLACE_CMD} -e "s+:%%LOCALBASE%%/include/suitesparse++" ${WRKSRC}/s= ite.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}/n= umpy/distutils/system_info.py =20 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=3Datlas -library_dirs =3D /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%% -include_dirs =3D /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/= suitesparse -src_dirs =3D %%LOCALBASE%%/src -# search static libraries (.a) in preference to shared ones (.so) -search_static_first =3D 0 -[atlas] -library_dirs =3D %%LOCALBASE%%/lib:%%GCCLIBDIR%% -atlas_libs =3D %%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=3Datlas +library_dirs =3D /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%% +include_dirs =3D /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/= suitesparse +src_dirs =3D %%LOCALBASE%%/src +search_static_first =3D 0 +[atlas] +library_dirs =3D %%LOCALBASE%%/lib:%%GCCLIBDIR%% +atlas_libs =3D 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 =3D /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%% +include_dirs =3D /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/= suitesparse +src_dirs =3D %%LOCALBASE%%/src +search_static_first =3D 0 diff -ruN py-numpy.orig/files/site.cfg.openblas py-numpy/files/site.cfg.ope= nblas --- py-numpy.orig/files/site.cfg.openblas 1970-01-01 01:00:00.000000000 +01= 00 +++ py-numpy/files/site.cfg.openblas 2015-02-08 17:19:39.000000000 +0100 @@ -0,0 +1,9 @@ +[DEFAULT] +lapack_type=3Dopenblas +library_dirs =3D /usr/lib:%%LOCALBASE%%/lib:%%GCCLIBDIR%% +include_dirs =3D /usr/include:%%LOCALBASE%%/include:%%LOCALBASE%%/include/= suitesparse +src_dirs =3D %%LOCALBASE%%/src +search_static_first =3D 0 +[openblas] +libraries =3D openblasp +library_dirs =3D %%LOCALBASE%%/lib:%%GCCLIBDIR%% ----- numpy updated to build with blaslapack ----- --=20 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) --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature -----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----- --7JfCtLOvnd9MIVvH--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150208174441.GA73775>