Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suite sparse #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sci-libs/suitesparse/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST suitesparse-5.4.0.tar.gz 52594099 BLAKE2B e7e2400d2d24c5e029cad7b6afd572077333e341d74c4f065e9eea793f6d5dad466d762153a97a57dbec40a86790c2db144122957beb68de083b15c6f5ebd204 SHA512 8328bcc2ef5eb03febf91b9c71159f091ff405c1ba7522e53714120fcf857ceab2d2ecf8bf9a2e1fc45e1a934665a341e3a47f954f87b59934f4fce6164775d6
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 9ec0dbdc11267e940c9932a2a02ea3cceea78673 Mon Sep 17 00:00:00 2001
From: Bernd Waibel <[email protected]>
Date: Sat, 20 Jul 2019 16:47:32 +0200
Subject: [PATCH 1/2] Suitesparse_config/Suitesparse_config.mk: drop RPATH

Signed-off-by: Bernd Waibel <[email protected]>
---
SuiteSparse_config/SuiteSparse_config.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SuiteSparse_config/SuiteSparse_config.mk b/SuiteSparse_config/SuiteSparse_config.mk
index 19a3903..c70c237 100644
--- a/SuiteSparse_config/SuiteSparse_config.mk
+++ b/SuiteSparse_config/SuiteSparse_config.mk
@@ -358,7 +358,7 @@ SUITESPARSE_VERSION = 5.4.0

ifeq ($(UNAME),Linux)
# add the realtime library, librt, and SuiteSparse/lib
- LDLIBS += -lrt -Wl,-rpath=$(INSTALL_LIB)
+ LDLIBS += -lrt
endif

#---------------------------------------------------------------------------
--
2.22.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From 7394b9923afb8703322dfeb8927c1dcf8144a67f Mon Sep 17 00:00:00 2001
From: Bernd Waibel <[email protected]>
Date: Sat, 20 Jul 2019 16:48:56 +0200
Subject: [PATCH 2/2] AMD/Lib/Makefile: also build shared library

Signed-off-by: Bernd Waibel <[email protected]>
---
AMD/Lib/Makefile | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/AMD/Lib/Makefile b/AMD/Lib/Makefile
index 3b92f6a..5b558a5 100644
--- a/AMD/Lib/Makefile
+++ b/AMD/Lib/Makefile
@@ -11,7 +11,7 @@ default: library
include ../../SuiteSparse_config/SuiteSparse_config.mk

# AMD depends on SuiteSparse_config
-LDLIBS += -lsuitesparseconfig
+LDLIBS += -lsuitesparseconfig -lgfortran

# compile and install in SuiteSparse/lib
library:
@@ -62,7 +62,7 @@ $(AR_TARGET): $(OBJ)
# compile the Fortran versions and the libamdf77.a library (static only)
#-------------------------------------------------------------------------------

-fortran: libamdf77.a
+fortran: libamdf77.a libamdf77.so.$(VERSION)

AMDF77 = amd.o amdbar.o

@@ -76,6 +76,12 @@ libamdf77.a: $(AMDF77)
$(ARCHIVE) libamdf77.a $^
- $(RANLIB) libamdf77.a

+libamdf77.so.$(VERSION): $(AMDF77)
+ $(CC) $(SO_OPTS) $^ -o $@ $(LDLIBS)
+ ln -sf $@ libamdf77.so.$(SO_VERSION)
+ ln -sf $@ libamdf77.so
+ chmod 755 $@
+
#-------------------------------------------------------------------------------
# install (shared C version only)
#-------------------------------------------------------------------------------
@@ -98,6 +104,15 @@ $(INSTALL_LIB)/$(SO_TARGET): $(OBJ)
chmod 644 $(INSTALL_DOC)/AMD_UserGuide.pdf
chmod 644 $(INSTALL_DOC)/AMD_README.txt

+install-fortran: $(INSTALL_LIB)/libamdf77.so.$(VERSION)
+
+$(INSTALL_LIB)/libamdf77.so.$(VERSION): fortran
+ @mkdir -p $(INSTALL_LIB)
+ $(CC) $(SO_OPTS) $(AMDF77) -o $@ $(LDLIBS)
+ ( cd $(INSTALL_LIB) ; ln -sf libamdf77.so.$(VERSION) libamdf77.so.$(SO_VERSION) )
+ ( cd $(INSTALL_LIB) ; ln -sf libamdf77.so.$(VERSION) libamdf77.so )
+ chmod 755 $(INSTALL_LIB)/libamdf77.so.$(VERSION)
+
# uninstall AMD
uninstall:
$(RM) $(INSTALL_LIB)/$(SO_TARGET)
--
2.22.0

38 changes: 38 additions & 0 deletions sci-libs/suitesparse/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>[email protected]</email>
<name>Gentoo Science Project</name>
</maintainer>
<longdescription lang="en">
<!-- FIXME: rework this -->
SuiteSparse is a suite of sparse matrix libraries from University of
Florida Computer Science Department. Currently, this includes:
* AMD: symmetric approximate minimum degree
* BTF: permutation to block triangular form
* CAMD: symmetric approximate minimum degree
* CCOLAMD: constrained column approximate minimum degree
* COLAMD: column approximate minimum degree
* CHOLMOD: sparse supernodal Cholesky factorization and update/downdate
* CSparse: a concise sparse matrix package
* CXSparse: an extended version of CSparse
* GraphBLAS: graph algorithms implemented with BLAS
* KLU: sparse LU factorization, for circuit simulation
* LDL: a simple LDL^T factorization
* Mongoose: graph partioning package
* RBio: read/write sparse matrices in Rutherford / Boeing format
* SPQR: multifrontal sparse QT factorization
* SuiteSparse_config: common configuration for all but CSparse
* UMFPACK: sparse multifrontal LU factorization
The Gentoo package does not include the suitesparse MATLAB tools from
upstream, from the packages above and the following MATLAB-only packages:
* LINFACTOR: solve Ax=b using LU or CHOL
* MESHND: 2D and 3D mesh generation and nested dissection
* SSMULT: sparse matrix times sparse matrix
</longdescription>
<use>
<flag name="cuda">Use CUDA for cholmod and spqr</flag>
<flag name="tbb">Use Intel's <pkg>dev-cpp/tbb</pkg> for threading</flag>
</use>
</pkgmetadata>
168 changes: 168 additions & 0 deletions sci-libs/suitesparse/suitesparse-5.4.0.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

# FIXME: currently this is a safety measure. Is it really needed by the
# fortran modules?
FORTRAN_NEED_OPENMP=1

# FIXME: how to handle cmake without having a root CMakeLists.txt?
inherit fortran-2 multiprocessing toolchain-funcs

MY_PN="SuiteSparse"

DESCRIPTION="Package for a suite of sparse matrix tools"
HOMEPAGE="http://faculty.cse.tamu.edu/davis/suitesparse.html"
SRC_URI="http://faculty.cse.tamu.edu/davis/${MY_PN}/${MY_PN}-${PV}.tar.gz -> ${P}.tar.gz"

# BSD: amd, camd, ccolamd, colamd, ssget
# LGPL-2.1+: btf, cholmod/Check, choldmod/Cholesky, cholmod/Core,
# cholmod/Partition, cxsparse, klu, ldl
# GPL-2+: choldmod/Demo, cholmod/Matlab, cholmod/MatrixOps,
# cholmod/Modify, cholmod/Supernodal, cholmod/Tcov, cholmod/Valgrind,
# GPUQREngine, RBio, spqr, SuiteSparse_GPURuntime, umfpack
# Apache-2.0: GraphBLAS
# GPL-3: Mongoose
LICENSE="Apache-2.0 BSD GPL-2+ GPL-3 LGPL-2.1+"
SLOT="0"

KEYWORDS="~amd64 ~x86"

FORTRAN_NEEDED="amd"

# FIXME: currently not included:
# Piro_Band, Skyline_SVD
# GraphBLAS and Mongoose are cmake based builds
# SuiteSparse_GPURuntime and GPUQREngine are part of spqr[cuda]
# FIXME: cuda is not compiling due to C/C++ mixing
# FIXME: testing
IUSE="cuda fortran tbb test"

# Tests currently fail in cholmod library
#RESTRICT="!test? ( test )"
RESTRICT="test"

# FIXME: Exclude the old packages. These could be removed once the package
# and revdeps are fully updated.
RDEPEND="
!<sci-libs/suitesparse-5
!sci-libs/amd
!sci-libs/btf
!sci-libs/camd
!sci-libs/ccolamd
!sci-libs/cholmod
!sci-libs/colamd
!sci-libs/cxsparse
!sci-libs/klu
!sci-libs/ldl
!sci-libs/spqr
!sci-libs/suitesparseconfig
!sci-libs/umfpack
|| ( >=sci-libs/metis-5.1.0-r3[openmp(+)] >=sci-libs/parmetis-4.0.3[openmp(+)] )
virtual/blas
virtual/lapack
cuda? (
>=dev-util/nvidia-cuda-toolkit-9.2.88:=
>=sci-libs/magma-2.4.0
)
tbb? ( >=dev-cpp/tbb-2017.20161128 )
"

DEPEND="
${RDEPEND}
sys-devel/m4
test? ( >=app-shells/tcsh-6.20.00 )
"
BDEPEND=">=sys-apps/grep-3.1"

S=${WORKDIR}/${MY_PN}

PATCHES=(
"${FILESDIR}/${P}-0001-Suitesparse_config-Suitesparse_config.mk-drop-RPATH.patch"
"${FILESDIR}/${P}-0002-AMD-Lib-Makefile-also-build-shared-library.patch"
)

DOCS=( README.txt )

pkg_setup() {
# several of the packages need openmp support, so check for it early
tc-check-openmp || die "Need OpenMP to build ${P}"
}

src_compile() {
local myblas=$($(tc-getPKG_CONFIG) --libs blas)
local mylapack=$($(tc-getPKG_CONFIG) --libs lapack)
# FIXME: AUTOCC auto-enables intel compilers
local mymakeopts="OPTIMIZATION= AUTOCC=no JOBS=$(makeopts_jobs)"
mymakeopts="${mymakeopts} INSTALL=${ED}/usr INSTALL_LIB=${ED}/usr/$(get_libdir)"
mymakeopts="${mymakeopts} LAPACK=\"${mylapack}\" BLAS=\"${myblas}\""
mymakeopts="${mymakeopts} MY_METIS_LIB=-lmetis"
if use cuda; then
mymakeopts="${mymakeopts} CUDA=yes magma_inc=${EPREFIX}/usr magma_lib=${EPREFIX}/usr/$(get_libdir) -lmagma"
mymakeopts="${mymakeopts} CHOLDMOD_CONFIG+=-DGPU_BLAS SPQR_CONFIG+=-DGPU_BLAS"
else
mymakeopts="${mymakeopts} CUDA=no"
fi
if use fortran; then
local myf77=$(tc-getF77)
mymakeopts="${mymakeopts} F77=${myf77}"
fi
if use tbb; then
mymakeopts="${mymakeopts} TBB=-ltbb SPQR_CONFIG+=-DHAVE_TBB"
fi
use test && mymakeopts="${mymakeopts} TCOV=yes"
export LD_LIBRARY_PATH="${S}/lib"
# emake ${mymakeopts} config # FIXME: remove on final ebuild
emake ${mymakeopts} library
# use static-libs && emake ${mymakeopts} static
if use fortran; then
emake -C "${S}/AMD" ${mymakeopts} fortran
fi
}

src_test() {
local myblas=$($(tc-getPKG_CONFIG) --libs blas)
local mylapack=$($(tc-getPKG_CONFIG) --libs lapack)
local mytestargs="OPTIMIZATION= AUTOCC=no BLAS=${myblas} LAPACK=${mylapack}"
mytestargs="${mytestargs} MY_METIS_LIB=-lmetis"
if use cuda; then
mytestargs="${mytestargs} CUDA=yes magma_inc=${EPREFIX}/usr magma_lib=${EPREFIX}/usr/$(get_libdir) -lmagma"
mytestargs="${mytestargs} CHOLDMOD_CONFIG+=-DGPU_BLAS SPQR_CONFIG+=-DGPU_BLAS"
else
mytestargs="${mytestargs} CUDA=no"
fi
if use fortran; then
local myf77=$(tc-getF77)
mytestargs="${mytestargs} F77=${myf77}"
fi
if use tbb; then
mytestargs="${mytestargs} TBB=-ltbb SPQR_CONFIG+=-DHAVE_TBB"
fi
export LD_LIBRARY_PATH="${S}/lib"
emake ${mytestargs} cov
}

src_install() {
local myblas=$($(tc-getPKG_CONFIG) --libs blas)
local mylapack=$($(tc-getPKG_CONFIG) --libs lapack)
local myinstallargs="INSTALL=${ED}/usr INSTALL_LIB=${ED}/usr/$(get_libdir)"
myinstallargs="${myinstallargs} BLAS=${myblas} LAPACK=${mylapack} MY_METIS_LIB=-lmetis"
if use cuda; then
myinstallargs="${myinstallargs} CUDA=yes magma_inc=${EPREFIX}/usr magma_lib=${EPREFIX}/usr/$(get_libdir) -lmagma"
myinstallargs="${myinstallargs} CHOLMOD_CONFIG+=-DGPU_BLAS SPQR_CONFIG+=-DGPU_BLAS"
else
myinstallargs="${myinstallargs} CUDA=no"
fi
if use fortran; then
local myf77=$(tc-getF77)
myinstallargs="${myinstallargs} F77=${myf77}"
fi
if use tbb; then
myinstallargs="${myinstallargs} TBB=-ltbb SPQR_CONFIG+=-DHAVE_TBB"
fi
emake ${myinstallargs} install
if use fortran; then
emake -C "${S}/AMD/Lib" ${myinstallargs} install-fortran
fi
}