Skip to content

Commit

Permalink
[Backport release-24.11] arpack: add ISO C binding and top arpack-mpi…
Browse files Browse the repository at this point in the history
… attribute (#367463)
  • Loading branch information
wolfgangwalther authored Jan 6, 2025
2 parents e967d84 + 77219e2 commit 0f73176
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
45 changes: 26 additions & 19 deletions pkgs/by-name/ar/arpack/package.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{ lib, stdenv, fetchFromGitHub, cmake
{ lib, stdenv, fetchFromGitHub, cmake, ninja
, gfortran, blas, lapack, eigen
, useMpi ? false
, mpi
, openssh
, igraph
, useAccel ? false #use Accelerate framework on darwin
}:

# MPI version can only be built with LP64 interface.
# See https://github.com/opencollab/arpack-ng#readme
assert useMpi -> !blas.isILP64;
assert useAccel -> stdenv.hostPlatform.isDarwin;

stdenv.mkDerivation rec {
pname = "arpack";
Expand All @@ -21,34 +23,39 @@ stdenv.mkDerivation rec {
sha256 = "sha256-HCvapLba8oLqx9I5+KDAU0s/dTmdWOEilS75i4gyfC0=";
};

nativeBuildInputs = [ cmake gfortran ];
buildInputs = assert (blas.isILP64 == lapack.isILP64); [
blas
lapack
nativeBuildInputs = [ cmake gfortran ninja ];
buildInputs = [
eigen
] ++ lib.optional useMpi mpi;
] ++ lib.optionals (!useAccel) (assert (blas.isILP64 == lapack.isILP64); [
blas lapack
]) ++ lib.optional useMpi mpi;

nativeCheckInputs = lib.optional useMpi openssh;

# a couple tests fail when run in parallel
doCheck = true;
enableParallelChecking = false;

env = lib.optionalAttrs useAccel {
# Without these flags some tests will fail / segfault when using Accelerate
# framework. They were pulled from the CI Workflow
# https://github.com/opencollab/arpack-ng/blob/804fa3149a0f773064198a8e883bd021832157ca/.github/workflows/jobs.yml#L184-L192
FFLAGS = "-ff2c -fno-second-underscore";
};

cmakeFlags = [
"-DBUILD_SHARED_LIBS=ON"
"-DINTERFACE64=${if blas.isILP64 then "1" else "0"}"
"-DMPI=${if useMpi then "ON" else "OFF"}"
(lib.cmakeBool "BUILD_SHARED_LIBS" stdenv.hostPlatform.hasSharedLibraries)
(lib.cmakeBool "EIGEN" true)
(lib.cmakeBool "EXAMPLES" true)
(lib.cmakeBool "ICB" true)
(lib.cmakeBool "INTERFACE64" (!useAccel && blas.isILP64))
(lib.cmakeBool "MPI" useMpi)
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
"-DBLA_VENDOR=${if useAccel then "Apple" else "Generic"}"
];

preCheck = ''
# Prevent tests from using all cores
export OMP_NUM_THREADS=2
'';

postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
install_name_tool -change libblas.dylib ${blas}/lib/libblas.dylib $out/lib/libarpack.dylib
'';

passthru = {
inherit (blas) isILP64;
isILP64 = !useAccel && blas.isILP64;
tests = {
inherit igraph;
};
Expand Down
2 changes: 2 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1679,6 +1679,8 @@ with pkgs;
stdenv = gccStdenv;
};

arpack-mpi = arpack.override { useMpi = true; };

inherit (callPackages ../data/fonts/arphic {})
arphic-ukai arphic-uming;

Expand Down

0 comments on commit 0f73176

Please sign in to comment.