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

Include Fortran modules in the installation; version bump to 2.5.2 #200

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/magma/Manifest
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DIST magma-2.4.0.tar.gz 7687575 BLAKE2B e111c261d42e4192729e63c3ca971fd0f003802431bd423a37cb5ec6fb1d281e311fc49ac974a33bc2b91f355ae4da1e3febe5c96dc7361adfdbefaa162a321e SHA512 ea72136fd52371f445f608c4a6d247c535793d51376f32ad57ca81767e3629285463597883adc988e532a7e93282885ff1dd8f83e5cfd61748abefce63990274
DIST magma-2.5.2.tar.gz 7867915 BLAKE2B 483c21d03c76e68f9a7192352542d60abe00115f4f37fb7220c8f6c6f009a011577a930f9f5a8cc8a56d5b4c77a5b8cac5101ecfb9d808224aebe73364447cd6 SHA512 ff3cca87b3c77370bba0b8b33a65544040fc26004c9913dc8d93535e5d983b7ea5c361f38741ee79f45bfbb83ebe0d8e8459951ec7c8ca608e85201ce671cdec
156 changes: 156 additions & 0 deletions sci-libs/magma/magma-2.5.2.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

# TODO
# 1. Open issue on science-overlay to add a possibility for installing
# xlintstc and other test programs from lapack-reference!
# 2. Keep an eye on the cmake implementation. Does not work currently,
# check again on bumps.

EAPI=7

PYTHON_COMPAT=( python2_7 )
FORTRAN_STANDARD="77 90"

inherit cuda flag-o-matic fortran-2 multilib toolchain-funcs python-any-r1

MY_PV=$(ver_rs 3 '-')

DESCRIPTION="Matrix Algebra on GPU and Multicore Architectures"
HOMEPAGE="https://icl.cs.utk.edu/magma/"
SRC_URI="https://icl.cs.utk.edu/projectsfiles/${PN}/downloads/${PN}-${MY_PV}.tar.gz -> ${P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64"
IUSE="doc kepler maxwell pascal sparse static-libs test volta"

RDEPEND="
dev-util/nvidia-cuda-toolkit:=
virtual/blas
virtual/lapack
"
DEPEND="
${RDEPEND}
test? ( ${PYTHON_DEPS} )
"
BDEPEND="
virtual/pkgconfig
doc? ( >=app-doc/doxygen-1.8.14-r1[dot] )
"

# We have to have write acccess /dev/nvidia0 and /dev/nvidiactl and the portage
# user is (usually) not in the video group
RESTRICT="!test? ( test )"

pkg_setup() {
fortran-2_pkg_setup
use test && python-any-r1_pkg_setup
tc-check-openmp || die "Need OpenMP to compile ${P}"
}

src_prepare() {
# distributed pc file not so useful so replace it
cat <<-EOF > ${PN}.pc
prefix=${EPREFIX}/usr
libdir=\${prefix}/$(get_libdir)
includedir=\${prefix}/include/${PN}
Name: ${PN}
Description: ${DESCRIPTION}
Version: ${PV}
URL: ${HOMEPAGE}
Libs: -L\${libdir} -lmagma
Libs.private: -lm -lpthread -ldl -lcublas -lcudart -lcusparse
Cflags: -I\${includedir}
Requires: blas lapack
EOF

if [[ $(tc-getCC) =~ gcc ]]; then
local eopenmp=-fopenmp
elif [[ $(tc-getCC) =~ icc ]]; then
local eopenmp=-openmp
else
elog "Cannot detect compiler type so not setting openmp support"
fi
append-flags -fPIC ${eopenmp}
append-ldflags -Wl,-soname,lib${PN}.so.2.4 ${eopenmp}

cuda_src_prepare
default
}

src_configure() {
cat <<-EOF > make.inc
ARCH = $(tc-getAR)
ARCHFLAGS = cr
RANLIB = $(tc-getRANLIB)
NVCC = nvcc
CC = $(tc-getCXX)
FORT = $(tc-getFC)
INC = -I"${EPREFIX}/opt/cuda/include" -DADD_ -DCUBLAS_GFORTRAN
CFLAGS = ${CFLAGS} -fPIC
CXXFLAGS = ${CXXFLAGS} -fPIC
F90FLAGS = ${FFLAGS} -fPIC -x f95-cpp-input
FFLAGS = ${FFLAGS} -fPIC
NVCCFLAGS = -DADD_ -DUNIX ${NVCCFLAGS}
LDOPTS = ${LDFLAGS}
LOADER = $(tc-getFC)
LIBBLAS = $($(tc-getPKG_CONFIG) --libs blas)
LIBLAPACK = $($(tc-getPKG_CONFIG) --libs lapack)
CUDADIR = ${EPREFIX}/opt/cuda
LIBCUDA = -L\$(CUDADIR)/$(get_libdir) -lcublas -lcudart -lcusparse
LIB = -pthread -lm -ldl \$(LIBCUDA) \$(LIBBLAS) \$(LIBLAPACK) -lstdc++
EOF
if use volta; then
echo >> make.inc "GPU_TARGET = Volta"
elif use pascal; then
echo >> make.inc "GPU_TARGET = Pascal"
elif use maxwell; then
echo >> make.inc "GPU_TARGET = Maxwell"
elif use kepler; then
echo >> make.inc "GPU_TARGET = Kepler"
else # See http://icl.cs.utk.edu/magma/forum/viewtopic.php?f=2&t=227
# Minimal arch supported is Fermi as of 2.4.0
echo >> make.inc "GPU_TARGET = Fermi"
fi
}

src_compile() {
emake lib
use sparse && emake sparse-lib
emake shared
mv lib/lib${PN}.so{,.2.4} || die
ln -sf lib${PN}.so.2.4 lib/lib${PN}.so.2 || die
ln -sf lib${PN}.so.2.4 lib/lib${PN}.so || die
if use sparse; then
mv lib/lib${PN}_sparse.so{,.2.4} || die
ln -sf lib${PN}_sparse.so.2.4 lib/lib${PN}_sparse.so.2 || die
ln -sf lib${PN}_sparse.so.2.4 lib/lib${PN}_sparse.so || die
fi
}

src_test() {
emake test
# FIXME: sparse-test currently fails
use sparse && emake sparse-test
cd testing/lin || die
# we need to access this while running the tests
cuda_add_sandbox -w # replaces addwrite /dev/nvidia{ctl,0}
# FIXME: The python file needs the xlintstc program from
# lapack-reference test suite, which is not installed, even
# if lapack-reference is compiled with FEATURES="test". See TODO
LD_LIBRARY_PATH="${S}"/lib ${EPYTHON} lapack_testing.py || die
}

src_install() {
dolib.so lib/lib*$(get_libname)*
use static-libs && dolib.a lib/lib*.a
insinto /usr/include/${PN}
doins include/*.h
doins include/*.mod
insinto /usr/$(get_libdir)/pkgconfig
doins ${PN}.pc
local DOCS=( README ReleaseNotes )
use doc && local HTML_DOCS=( docs/html/. )
einstalldocs
}