diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 75f342c6983a..bfacf3aae0c3 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -17676,6 +17676,12 @@ githubId = 12017109; name = "Rabindra Dhakal"; }; + qbisi = { + name = "qbisicwate"; + email = "qbisicwate@gmail.com"; + github = "qbisi"; + githubId = 84267544; + }; qbit = { name = "Aaron Bieber"; email = "aaron@bolddaemon.com"; diff --git a/pkgs/by-name/ca/casadi/package.nix b/pkgs/by-name/ca/casadi/package.nix index 5cd35b064342..891b423d9e7a 100644 --- a/pkgs/by-name/ca/casadi/package.nix +++ b/pkgs/by-name/ca/casadi/package.nix @@ -10,6 +10,7 @@ cplex, fatrop, fetchFromGitHub, + fetchpatch, gurobi, highs, hpipm, @@ -45,6 +46,14 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-Mft0qhjdAbU82RgjYuKue5p7EqbTbt3ii5yXSsCFHrQ="; }; + patches = [ + (fetchpatch { + name = "fix-FindMUMPS.cmake.patch"; + url = "https://github.com/casadi/casadi/pull/3899/commits/274f4b23f73e60c5302bec0479fe1e92682b63d2.patch"; + hash = "sha256-3GWEWlN8dKLD6htpnOQLChldcT3hE09JWLeuCfAhY+4="; + }) + ]; + postPatch = '' # fix case of hpipmConfig.cmake @@ -57,11 +66,6 @@ stdenv.mkDerivation (finalAttrs: { '$'{CLANG_LLVM_LIB_DIR} \ ${llvmPackages_17.libclang.lib}/lib - # fix mumps lib name. No idea where this comes from. - substituteInPlace cmake/FindMUMPS.cmake --replace-fail \ - "mumps_seq" \ - "mumps" - # help casadi find its own libs substituteInPlace casadi/core/casadi_os.cpp --replace-fail \ "std::vector search_paths;" \ diff --git a/pkgs/by-name/mu/mumps/package.nix b/pkgs/by-name/mu/mumps/package.nix index 7d0e3e154cb4..2620d5b602b5 100644 --- a/pkgs/by-name/mu/mumps/package.nix +++ b/pkgs/by-name/mu/mumps/package.nix @@ -6,9 +6,55 @@ lapack, lib, metis, + parmetis, + withParmetis ? false, # default to false due to unfree license scotch, + withPtScotch ? mpiSupport, stdenv, + fixDarwinDylibNames, + mpi, + mpiSupport ? false, + mpiCheckPhaseHook, + scalapack, }: +assert withParmetis -> mpiSupport; +assert withPtScotch -> mpiSupport; +let + profile = if mpiSupport then "debian.PAR" else "debian.SEQ"; + metisFlags = + if withParmetis then + '' + IMETIS="-I${parmetis}/include -I${metis}/include" \ + LMETIS="-L${parmetis}/lib -lparmetis -L${metis}/lib -lmetis" + '' + else + '' + IMETIS=-I${metis}/include \ + LMETIS="-L${metis}/lib -lmetis" + ''; + scotchFlags = + if withPtScotch then + '' + ISCOTCH=-I${scotch.dev}/include \ + LSCOTCH="-L${scotch}/lib -lptscotch -lptesmumps -lptscotcherr" + '' + else + '' + ISCOTCH=-I${scotch.dev}/include \ + LSCOTCH="-L${scotch}/lib -lesmumps -lscotch -lscotcherr" + ''; + macroFlags = + "-Dmetis -Dpord -Dscotch" + + lib.optionalString withParmetis " -Dparmetis" + + lib.optionalString withPtScotch " -Dptscotch"; + # Optimized options + # Disable -fopenmp in lines below to benefit from OpenMP + optFlags = '' + OPTF="-O3 -fallow-argument-mismatch" \ + OPTL="-O3" \ + OPTC="-O3" + ''; +in stdenv.mkDerivation (finalAttrs: { name = "mumps"; version = "5.7.3"; @@ -18,28 +64,20 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-ZnIfAuvOBJDYqCtKGlWs0r39nG6X2lAVRuUmeIJenZw="; }; - patches = [ - # Compatibility with coin-or-mumps version - (fetchpatch { - url = "https://raw.githubusercontent.com/coin-or-tools/ThirdParty-Mumps/bd0bdf9baa3f3677bd34fb36ce63b2b32cc6cc7d/mumps_mpi.patch"; - hash = "sha256-70qZUKBVBpJOSRxYxng5Y6ct1fdCUQUGur3chDhGabQ="; - }) - ]; - - postPatch = - '' - # Compatibility with coin-or-mumps version - # https://github.com/coin-or-tools/ThirdParty-Mumps/blob/stable/3.0/get.Mumps#L66 - cp libseq/mpi.h libseq/mumps_mpi.h - '' - + lib.optionalString stdenv.hostPlatform.isDarwin '' - substituteInPlace src/Makefile --replace-fail \ - "-Wl,\''$(SONAME),libmumps_common" \ - "-Wl,-install_name,$out/lib/libmumps_common" - ''; + postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace src/Makefile --replace-fail \ + "-Wl,\''$(SONAME),libmumps_common" \ + "-Wl,-install_name,$out/lib/libmumps_common" + ''; configurePhase = '' - cp Make.inc/Makefile.debian.SEQ ./Makefile.inc + cp Make.inc/Makefile.${profile} ./Makefile.inc + ''; + + enableParallelBuilding = true; + + preBuild = '' + makeFlagsArray+=(${metisFlags} ${scotchFlags} ORDERINGSF="${macroFlags}" ${optFlags}) ''; makeFlags = @@ -48,84 +86,74 @@ stdenv.mkDerivation (finalAttrs: { "LIBEXT_SHARED=.dylib" ] ++ [ - "LSCOTCHDIR=${scotch}/lib" - "ISCOTCH=-I${scotch.dev}/include" - "LMETISDIR=${metis}/lib" - "IMETIS=-I${metis}/include" + "SCALAP=-lscalapack" "allshared" ]; - installPhase = '' - mkdir $out - cp -r include lib $out + installPhase = + '' + mkdir $out + cp -r include lib $out + '' + + lib.optionalString (!mpiSupport) '' + # Install mumps_seq headers + install -Dm 444 -t $out/include/mumps_seq libseq/*.h - # Add some compatibility with coin-or-mumps - ln -s $out/include $out/include/mumps - cp libseq/mumps_mpi.h $out/include + # Add some compatibility with coin-or-mumps + ln -s $out/include/mumps_seq/mpi.h $out/include/mumps_mpi.h + ''; + + nativeBuildInputs = [ + gfortran + ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames ++ lib.optional mpiSupport mpi; + + # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" + buildInputs = + lib.optional withParmetis parmetis + ++ lib.optional mpiSupport scalapack + ++ [ + blas + lapack + metis + scotch + ]; + + doInstallCheck = true; + nativeInstallCheckInputs = lib.optional mpiSupport mpiCheckPhaseHook; + installCheckPhase = '' + runHook preInstallCheck + ${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"} + ${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"} + cd examples + make all + $MPIRUN ./ssimpletest