diff options
Diffstat (limited to 'pkgs/development/libraries/science/math')
10 files changed, 96 insertions, 30 deletions
diff --git a/pkgs/development/libraries/science/math/bonmin/default.nix b/pkgs/development/libraries/science/math/bonmin/default.nix index 5a736f976957..2bbd698f7fa7 100644 --- a/pkgs/development/libraries/science/math/bonmin/default.nix +++ b/pkgs/development/libraries/science/math/bonmin/default.nix @@ -43,6 +43,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "An open-source code for solving general MINLP (Mixed Integer NonLinear Programming) problems"; + mainProgram = "bonmin"; homepage = "https://github.com/coin-or/Bonmin"; license = licenses.epl10; platforms = platforms.unix; diff --git a/pkgs/development/libraries/science/math/faiss/default.nix b/pkgs/development/libraries/science/math/faiss/default.nix index 25ac539e05f2..25d6542f8da1 100644 --- a/pkgs/development/libraries/science/math/faiss/default.nix +++ b/pkgs/development/libraries/science/math/faiss/default.nix @@ -145,6 +145,7 @@ stdenv.mkDerivation { meta = with lib; { description = "A library for efficient similarity search and clustering of dense vectors by Facebook Research"; + mainProgram = "demo_ivfpq_indexing"; homepage = "https://github.com/facebookresearch/faiss"; license = licenses.mit; platforms = platforms.unix; diff --git a/pkgs/development/libraries/science/math/itpp/default.nix b/pkgs/development/libraries/science/math/itpp/default.nix index 639497bb1f8c..cb45787e1403 100644 --- a/pkgs/development/libraries/science/math/itpp/default.nix +++ b/pkgs/development/libraries/science/math/itpp/default.nix @@ -44,6 +44,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "IT++ is a C++ library of mathematical, signal processing and communication classes and functions"; + mainProgram = "itpp-config"; homepage = "https://itpp.sourceforge.net/"; license = licenses.gpl3; platforms = platforms.unix; diff --git a/pkgs/development/libraries/science/math/lcalc/default.nix b/pkgs/development/libraries/science/math/lcalc/default.nix index b1896917658c..f6603f7d8fb8 100644 --- a/pkgs/development/libraries/science/math/lcalc/default.nix +++ b/pkgs/development/libraries/science/math/lcalc/default.nix @@ -34,6 +34,7 @@ stdenv.mkDerivation rec { meta = with lib; { homepage = "https://gitlab.com/sagemath/lcalc"; description = "A program for calculating with L-functions"; + mainProgram = "lcalc"; license = with licenses; [ gpl2 ]; maintainers = teams.sage.members; platforms = platforms.all; diff --git a/pkgs/development/libraries/science/math/magma/generic.nix b/pkgs/development/libraries/science/math/magma/generic.nix index 7ef60e0418ed..757a1b77dafc 100644 --- a/pkgs/development/libraries/science/math/magma/generic.nix +++ b/pkgs/development/libraries/science/math/magma/generic.nix @@ -5,35 +5,48 @@ # supportedGpuTargets: List String # } -{ blas +{ autoPatchelfHook +, blas , cmake +, cudaPackages_11 ? null , cudaPackages , cudaSupport ? config.cudaSupport , fetchurl , gfortran -, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities , gpuTargets ? [ ] # Non-CUDA targets, that is HIP -, rocmPackages +, rocmPackages_5 , lapack , lib , libpthreadstubs , magmaRelease , ninja +, python3 , config # At least one back-end has to be enabled, # and we can't default to CUDA since it's unfree , rocmSupport ? !cudaSupport , static ? stdenv.hostPlatform.isStatic , stdenv -, symlinkJoin }: let inherit (lib) lists strings trivial; - inherit (cudaPackages) backendStdenv cudaFlags cudaVersion; inherit (magmaRelease) version hash supportedGpuTargets; + # Per https://icl.utk.edu/magma/downloads, support for CUDA 12 wasn't added until 2.7.1. + # If we're building a version prior to that, use the latest release of the 11.x series. + effectiveCudaPackages = + if strings.versionOlder version "2.7.1" + then cudaPackages_11 + else cudaPackages; + + inherit (effectiveCudaPackages) cudaAtLeast cudaFlags cudaOlder; + inherit (cudaFlags) cudaCapabilities; + + # move to newer ROCm version once supported + rocmPackages = rocmPackages_5; + # NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements # of the first list *from* the second list. That means: # lists.subtractLists a b = b - a @@ -95,19 +108,34 @@ stdenv.mkDerivation { inherit hash; }; + # Magma doesn't have anything which could be run under doCheck, but it does build test suite executables. + # These are moved to $test/bin/ and $test/lib/ in postInstall. + outputs = ["out" "test"]; + + # Fixup for the python test runners + postPatch = '' + patchShebangs ./testing/run_{tests,summarize}.py + substituteInPlace ./testing/run_tests.py \ + --replace-fail \ + "print >>sys.stderr, cmdp, \"doesn't exist (original name: \" + cmd + \", precision: \" + precision + \")\"" \ + "print(f\"{cmdp} doesn't exist (original name: {cmd}, precision: {precision})\", file=sys.stderr)" + ''; + nativeBuildInputs = [ + autoPatchelfHook cmake ninja gfortran ] ++ lists.optionals cudaSupport [ - cudaPackages.cuda_nvcc + effectiveCudaPackages.cuda_nvcc ]; buildInputs = [ libpthreadstubs lapack blas - ] ++ lists.optionals cudaSupport (with cudaPackages; [ + python3 + ] ++ lists.optionals cudaSupport (with effectiveCudaPackages; [ cuda_cudart.dev # cuda_runtime.h cuda_cudart.lib # cudart cuda_cudart.static # cudart_static @@ -115,11 +143,11 @@ stdenv.mkDerivation { libcublas.lib # cublas libcusparse.dev # cusparse.h libcusparse.lib # cusparse - ] ++ lists.optionals (strings.versionOlder cudaVersion "11.8") [ + ] ++ lists.optionals (cudaOlder "11.8") [ cuda_nvprof.dev # <cuda_profiler_api.h> - ] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [ + ] ++ lists.optionals (cudaAtLeast "11.8") [ cuda_profiler_api.dev # <cuda_profiler_api.h> - ] ++ lists.optionals (strings.versionAtLeast cudaVersion "12.0") [ + ] ++ lists.optionals (cudaAtLeast "12.0") [ cuda_cccl.dev # <nv/target> ]) ++ lists.optionals rocmSupport [ rocmPackages.clr @@ -129,32 +157,60 @@ stdenv.mkDerivation { ]; cmakeFlags = [ - "-DGPU_TARGET=${gpuTargetString}" - (lib.cmakeBool "MAGMA_ENABLE_CUDA" cudaSupport) - (lib.cmakeBool "MAGMA_ENABLE_HIP" rocmSupport) - ] ++ lists.optionals static [ - "-DBUILD_SHARED_LIBS=OFF" + (strings.cmakeFeature "GPU_TARGET" gpuTargetString) + (strings.cmakeBool "MAGMA_ENABLE_CUDA" cudaSupport) + (strings.cmakeBool "MAGMA_ENABLE_HIP" rocmSupport) + (strings.cmakeBool "BUILD_SHARED_LIBS" (!static)) + # Set the Fortran name mangling scheme explicitly. We must set FORTRAN_CONVENTION manually because it will + # otherwise not be set in NVCC_FLAGS or DEVCCFLAGS (which we cannot modify). + # See https://github.com/NixOS/nixpkgs/issues/281656#issuecomment-1902931289 + (strings.cmakeBool "USE_FORTRAN" true) + (strings.cmakeFeature "CMAKE_C_FLAGS" "-DADD_") + (strings.cmakeFeature "CMAKE_CXX_FLAGS" "-DADD_") + (strings.cmakeFeature "FORTRAN_CONVENTION" "-DADD_") ] ++ lists.optionals cudaSupport [ - "-DCMAKE_CUDA_ARCHITECTURES=${cudaArchitecturesString}" - "-DMIN_ARCH=${minArch}" # Disarms magma's asserts - "-DCMAKE_C_COMPILER=${backendStdenv.cc}/bin/cc" - "-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++" + (strings.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaArchitecturesString) + (strings.cmakeFeature "MIN_ARCH" minArch) # Disarms magma's asserts ] ++ lists.optionals rocmSupport [ - "-DCMAKE_C_COMPILER=${rocmPackages.clr}/bin/hipcc" - "-DCMAKE_CXX_COMPILER=${rocmPackages.clr}/bin/hipcc" - ] ++ lists.optionals (cudaPackages.cudaAtLeast "12.0.0") [ - (lib.cmakeBool "USE_FORTRAN" false) - ]; - - buildFlags = [ - "magma" - "magma_sparse" + (strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clr}/bin/hipcc") + (strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clr}/bin/hipcc") ]; + # Magma doesn't have a test suite we can easily run, just loose executables, all of which require a GPU. doCheck = false; + # Copy the files to the test output and fix the RPATHs. + postInstall = + # NOTE: The python scripts aren't copied by CMake into the build directory, so we must copy them from the source. + # TODO(@connorbaker): This should be handled by having CMakeLists.txt install them, but such a patch is + # out of the scope of the PR which introduces the `test` output: https://github.com/NixOS/nixpkgs/pull/283777. + # See https://github.com/NixOS/nixpkgs/pull/283777#discussion_r1482125034 for more information. + # Such work is tracked by https://github.com/NixOS/nixpkgs/issues/296286. + '' + install -Dm755 ../testing/run_{tests,summarize}.py -t "$test/bin/" + '' + # Copy core test executables and libraries over to the test output. + # NOTE: Magma doesn't provide tests for sparse solvers for ROCm, but it does for CUDA -- we put them both in the same + # install command to avoid the case where a glob would fail to find any files and cause the install command to fail + # because it has no files to install. + + '' + install -Dm755 ./testing/testing_* ./sparse/testing/testing_* -t "$test/bin/" + install -Dm755 ./lib/lib*test*.* -t "$test/lib/" + '' + # All of the test executables and libraries will have a reference to the build directory in their RPATH, which we + # must remove. We do this by shrinking the RPATH to only include the Nix store. The autoPatchelfHook will take care + # of supplying the correct RPATH for needed libraries (like `libtester.so`). + + '' + find "$test" -type f -exec \ + patchelf \ + --shrink-rpath \ + --allowed-rpath-prefixes "$NIX_STORE" \ + {} \; + ''; + passthru = { - inherit cudaPackages cudaSupport rocmSupport gpuTargets; + inherit cudaSupport rocmSupport gpuTargets; + cudaPackages = effectiveCudaPackages; }; meta = with lib; { @@ -168,6 +224,7 @@ stdenv.mkDerivation { broken = !(cudaSupport || rocmSupport) # At least one back-end enabled || (cudaSupport && rocmSupport) # Mutually exclusive - || (cudaSupport && strings.versionOlder cudaVersion "9"); + || (cudaSupport && cudaOlder "9.0") + || (cudaSupport && strings.versionOlder version "2.7.1" && cudaPackages_11 == null); }; } diff --git a/pkgs/development/libraries/science/math/mongoose/default.nix b/pkgs/development/libraries/science/math/mongoose/default.nix index 29b901277f61..c1eed9bf432a 100644 --- a/pkgs/development/libraries/science/math/mongoose/default.nix +++ b/pkgs/development/libraries/science/math/mongoose/default.nix @@ -61,6 +61,7 @@ stdenv.mkDerivation { meta = with lib; { description = "Graph Coarsening and Partitioning Library"; + mainProgram = "suitesparse_mongoose"; homepage = "https://github.com/DrTimothyAldenDavis/SuiteSparse/tree/dev/Mongoose"; license = licenses.gpl3Only; maintainers = with maintainers; [ wegank ]; diff --git a/pkgs/development/libraries/science/math/or-tools/default.nix b/pkgs/development/libraries/science/math/or-tools/default.nix index 5cbc23589895..1b17f9576175 100644 --- a/pkgs/development/libraries/science/math/or-tools/default.nix +++ b/pkgs/development/libraries/science/math/or-tools/default.nix @@ -120,6 +120,7 @@ stdenv.mkDerivation rec { description = '' Google's software suite for combinatorial optimization. ''; + mainProgram = "fzn-ortools"; maintainers = with maintainers; [ andersk ]; platforms = with platforms; linux ++ darwin; }; diff --git a/pkgs/development/libraries/science/math/planarity/default.nix b/pkgs/development/libraries/science/math/planarity/default.nix index 3b072fecde34..196ee5de576b 100644 --- a/pkgs/development/libraries/science/math/planarity/default.nix +++ b/pkgs/development/libraries/science/math/planarity/default.nix @@ -23,6 +23,7 @@ stdenv.mkDerivation rec { meta = with lib; { homepage = "https://github.com/graph-algorithms/edge-addition-planarity-suite"; description = "A library for implementing graph algorithms"; + mainProgram = "planarity"; license = licenses.bsd3; maintainers = teams.sage.members; platforms = platforms.unix; diff --git a/pkgs/development/libraries/science/math/sympow/default.nix b/pkgs/development/libraries/science/math/sympow/default.nix index 09ca356ccdc5..1033f26f4360 100644 --- a/pkgs/development/libraries/science/math/sympow/default.nix +++ b/pkgs/development/libraries/science/math/sympow/default.nix @@ -73,6 +73,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Compute special values of symmetric power elliptic curve L-functions"; + mainProgram = "sympow"; license = { shortName = "sympow"; fullName = "Custom, BSD-like. See COPYING file."; diff --git a/pkgs/development/libraries/science/math/trilinos/default.nix b/pkgs/development/libraries/science/math/trilinos/default.nix index 1939b0a5307b..8e461f1caf24 100644 --- a/pkgs/development/libraries/science/math/trilinos/default.nix +++ b/pkgs/development/libraries/science/math/trilinos/default.nix @@ -88,6 +88,7 @@ stdenv.mkDerivation rec { meta = with lib; { description = "Engineering and scientific problems algorithms"; + mainProgram = "nvcc_wrapper"; longDescription = '' The Trilinos Project is an effort to develop algorithms and enabling technologies within an object-oriented software framework for the |