arpack: add option to use macOS Accelerate
Copy darwin flags `-ff2c -fno-second-underscore` from workflow to use Accelerate without segfaulting / failing tests and enable the Accelerate framework when `useAccel` is true. https://github.com/opencollab/arpack-ng/blob/804fa3149a0f773064198a8e883bd021832157ca/.github/workflows/jobs.yml#L184-L192
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
, 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";
|
||||
@@ -22,11 +24,11 @@ stdenv.mkDerivation rec {
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ cmake gfortran ninja ];
|
||||
buildInputs = assert (blas.isILP64 == lapack.isILP64); [
|
||||
blas
|
||||
lapack
|
||||
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;
|
||||
|
||||
@@ -34,21 +36,26 @@ stdenv.mkDerivation rec {
|
||||
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 = [
|
||||
(lib.cmakeBool "BUILD_SHARED_LIBS" stdenv.hostPlatform.hasSharedLibraries)
|
||||
(lib.cmakeBool "EIGEN" true)
|
||||
(lib.cmakeBool "EXAMPLES" true)
|
||||
(lib.cmakeBool "ICB" true)
|
||||
(lib.cmakeBool "INTERFACE64" blas.isILP64)
|
||||
(lib.cmakeBool "INTERFACE64" (!useAccel && blas.isILP64))
|
||||
(lib.cmakeBool "MPI" useMpi)
|
||||
] ++ lib.optionals stdenv.hostPlatform.isDarwin [
|
||||
# prevent cmake from using Accelerate, which causes single precision tests
|
||||
# to segfault
|
||||
"-DBLA_VENDOR=Generic"
|
||||
"-DBLA_VENDOR=${if useAccel then "Apple" else "Generic"}"
|
||||
];
|
||||
|
||||
passthru = {
|
||||
inherit (blas) isILP64;
|
||||
isILP64 = !useAccel && blas.isILP64;
|
||||
tests = {
|
||||
inherit igraph;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user