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

petsc: 3.8.4 -> 3.10.3 #55358

Closed
wants to merge 11 commits into from
5 changes: 5 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,11 @@
github = "jammerful";
name = "jammerful";
};
jamtrott = {
email = "james@simula.no";
github = "jamtrott";
name = "James D. Trotter";
};
jansol = {
email = "jan.solanti@paivola.fi";
github = "jansol";
Expand Down
26 changes: 19 additions & 7 deletions pkgs/applications/science/math/scotch/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{ stdenv, fetchurl, bison, openmpi, flex, zlib}:
{ stdenv, fetchurl, bison, openmpi, flex, zlib, fixDarwinDylibNames }:

stdenv.mkDerivation rec {
version = "6.0.4";
name = "scotch-${version}";
src_name = "scotch_${version}";

nativeBuildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;
buildInputs = [ bison openmpi flex zlib ];

src = fetchurl {
Expand All @@ -15,22 +16,33 @@ stdenv.mkDerivation rec {
sourceRoot = "${src_name}/src";

preConfigure = ''
ln -s Make.inc/Makefile.inc.x86-64_pc_linux2 Makefile.inc
substituteInPlace Makefile \
--replace '-$(CP) -f ../include/*scotch*.h $(includedir)' '-$(CP) -f ../include/*.h $(includedir)' \
--replace '-$(CP) -f ../lib/*scotch*$(LIB) $(libdir)' '-$(CP) -f ../lib/*$(LIB) $(libdir)'

ln -s Make.inc/Makefile.inc.x86-64_pc_linux2.shlib Makefile.inc
'' + stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace Makefile.inc \
--replace gcc mpicc \
--replace "-DSCOTCH_PTHREAD " "" \
--replace "-DCOMMON_PTHREAD" "-DCOMMON_PTHREAD -DCOMMON_PTHREAD_BARRIER" \
--replace "-lrt" "" \
--replace "-shared" "-dynamiclib -undefined dynamic_lookup" \
--replace ".so" ".dylib"
'';

buildFlags = [ "scotch ptscotch" ];
installFlags = [ "prefix=\${out}" ];
buildFlags = [ "scotch ptscotch esmumps ptesmumps" ];
installFlags = [ "prefix=\${out} scotch ptscotch esmumps ptesmumps" ];

meta = {
description = "Graph and mesh/hypergraph partitioning, graph clustering, and sparse matrix ordering";
longDescription = ''
Scotch is a software package for graph and mesh/hypergraph partitioning, graph clustering,
Scotch is a software package for graph and mesh/hypergraph partitioning, graph clustering,
and sparse matrix ordering.
'';
homepage = http://www.labri.fr/perso/pelegrin/scotch;
license = stdenv.lib.licenses.cecill-c;
maintainers = [ stdenv.lib.maintainers.bzizou ];
platforms = stdenv.lib.platforms.linux;
platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
};
}

27 changes: 27 additions & 0 deletions pkgs/development/libraries/science/math/hypre/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{ stdenv, fetchurl, gfortran, cmake, openmpi }:

stdenv.mkDerivation rec {
name = "hypre";
version = "2.14.0";

src = fetchurl {
url = "https://github.com/LLNL/hypre/archive/v${version}.tar.gz";
sha256 = "0v515i73bvaz378h5465b1dy9v2gf924zy2q94cpq4qqarawvkqh";
};

sourceRoot = "${name}-${version}/src";

preConfigure = ''
cmakeFlags="$cmakeFlags -DHYPRE_INSTALL_PREFIX=$out -DHYPRE_SHARED=ON -DCMAKE_SHARED_LINKER_FLAGS=\"-lmpi\""
'';

buildInputs = [ cmake gfortran openmpi ];

meta = {
description = "Scalable linear solvers and multigrid methods";
homepage = https://computation.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods;
license = stdenv.lib.licenses.lgpl21;
platforms = stdenv.lib.platforms.all;
maintainers = with stdenv.lib.maintainers; [ jamtrott ];
};
}
41 changes: 41 additions & 0 deletions pkgs/development/libraries/science/math/mumps/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ stdenv, fetchurl, gfortran, blas, liblapack, metis, openmpi, scalapack, scotch }:

stdenv.mkDerivation rec {
name = "mumps";
version = "5.1.2-p2";

src = fetchurl {
url = "https://bitbucket.org/petsc/pkg-mumps/get/v${version}.tar.gz";
sha256 = "0211njml8pxhj69pj5p2vjwvwz94wxzd8knd9yq69z8w7qrs5b4a";
};

patchPhase = ''
ln -s Make.inc/Makefile.debian.PAR Makefile.inc
substituteInPlace Makefile.inc \
--replace "LSCOTCHDIR = /usr/lib" "LSCOTCHDIR = ${scotch}/lib" \
--replace "ISCOTCH = -I/usr/include/scotch" "ISCOTCH = -I${scotch}/include" \
--replace "LMETISDIR = /usr/lib" "LMETISDIR = ${metis}/lib" \
--replace "IMETIS = -I/usr/include/metis" "IMETIS = -I${metis}/include" \
--replace "INCPAR = -I/usr/lib/openmpi/include" "INCPAR = -I${openmpi}/include" \
--replace 'LIBPAR = $(SCALAP) $(LAPACK) -lmpi -lmpi_f77' 'LIBPAR = $(SCALAP) $(LAPACK) -lmpi -lmpi_mpifh' \
--replace "SCALAP = -lscalapack-openmpi -lblacs-openmpi -lblacsF77init-openmpi -lblacsCinit-openmpi" "SCALAP = -lscalapack"
'';

buildFlags = [ "all" ];

installPhase = ''
mkdir -p $out/lib
cp -R include $out
cp lib/*.a $out/lib
'';

buildInputs = [ gfortran blas liblapack metis openmpi scalapack scotch ];

meta = {
description = "A parallel sparse direct solver";
homepage = http://mumps-solver.org/;
license = stdenv.lib.licenses.cecill-c;
platforms = stdenv.lib.platforms.all;
maintainers = with stdenv.lib.maintainers; [ jamtrott ];
};
}
79 changes: 59 additions & 20 deletions pkgs/development/libraries/science/math/petsc/default.nix
Original file line number Diff line number Diff line change
@@ -1,50 +1,89 @@
{ stdenv
, fetchurl
, blas
, gfortran
, pkgconfig
, python2
, blas
, hdf5
, hypre
, liblapack
, python }:
, metis
, mumps
, openmpi
, openssh
, scalapack
, scotch
, spai
, suitesparse
, superlu
, fixDarwinDylibNames }:

stdenv.mkDerivation rec {
version = "3.10.3";
name = "petsc-${version}";
version = "3.8.4";

src = fetchurl {
url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz";
sha256 = "1iy49gagxncx09d88kxnwkj876p35683mpfk33x37165si6xqy4z";
sha256 = "1r4dvkrmsx2sxzm7krwvji4c1pl4girmihj0xr7n14g0pamnn46d";
};

nativeBuildInputs = [ blas gfortran.cc.lib liblapack python ];
nativeBuildInputs = [
gfortran
pkgconfig
python2
] ++ stdenv.lib.optional stdenv.isDarwin [ fixDarwinDylibNames ];

buildInputs = [
blas
hdf5
hypre
liblapack
metis
mumps
openmpi
openssh
scalapack
scotch
spai
suitesparse
superlu
];

prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
substituteInPlace config/install.py \
--replace /usr/bin/install_name_tool install_name_tool
substituteInPlace config/BuildSystem/config/packages/MUMPS.py \
--replace "'libmpiseq.a'" ""
'';

preConfigure = ''
patchShebangs .
configureFlagsArray=(
$configureFlagsArray
"--CC=$CC"
"--with-cxx=0"
"--with-fc=0"
"--with-mpi=0"
"--with-blas-lib=[${blas}/lib/libblas.a,${gfortran.cc.lib}/lib/libgfortran.a]"
"--with-lapack-lib=[${liblapack}/lib/liblapack.a,${gfortran.cc.lib}/lib/libgfortran.a]"
)
'';

postInstall = ''
rm $out/bin/petscmpiexec
rm $out/bin/popup
rm $out/bin/uncrustify.cfg
rm -rf $out/bin/win32fe
'';
configureFlags = [
"--COPTFLAGS=\"-g -O2\""
"--CXXOPTFLAGS=\"-g -O2\""
"--with-debugging=yes"
"--with-fortran-bindings=no"
"--with-hdf5-dir=${hdf5}"
"--with-hypre-dir=${hypre}"
"--with-metis-dir=${metis}"
"--with-mumps-dir=${mumps}"
"--with-scalapack-dir=${scalapack}"
"--with-ptscotch-dir=${scotch}"
"--with-spai-dir=${spai}"
"--with-suitesparse-dir=${suitesparse}"
"--with-superlu-dir=${superlu}"
];

doCheck = true;
checkTarget = "test";

meta = {
description = "Library of linear algebra algorithms for solving partial differential equations";
homepage = https://www.mcs.anl.gov/petsc/index.html;
platforms = stdenv.lib.platforms.all;
license = stdenv.lib.licenses.bsd2;
maintainers = with stdenv.lib.maintainers; [ jamtrott ];
};
}
5 changes: 3 additions & 2 deletions pkgs/development/libraries/science/math/scalapack/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ stdenv.mkDerivation rec {
export OMP_NUM_THREADS=1

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/lib
'' + stdenv.lib.optionalString stdenv.isDarwin ''
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:`pwd`/lib
'';

meta = with stdenv.lib; {
homepage = http://www.netlib.org/scalapack/;
description = "Library of high-performance linear algebra routines for parallel distributed memory machines";
license = licenses.bsd3;
platforms = platforms.linux;
platforms = platforms.linux ++ platforms.darwin;
maintainers = [ maintainers.costrouc ];
};

}
35 changes: 35 additions & 0 deletions pkgs/development/libraries/science/math/spai/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
name = "spai";
version = "3.0-p1";

src = fetchurl {
url = "http://ftp.mcs.anl.gov/pub/petsc/externalpackages/spai-${version}.tar.gz";
sha256 = "13nadflrkanmw9v86z12kwwx63wys4k8s6iyaamx6apl8frxb708";
};

configurePhase = ''
substituteInPlace lib/Makefile \
--replace "include Makefile.in" ""
'';

buildPhase = ''
make -C lib
'';

installPhase = ''
mkdir -p $out/include
cp lib/*.h $out/include
mkdir -p $out/lib
cp lib/libspai.a $out/lib
'';

meta = {
description = "Sparse approximate inverse preconditioner";
homepage = https://bitbucket.org/petsc/pkg-spai;
platforms = stdenv.lib.platforms.all;
license = stdenv.lib.licenses.unfree;
maintainers = with stdenv.lib.maintainers; [ jamtrott ];
};
}
11 changes: 8 additions & 3 deletions pkgs/development/python-modules/mpi4py/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchPypi, fetchpatch, python, buildPythonPackage, mpi, openssh }:
{ stdenv, fetchPypi, fetchpatch, python, buildPythonPackage, cython, mpi, openssh }:

buildPythonPackage rec {
pname = "mpi4py";
Expand Down Expand Up @@ -46,14 +46,19 @@ buildPythonPackage rec {
export OMPI_MCA_rmaps_base_oversubscribe=yes
'';

setupPyBuildFlags = ["--mpicc=${mpi}/bin/mpicc"];
# The "build_src --force" flag is used to re-build the package's cython code.
# This prevents issues when using multiple cython-based packages
# together (for example, mpi4py and petsc4py) due to code that has been
# generated with incompatible cython versions.
setupPyBuildFlags = [ "--mpicc=${mpi}/bin/mpicc" "build_src --force" ];
dotlambda marked this conversation as resolved.
Show resolved Hide resolved

nativeBuildInputs = [ cython ];
buildInputs = [ mpi openssh ];

meta = {
description =
"Python bindings for the Message Passing Interface standard";
homepage = http://code.google.com/p/mpi4py/;
homepage = https://bitbucket.org/mpi4py/mpi4py/;
license = stdenv.lib.licenses.bsd3;
};
}
39 changes: 39 additions & 0 deletions pkgs/development/python-modules/petsc4py/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ lib
, fetchPypi
, python
, buildPythonPackage
, cython
, numpy
, openmpi
, openssh
, petsc
, pytest }:

buildPythonPackage rec {
pname = "petsc4py";
version = "3.10.1";

src = fetchPypi {
inherit pname version;
sha256 = "094hcnran0r2z1wlvmjswsz3ski1m9kqrl5l0ax8jjhnk55x0flh";
};

PETSC_DIR = "${petsc}";

# The "build_src --force" flag is used to re-build the package's cython code.
# This prevents issues when using multiple cython-based packages
# together (for example, mpi4py and petsc4py) due to code that has been
# generated with incompatible cython versions.
setupPyBuildFlags = [ "build_src --force" ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add the same comment here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


nativeBuildInputs = [ cython openmpi openssh ];
propagatedBuildInputs = [ numpy ];
checkInputs = [ pytest ];

meta = {
description = "Python bindings for PETSc, the Portable, Extensible Toolkit for Scientific Computation";
homepage = https://bitbucket.org/petsc/petsc4py;
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ jamtrott ];
srhb marked this conversation as resolved.
Show resolved Hide resolved
};
}
Loading