diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/science')
115 files changed, 6167 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch new file mode 100644 index 000000000000..0ea3b55ef708 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/darwin-rpath-universal.patch @@ -0,0 +1,21 @@ +diff -ruN cfitsio/configure cfitsio-rpath-universal/configure +--- cfitsio/configure 2018-05-09 21:16:00.000000000 +0200 ++++ cfitsio-rpath-universal/configure 2021-10-27 12:02:25.000000000 +0200 +@@ -4829,16 +4829,7 @@ + SHLIB_SUFFIX=".dylib" + CFITSIO_SHLIB="lib\${PACKAGE}.\${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}\${SHLIB_SUFFIX}" + CFITSIO_SHLIB_SONAME="lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX}" +- case $host in +- *darwin[56789]*) +- SHLIB_LD="$CC -dynamiclib -install_name lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}.\${CFITSIO_MICRO}" +- ;; +- *) +- # Build 'Universal' binaries (i386 & x86_64 architectures) and +- # use rpath token on Darwin 10.x or newer: +- SHLIB_LD="$CC -dynamiclib $C_UNIV_SWITCH -headerpad_max_install_names -install_name @rpath/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}.\${CFITSIO_MICRO}" +- ;; +- esac ++ SHLIB_LD="$CC -dynamiclib -install_name ${out}/lib/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}" + + lhea_shlib_cflags="-fPIC -fno-common" + ;; diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix new file mode 100644 index 000000000000..9f9545e52f3b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/cfitsio/default.nix @@ -0,0 +1,42 @@ +{ stdenv, lib, fetchurl, bzip2, zlib }: + +stdenv.mkDerivation rec { + pname = "cfitsio"; + version = "4.0.0"; + + src = fetchurl { + url = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-${version}.tar.gz"; + sha256 = "sha256-sqjvugufhtPhvWGfZipHbsGBErTyfMRBzGgKTjd3Ql4="; + }; + + buildInputs = [ bzip2 zlib ]; + + patches = [ ./darwin-rpath-universal.patch ]; + + configureFlags = [ "--with-bzip2=${bzip2.out}" ]; + + hardeningDisable = [ "format" ]; + + # Shared-only build + buildFlags = [ "shared" ]; + postPatch = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in + ''; + + meta = with lib; { + homepage = "https://heasarc.gsfc.nasa.gov/fitsio/"; + description = "Library for reading and writing FITS data files"; + longDescription = + '' CFITSIO is a library of C and Fortran subroutines for reading and + writing data files in FITS (Flexible Image Transport System) data + format. CFITSIO provides simple high-level routines for reading and + writing FITS files that insulate the programmer from the internal + complexities of the FITS format. CFITSIO also provides many + advanced features for manipulating and filtering the information in + FITS files. + ''; + changelog = "https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/changes.txt"; + license = licenses.mit; + maintainers = with maintainers; [ xbreak hjones2199 ]; + platforms = with platforms; linux ++ darwin; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix new file mode 100644 index 000000000000..60f5e51ae957 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/default.nix @@ -0,0 +1,56 @@ +{ stdenv +, lib +, fetchFromGitHub +, cmake +, cfitsio +, libusb1 +, zlib +, boost +, libnova +, curl +, libjpeg +, gsl +, fftw +}: + +stdenv.mkDerivation rec { + pname = "indilib"; + version = "1.9.4"; + + src = fetchFromGitHub { + owner = "indilib"; + repo = "indi"; + rev = "v${version}"; + sha256 = "sha256-U3Q0WUEDRn0zfBIdHXFp5Zcaf+M6HrSFnpeu5aAkjks="; + }; + + nativeBuildInputs = [ + cmake + ]; + + buildInputs = [ + curl + cfitsio + libusb1 + zlib + boost + libnova + libjpeg + gsl + fftw + ]; + + cmakeFlags = [ + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d" + ]; + + meta = with lib; { + homepage = "https://www.indilib.org/"; + description = "Implementation of the INDI protocol for POSIX operating systems"; + changelog = "https://github.com/indilib/indi/releases/tag/v${version}"; + license = licenses.lgpl2Plus; + maintainers = with maintainers; [ hjones2199 ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix new file mode 100644 index 000000000000..c4faadd2a5eb --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-3rdparty.nix @@ -0,0 +1,79 @@ +{ stdenv +, lib +, cmake +, cfitsio +, libusb1 +, zlib +, boost +, libnova +, curl +, libjpeg +, gsl +, fftw +, indilib +, libgphoto2 +, libraw +, libftdi1 +, libdc1394 +, gpsd +, ffmpeg +, version +, src +, withFirmware ? false +, firmware ? null +}: + +stdenv.mkDerivation rec { + pname = "indi-3rdparty"; + + inherit version src; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd + libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw + ] ++ lib.optionals withFirmware [ + firmware + ]; + + postPatch = '' + for f in indi-qsi/CMakeLists.txt \ + indi-dsi/CMakeLists.txt \ + indi-armadillo-platypus/CMakeLists.txt \ + indi-orion-ssg3/CMakeLists.txt + do + substituteInPlace $f \ + --replace "/lib/udev/rules.d" "lib/udev/rules.d" \ + --replace "/etc/udev/rules.d" "lib/udev/rules.d" \ + --replace "/lib/firmware" "lib/firmware" + done + ''; + + cmakeFlags = [ + "-DINDI_DATA_DIR=share/indi" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d" + "-DRULES_INSTALL_DIR=lib/udev/rules.d" + # Pentax, Atik, and SX cmakelists are currently broken + "-DWITH_PENTAX=off" + "-DWITH_ATIK=off" + "-DWITH_SX=off" + ] ++ lib.optionals (!withFirmware) [ + "-DWITH_APOGEE=off" + "-DWITH_DSI=off" + "-DWITH_QHY=off" + "-DWITH_ARMADILLO=off" + "-DWITH_FISHCAMP=off" + "-DWITH_SBIG=off" + ]; + + meta = with lib; { + homepage = "https://www.indilib.org/"; + description = "Third party drivers for the INDI astronomical software suite"; + changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}"; + license = licenses.lgpl2Plus; + maintainers = with maintainers; [ hjones2199 ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix new file mode 100644 index 000000000000..d23673ac37ae --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-firmware.nix @@ -0,0 +1,66 @@ +{ stdenv +, lib +, cmake +, cfitsio +, libusb1 +, zlib +, boost +, libnova +, curl +, libjpeg +, gsl +, fftw +, indilib +, libgphoto2 +, libraw +, libftdi1 +, libdc1394 +, gpsd +, ffmpeg +, version +, src +}: + +stdenv.mkDerivation rec { + pname = "indi-firmware"; + + inherit version src; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ + indilib libnova curl cfitsio libusb1 zlib boost gsl gpsd + libjpeg libgphoto2 libraw libftdi1 libdc1394 ffmpeg fftw + ]; + + cmakeFlags = [ + "-DINDI_DATA_DIR=\${CMAKE_INSTALL_PREFIX}/share/indi" + "-DCMAKE_INSTALL_LIBDIR=lib" + "-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d" + "-DRULES_INSTALL_DIR=lib/udev/rules.d" + "-DFIRMWARE_INSTALL_DIR=\${CMAKE_INSTALL_PREFIX}/lib/firmware" + "-DCONF_DIR=etc" + "-DBUILD_LIBS=1" + "-DWITH_PENTAX=off" + ]; + + postPatch = '' + for f in libfishcamp/CMakeLists.txt libsbig/CMakeLists.txt + do + substituteInPlace $f --replace "/lib/firmware" "lib/firmware" + done + ''; + + postFixup = '' + rm $out/lib/udev/rules.d/99-fli.rules + ''; + + meta = with lib; { + homepage = "https://www.indilib.org/"; + description = "Third party firmware for the INDI astronomical software suite"; + changelog = "https://github.com/indilib/indi-3rdparty/releases/tag/v${version}"; + license = licenses.lgpl2Plus; + maintainers = with maintainers; [ hjones2199 ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix new file mode 100644 index 000000000000..a20c92dfaeba --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-full.nix @@ -0,0 +1,30 @@ +{ stdenv, lib, callPackage, fetchFromGitHub, indilib }: + +let + indi-version = "1.9.3"; + indi-3rdparty-src = fetchFromGitHub { + owner = "indilib"; + repo = "indi-3rdparty"; + rev = "v${indi-version}"; + sha256 = "sha256-TBccdheBEO48uIXd6tya6dytkzxaHg2+YancBkcL3bw="; + }; + indi-firmware = callPackage ./indi-firmware.nix { + version = indi-version; + src = indi-3rdparty-src; + }; + indi-3rdparty = callPackage ./indi-3rdparty.nix { + version = indi-version; + src = indi-3rdparty-src; + withFirmware = stdenv.isx86_64; + firmware = indi-firmware; + }; +in +callPackage ./indi-with-drivers.nix { + pname = "indi-full"; + version = indi-version; + extraDrivers = [ + indi-3rdparty + ] ++ lib.optionals stdenv.isx86_64 [ + indi-firmware + ]; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix new file mode 100644 index 000000000000..5ec1acdf21e9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/indilib/indi-with-drivers.nix @@ -0,0 +1,10 @@ +{ buildEnv, indilib ? indilib, pname ? "indi-with-drivers", version ? null, extraDrivers ? null }: + +buildEnv { + name = "${pname}-${version}"; + paths = [ + indilib + ] + ++ extraDrivers; + inherit (indilib) meta; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix new file mode 100644 index 000000000000..f6a8d01ab845 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/libnova/default.nix @@ -0,0 +1,25 @@ +{ lib, stdenv, fetchgit, autoreconfHook }: + +stdenv.mkDerivation rec { + pname = "libnova"; + version = "0.16"; + + # pull from git repo because upstream stopped tarball releases after v0.15 + src = fetchgit { + url = "https://git.code.sf.net/p/libnova/${pname}"; + rev = "v${version}"; + sha256 = "0icwylwkixihzni0kgl0j8dx3qhqvym6zv2hkw2dy6v9zvysrb1b"; + }; + + nativeBuildInputs = [ + autoreconfHook + ]; + + meta = with lib; { + description = "Celestial Mechanics, Astrometry and Astrodynamics Library"; + homepage = "http://libnova.sf.net"; + license = licenses.gpl2; + maintainers = with maintainers; [ hjones2199 ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix new file mode 100644 index 000000000000..a214d28347de --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/stellarsolver/default.nix @@ -0,0 +1,30 @@ +{ lib, mkDerivation, fetchFromGitHub, cmake, + qtbase, cfitsio, gsl, wcslib, withTester ? false }: + +mkDerivation rec { + pname = "stellarsolver"; + version = "1.9"; + + src = fetchFromGitHub { + owner = "rlancaste"; + repo = pname; + rev = version; + sha256 = "sha256-PiRXNiemJ+UjVhmd2KPcTKJoDW9K9QBf62nkP1LlOfw="; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ qtbase cfitsio gsl wcslib ]; + + cmakeFlags = [ + "-DBUILD_TESTER=${if withTester then "on" else "off"}" + ]; + + meta = with lib; { + homepage = "https://github.com/rlancaste/stellarsolver"; + description = "Astrometric plate solving library"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ hjones2199 ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix b/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix new file mode 100644 index 000000000000..6adf52514710 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/astronomy/wcslib/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv, fetchurl, flex }: + +stdenv.mkDerivation rec { + pname = "wcslib"; + version = "7.7"; + + src = fetchurl { + url = "ftp://ftp.atnf.csiro.au/pub/software/wcslib/${pname}-${version}.tar.bz2"; + sha256 = "sha256-pwjmtOkOLNZCdDRxW1kbucPUAFyZcl7ElLjgvtLeU1U="; + }; + + nativeBuildInputs = [ flex ]; + + enableParallelBuilding = true; + + outputs = [ "out" "man" ]; + + meta = with lib; { + homepage = "https://www.atnf.csiro.au/people/mcalabre/WCS/"; + description = "World Coordinate System library for astronomy"; + longDescription = '' + Library for world coordinate systems for spherical geometries + and their conversion to image coordinate systems. This is the + standard library for this purpose in astronomy. + ''; + maintainers = with maintainers; [ hjones2199 ]; + license = licenses.lgpl3Plus; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix new file mode 100644 index 000000000000..d4610d60415b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/benchmark/papi/default.nix @@ -0,0 +1,28 @@ +{ lib, stdenv +, fetchurl +}: + +stdenv.mkDerivation rec { + version = "6.0.0.1"; + pname = "papi"; + + src = fetchurl { + url = "https://bitbucket.org/icl/papi/get/papi-${lib.replaceStrings ["."] ["-"] version}-t.tar.gz"; + sha256 = "1jd67yadyffzxwsqlylsi0bx8ishb0cgj2ziz1wdslaz6ylvyf9j"; + }; + + setSourceRoot = '' + sourceRoot=$(echo */src) + ''; + + doCheck = true; + checkTarget = "test"; + + meta = with lib; { + homepage = "https://icl.utk.edu/papi/"; + description = "Library providing access to various hardware performance counters"; + license = licenses.bsdOriginal; + platforms = platforms.linux; + maintainers = with maintainers; [ costrouc zhaofengli ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix new file mode 100644 index 000000000000..2a832fc7c37a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/EBTKS/default.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, fetchFromGitHub, cmake, libminc }: + +stdenv.mkDerivation rec { + pname = "EBTKS"; + version = "unstable-2017-09-23"; + + src = fetchFromGitHub { + owner = "BIC-MNI"; + repo = pname; + rev = "67e4e197d8a32d6462c9bdc7af44d64ebde4fb5c"; + sha256 = "1a1qw6i47fs1izx60l1ysabpmyx9j5sjnbdv8b47wi2xcc9i3hpq"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libminc ]; + + cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" ]; + + meta = with lib; { + homepage = "https://github.com/BIC-MNI/${pname}"; + description = "Library for working with MINC files"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.free; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix new file mode 100644 index 000000000000..4f98874b2595 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bicgl/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, cmake, libminc, bicpl, freeglut, mesa_glu, GLUT }: + +stdenv.mkDerivation rec { + pname = "bicgl"; + version = "unstable-2018-04-06"; + + owner = "BIC-MNI"; + + src = fetchFromGitHub { + inherit owner; + repo = pname; + rev = "61a035751c9244fcca1edf94d6566fa2a709ce90"; + sha256 = "0lzirdi1mf4yl8srq7vjn746sbydz7h0wjh7wy8gycy6hq04qrg4"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libminc bicpl mesa_glu ] + ++ lib.optionals stdenv.isDarwin [ GLUT ] + ++ lib.optionals stdenv.isLinux [ freeglut ]; + + cmakeFlags = [ + "-DLIBMINC_DIR=${libminc}/lib/cmake" + "-DBICPL_DIR=${bicpl}/lib" + ]; + + meta = with lib; { + homepage = "https://github.com/${owner}/${pname}"; + description = "Brain Imaging Centre graphics library"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.free; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix new file mode 100644 index 000000000000..5cf63e342242 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bicpl/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv, fetchFromGitHub, cmake, libminc, netpbm }: + +stdenv.mkDerivation rec { + pname = "bicpl"; + version = "unstable-2020-10-15"; + + # current master is significantly ahead of most recent release, so use Git version: + src = fetchFromGitHub { + owner = "BIC-MNI"; + repo = pname; + rev = "a58af912a71a4c62014975b89ef37a8e72de3c9d"; + sha256 = "0iw0pmr8xrifbx5l8a0xidfqbm1v8hwzqrw0lcmimxlzdihyri0g"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ libminc netpbm ]; + + cmakeFlags = [ "-DLIBMINC_DIR=${libminc}/lib/cmake" ]; + + doCheck = false; + # internal_volume_io.h: No such file or directory + + meta = with lib; { + homepage = "https://github.com/BIC-MNI/bicpl"; + description = "Brain Imaging Centre programming library"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.free; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix new file mode 100644 index 000000000000..d1eb096e08e6 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-core/default.nix @@ -0,0 +1,36 @@ +{ lib, stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "bpp-core"; + version = "2.4.1"; + + src = fetchFromGitHub { owner = "BioPP"; + repo = pname; + rev = "v${version}"; + sha256 = "0ma2cl677l7s0n5sffh66cy9lxp5wycm50f121g8rx85p95vkgwv"; + }; + + nativeBuildInputs = [ cmake ]; + + preCheck = '' + export LD_LIBRARY_PATH=$(pwd)/src + ''; + + postFixup = '' + substituteInPlace $out/lib/cmake/bpp-core/bpp-core-targets.cmake \ + --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX' + ''; + # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES + # of form /nix/store/.../nix/store/.../include, + # probably due to relative vs absolute path issue + + doCheck = !stdenv.isDarwin; + + meta = with lib; { + homepage = "http://biopp.univ-montp2.fr/wiki/index.php/Main_Page"; + changelog = "https://github.com/BioPP/bpp-core/blob/master/ChangeLog"; + description = "C++ bioinformatics libraries and tools"; + maintainers = with maintainers; [ bcdarwin ]; + license = licenses.cecill20; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix new file mode 100644 index 000000000000..8ff6ad433fb5 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-phyl/default.nix @@ -0,0 +1,32 @@ +{ stdenv, fetchFromGitHub, cmake, bpp-core, bpp-seq }: + +stdenv.mkDerivation rec { + pname = "bpp-phyl"; + + inherit (bpp-core) version; + + src = fetchFromGitHub { + owner = "BioPP"; + repo = pname; + rev = "v${version}"; + sha256 = "192zks6wyk903n06c2lbsscdhkjnfwms8p7jblsmk3lvjhdipb20"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ bpp-core bpp-seq ]; + + preCheck = '' + export LD_LIBRARY_PATH=$(pwd)/src + ''; + + postFixup = '' + substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake \ + --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX' + ''; + + doCheck = !stdenv.isDarwin; + + meta = bpp-core.meta // { + changelog = "https://github.com/BioPP/bpp-phyl/blob/master/ChangeLog"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix new file mode 100644 index 000000000000..af5d1d00d4d9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-popgen/default.nix @@ -0,0 +1,35 @@ +{ stdenv, fetchFromGitHub, cmake, bpp-core, bpp-seq }: + +stdenv.mkDerivation rec { + pname = "bpp-popgen"; + + inherit (bpp-core) version; + + src = fetchFromGitHub { + owner = "BioPP"; + repo = pname; + rev = "v${version}"; + sha256 = "0bz0fhrq3dri6a0hvfc3zlvrns8mrzzlnicw5pyfa812gc1qwfvh"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ bpp-core bpp-seq ]; + + preCheck = '' + export LD_LIBRARY_PATH=$(pwd)/src + ''; + + postFixup = '' + substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake \ + --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX' + ''; + # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES + # of form /nix/store/.../nix/store/.../include, + # probably due to relative vs absolute path issue + + doCheck = !stdenv.isDarwin; + + meta = bpp-core.meta // { + changelog = "https://github.com/BioPP/bpp-popgen/blob/master/ChangeLog"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix new file mode 100644 index 000000000000..ef3f3d5756e9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/bpp-seq/default.nix @@ -0,0 +1,35 @@ +{ stdenv, fetchFromGitHub, cmake, bpp-core }: + +stdenv.mkDerivation rec { + pname = "bpp-seq"; + + inherit (bpp-core) version; + + src = fetchFromGitHub { + owner = "BioPP"; + repo = pname; + rev = "v${version}"; + sha256 = "1mc09g8jswzsa4wgrfv59jxn15ys3q8s0227p1j838wkphlwn2qk"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ bpp-core ]; + + preCheck = '' + export LD_LIBRARY_PATH=$(pwd)/src + ''; + + postFixup = '' + substituteInPlace $out/lib/cmake/${pname}/${pname}-targets.cmake \ + --replace 'set(_IMPORT_PREFIX' '#set(_IMPORT_PREFIX' + ''; + # prevents cmake from exporting incorrect INTERFACE_INCLUDE_DIRECTORIES + # of form /nix/store/.../nix/store/.../include, + # probably due to relative vs absolute path issue + + doCheck = !stdenv.isDarwin; + + meta = bpp-core.meta // { + changelog = "https://github.com/BioPP/bpp-seq/blob/master/ChangeLog"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix new file mode 100644 index 000000000000..15465c501b43 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/elastix/default.nix @@ -0,0 +1,38 @@ +{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, itk, python3, Cocoa }: + +stdenv.mkDerivation rec { + pname = "elastix"; + version = "5.0.1"; + + src = fetchFromGitHub { + owner = "SuperElastix"; + repo = pname; + rev = version; + sha256 = "1mx8kkak2d3ibfrxrh8jkmh2zkdlgl9h578wiw3617zcwaa97bxw"; + }; + + patches = [ + (fetchpatch { + name = "install-executables.patch"; # https://github.com/SuperElastix/elastix/issues/305 + url = "https://github.com/SuperElastix/elastix/commit/8e26cdc0d66f6030c7be085fdc424d84d4fc7546.patch"; + sha256 = "12y9wbpi9jlarnw6fk4iby97jxvx5g4daq9zqblbcmn51r134bj5"; + }) + ]; + + nativeBuildInputs = [ cmake python3 ]; + buildInputs = [ itk ] ++ lib.optionals stdenv.isDarwin [ Cocoa ]; + + doCheck = !stdenv.isDarwin; # usual dynamic linker issues + + preCheck = " + export LD_LIBRARY_PATH=$(pwd)/bin + "; + + meta = with lib; { + homepage = "https://elastix.lumc.nl"; + description = "Image registration toolkit based on ITK"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.x86_64; # libitkpng linker issues with ITK 5.1 + license = licenses.asl20; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix new file mode 100644 index 000000000000..306324129cbd --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/gifticlib/default.nix @@ -0,0 +1,34 @@ +{ lib, stdenv, fetchFromGitHub, cmake, expat, nifticlib, zlib }: + +stdenv.mkDerivation rec { + pname = "gifticlib"; + version = "unstable-2020-07-07"; + + src = fetchFromGitHub { + owner = "NIFTI-Imaging"; + repo = "gifti_clib"; + rev = "5eae81ba1e87ef3553df3b6ba585f12dc81a0030"; + sha256 = "0gcab06gm0irjnlrkpszzd4wr8z0fi7gx8f7966gywdp2jlxzw19"; + }; + + cmakeFlags = [ "-DUSE_SYSTEM_NIFTI=ON" "-DDOWNLOAD_TEST_DATA=OFF" ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ expat nifticlib zlib ]; + + # without the test data, this is only a few basic tests + doCheck = !stdenv.isDarwin; + checkPhase = '' + runHook preCheck + ctest -LE 'NEEDS_DATA' + runHook postCheck + ''; + + meta = with lib; { + homepage = "https://www.nitrc.org/projects/gifti"; + description = "Medical imaging geometry format C API"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.publicDomain; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix new file mode 100644 index 000000000000..8a9df7601d28 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/htslib/default.nix @@ -0,0 +1,36 @@ +{ lib, stdenv, fetchurl, zlib, bzip2, xz, curl, perl }: + +stdenv.mkDerivation rec { + pname = "htslib"; + version = "1.14"; + + src = fetchurl { + url = "https://github.com/samtools/htslib/releases/download/${version}/${pname}-${version}.tar.bz2"; + sha256 = "sha256-7SIbj1L0gS+BDuvgzFbNg1WlydIcYtFCrAWtDaFHk18="; + }; + + # perl is only used during the check phase. + nativeBuildInputs = [ perl ]; + + buildInputs = [ zlib bzip2 xz curl ]; + + configureFlags = [ "--enable-libcurl" ]; # optional but strongly recommended + + installFlags = [ "prefix=$(out)" ]; + + preCheck = '' + patchShebangs test/ + ''; + + enableParallelBuilding = true; + + doCheck = true; + + meta = with lib; { + description = "A C library for reading/writing high-throughput sequencing data"; + license = licenses.mit; + homepage = "http://www.htslib.org/"; + platforms = platforms.unix; + maintainers = [ maintainers.mimame ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix new file mode 100644 index 000000000000..d2615b391ffc --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/mirtk/default.nix @@ -0,0 +1,44 @@ +{ lib, stdenv, gtest, fetchFromGitHub, cmake, boost, eigen, python3, vtk, zlib, tbb }: + +stdenv.mkDerivation rec { + version = "2.0.0"; + pname = "mirtk"; + + src = fetchFromGitHub { + owner = "BioMedIA"; + repo = "MIRTK"; + rev = "v${version}"; + sha256 = "0i2v97m66ir5myvi5b123r7zcagwy551b73s984gk7lksl5yiqxk"; + fetchSubmodules = true; + }; + + cmakeFlags = [ + "-DWITH_VTK=ON" + "-DBUILD_ALL_MODULES=ON" + "-DWITH_TBB=ON" + ]; + + doCheck = true; + + checkPhase = '' + ctest -E '(Polynomial|ConvolutionFunction|Downsampling|EdgeTable|InterpolateExtrapolateImage)' + ''; + # testPolynomial - segfaults for some reason + # testConvolutionFunction, testDownsampling - main not called correctly + # testEdgeTable, testInterpolateExtrapolateImageFunction - setup fails + + postInstall = '' + install -Dm644 -t "$out/share/bash-completion/completions/mirtk" share/completion/bash/mirtk + ''; + + nativeBuildInputs = [ cmake gtest ]; + buildInputs = [ boost eigen python3 vtk zlib tbb ]; + + meta = with lib; { + homepage = "https://github.com/BioMedIA/MIRTK"; + description = "Medical image registration library and tools"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.linux; + license = licenses.asl20; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix new file mode 100644 index 000000000000..fee2ea8772b4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/nifticlib/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, cmake, zlib }: + +stdenv.mkDerivation rec { + pname = "nifticlib"; + version = "3.0.1"; + + src = fetchFromGitHub { + owner = "NIFTI-Imaging"; + repo = "nifti_clib"; + rev = "v${version}"; + sha256 = "0hamm6nvbjdjjd5md4jahzvn5559frigxaiybnjkh59ckxwb1hy4"; + }; + + cmakeFlags = [ "-DDOWNLOAD_TEST_DATA=OFF" ]; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ zlib ]; + + checkPhase = '' + runHook preCheck + ctest -LE 'NEEDS_DATA' + runHook postCheck + ''; + doCheck = true; + + meta = with lib; { + homepage = "https://nifti-imaging.github.io"; + description = "Medical imaging format C API"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.publicDomain; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix new file mode 100644 index 000000000000..7f1112311d6b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/biology/oobicpl/default.nix @@ -0,0 +1,39 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, libminc +, bicpl +, arguments +, pcre-cpp }: + +stdenv.mkDerivation rec { + pname = "oobicpl"; + version = "unstable-2020-08-12"; + + src = fetchFromGitHub { + owner = "BIC-MNI"; + repo = pname; + rev = "a9409da8a5bb4925438f32aff577b6333faec28b"; + sha256 = "0b4chjhr32wbb1sash8cq1jfnr7rzdq84hif8anlrjqd3l0gw357"; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libminc bicpl arguments pcre-cpp ]; + + cmakeFlags = [ + "-DLIBMINC_DIR=${libminc}/lib/cmake" + "-DBICPL_DIR=${bicpl}/lib" + "-DARGUMENTS_DIR=${arguments}/lib" + "-DOOBICPL_BUILD_SHARED_LIBS=TRUE" + ]; + + meta = with lib; { + homepage = "https://github.com/BIC-MNI/oobicpl"; + description = "Brain Imaging Centre object-oriented programming library (and tools)"; + maintainers = with maintainers; [ bcdarwin ]; + platforms = platforms.unix; + license = licenses.free; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix new file mode 100644 index 000000000000..b7f5f5f6d90e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/avogadrolibs/default.nix @@ -0,0 +1,68 @@ +{ lib, stdenv, fetchFromGitHub, cmake, zlib, eigen, libGL, doxygen, spglib +, mmtf-cpp, glew, python3, libarchive, libmsym, msgpack, qttools, wrapQtAppsHook +}: + +let + pythonWP = python3.withPackages (p: with p; [ openbabel-bindings numpy ]); + + # Pure data repositories + moleculesRepo = fetchFromGitHub { + owner = "OpenChemistry"; + repo = "molecules"; + rev = "1.0.0"; + sha256 = "guY6osnpv7Oqt+HE1BpIqL10POp+x8GAci2kY0bLmqg="; + }; + crystalsRepo = fetchFromGitHub { + owner = "OpenChemistry"; + repo = "crystals"; + rev = "1.0.1"; + sha256 = "sH/WuvLaYu6akOc3ssAKhnxD8KNoDxuafDSozHqJZC4="; + }; + +in stdenv.mkDerivation rec { + pname = "avogadrolibs"; + version = "1.95.1"; + + src = fetchFromGitHub { + owner = "OpenChemistry"; + repo = pname; + rev = version; + sha256 = "0zzVg8xNqFwDrK8gRkDm3tRgBt7fD4K3Uy/ajUBc+eQ="; + }; + + postUnpack = '' + cp -r ${moleculesRepo} molecules + cp -r ${crystalsRepo} crystals + ''; + + nativeBuildInputs = [ + cmake + wrapQtAppsHook + ]; + + buildInputs = [ + eigen + zlib + libGL + spglib + mmtf-cpp + glew + libarchive + libmsym + msgpack + qttools + ]; + + postFixup = '' + substituteInPlace $out/lib/cmake/${pname}/AvogadroLibsConfig.cmake \ + --replace "''${AvogadroLibs_INSTALL_PREFIX}/$out" "''${AvogadroLibs_INSTALL_PREFIX}" + ''; + + meta = with lib; { + description = "Molecule editor and visualizer"; + maintainers = with maintainers; [ sheepforce ]; + homepage = "https://github.com/OpenChemistry/avogadrolibs"; + platforms = platforms.linux; + license = licenses.gpl2Only; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix new file mode 100644 index 000000000000..9781ce780660 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/cppe/default.nix @@ -0,0 +1,26 @@ +{ stdenv, lib, fetchFromGitHub, cmake, llvmPackages }: + +stdenv.mkDerivation rec { + pname = "cppe"; + version = "0.3.1"; + + src = fetchFromGitHub { + owner = "maxscheurer"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-guM7+ZWDJLcAUJtPkKLvC4LYSA2eBvER7cgwPZ7FxHw="; + }; + + nativeBuildInputs = [ cmake ] + ++ lib.optionals stdenv.cc.isClang [ llvmPackages.openmp ]; + + cmakeFlags = [ "-DCMAKE_INSTALL_LIBDIR=lib" ]; + + meta = with lib; { + description = "C++ and Python library for Polarizable Embedding"; + homepage = "https://github.com/maxscheurer/cppe"; + license = licenses.lgpl3Only; + platforms = platforms.unix; + maintainers = [ maintainers.sheepforce ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix new file mode 100644 index 000000000000..fdcf7d00e3ba --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/libmsym/default.nix @@ -0,0 +1,23 @@ +{ stdenv, lib, fetchFromGitHub, cmake } : + +stdenv.mkDerivation rec { + pname = "libmsym"; + version = "0.2.3"; + + src = fetchFromGitHub { + owner = "mcodev31"; + repo = pname; + rev = "v${version}"; + sha256= "k+OEwrA/saupP/wX6Ii5My0vffiJ0X9xMCTrliMSMik="; + }; + + nativeBuildInputs = [ cmake ]; + + meta = with lib; { + description = " molecular point group symmetry lib"; + homepage = "https://github.com/mcodev31/libmsym"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = [ maintainers.sheepforce ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix new file mode 100644 index 000000000000..ec1fed68ff93 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/mmtf-cpp/default.nix @@ -0,0 +1,25 @@ +{ stdenv, lib, fetchFromGitHub, cmake, msgpack } : + +stdenv.mkDerivation rec { + pname = "mmtf-cpp"; + version = "1.0.0"; + + src = fetchFromGitHub { + owner = "rcsb"; + repo = pname; + rev = "v${version}"; + sha256= "17ylramda69plf5w0v5hxbl4ggkdi5s15z55cv0pljl12yvyva8l"; + }; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ msgpack ]; + + meta = with lib; { + description = "A library of exchange-correlation functionals with arbitrary-order derivatives"; + homepage = "https://github.com/rcsb/mmtf-cpp"; + license = licenses.mit; + platforms = platforms.linux; + maintainers = [ maintainers.sheepforce ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix new file mode 100644 index 000000000000..1e8ca2d961d3 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/molequeue/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, cmake, qttools, wrapQtAppsHook }: + +stdenv.mkDerivation rec { + pname = "molequeue"; + version = "0.9.0"; + + src = fetchFromGitHub { + owner = "OpenChemistry"; + repo = pname; + rev = version; + sha256 = "+NoY8YVseFyBbxc3ttFWiQuHQyy1GN8zvV1jGFjmvLg="; + }; + + nativeBuildInputs = [ + cmake + wrapQtAppsHook + ]; + + buildInputs = [ qttools ]; + + postFixup = '' + substituteInPlace $out/lib/cmake/molequeue/MoleQueueConfig.cmake \ + --replace "''${MoleQueue_INSTALL_PREFIX}/$out" "''${MoleQueue_INSTALL_PREFIX}" + ''; + + meta = with lib; { + description = "Desktop integration of high performance computing resources"; + maintainers = with maintainers; [ sheepforce ]; + homepage = "https://github.com/OpenChemistry/molequeue"; + platforms = platforms.linux; + license = licenses.bsd3; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix b/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix new file mode 100644 index 000000000000..0856168092cb --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/chemistry/xcfun/default.nix @@ -0,0 +1,30 @@ +{ stdenv, lib, fetchFromGitHub, cmake, gfortran, python3 } : + +stdenv.mkDerivation rec { + pname = "xcfun"; + version = "2.1.1"; + + src = fetchFromGitHub { + owner = "dftlibs"; + repo = pname; + rev = "v${version}"; + sha256 = "1bj70cnhbh6ziy02x988wwl7cbwaq17ld7qwhswqkgnnx8rpgxid"; + }; + + nativeBuildInputs = [ + cmake + gfortran + ]; + + propagatedBuildInputs = [ (python3.withPackages (p: with p; [ pybind11 ])) ]; + + cmakeFlags = [ "-DXCFUN_MAX_ORDER=3" ]; + + meta = with lib; { + description = "A library of exchange-correlation functionals with arbitrary-order derivatives"; + homepage = "https://github.com/dftlibs/xcfun"; + license = licenses.mpl20; + platforms = platforms.linux; + maintainers = [ maintainers.sheepforce ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix b/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix new file mode 100644 index 000000000000..a20f6973384a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/electronics/qcsxcad/default.nix @@ -0,0 +1,47 @@ +{ lib +, mkDerivation +, fetchFromGitHub +, cmake +, csxcad +, tinyxml +, vtkWithQt5 +, qtbase +}: + +mkDerivation { + pname = "qcsxcad"; + version = "unstable-2020-01-04"; + + src = fetchFromGitHub { + owner = "thliebig"; + repo = "QCSXCAD"; + rev = "0dabbaf2bc1190adec300871cf309791af842c8e"; + sha256 = "11kbh0mxbdfh7s5azqin3i2alic5ihmdfj0jwgnrhlpjk4cbf9rn"; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ + cmake + ]; + + cmakeFlags = [ + "-DCSXCAD_ROOT_DIR=${csxcad}" + "-DENABLE_RPATH=OFF" + ]; + + buildInputs = [ + csxcad + tinyxml + vtkWithQt5 + qtbase + ]; + + meta = with lib; { + description = "Qt library for CSXCAD"; + homepage = "https://github.com/thliebig/QCSXCAD"; + license = licenses.gpl3; + maintainers = with maintainers; [ matthuszagh ]; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix new file mode 100644 index 000000000000..703a7f2e3441 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/QuadProgpp/default.nix @@ -0,0 +1,26 @@ +{ lib, stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "QuadProgpp"; + version = "4b6bd65f09fbff99c172a86d6e96ca74449b323f"; + + src = fetchFromGitHub { + owner = "liuq"; + repo = "QuadProgpp"; + rev = version; + sha256 = "02r0dlk2yjpafknvm945vbgs4sl26w2i1gw3pllar9hi364y8hnx"; + }; + + nativeBuildInputs = [ cmake ]; + + meta = with lib; { + homepage = "https://github.com/liuq/QuadProgpp"; + license = licenses.mit; + description = '' + A C++ library for Quadratic Programming which implements the + Goldfarb-Idnani active-set dual method. + ''; + maintainers = with maintainers; [ ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix new file mode 100644 index 000000000000..cba9c28164a3 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-blis/default.nix @@ -0,0 +1,70 @@ +{ lib, stdenv +, fetchFromGitHub +, perl +, python3 + +# Enable BLAS interface with 64-bit integer width. +, blas64 ? false + +# Target architecture. "amd64" compiles kernels for all Zen +# generations. To build kernels for specific Zen generations, +# use "zen", "zen2", or "zen3". +, withArchitecture ? "amd64" + +# Enable OpenMP-based threading. +, withOpenMP ? true +}: + +let + threadingSuffix = if withOpenMP then "-mt" else ""; + blasIntSize = if blas64 then "64" else "32"; +in stdenv.mkDerivation rec { + pname = "amd-blis"; + version = "3.0"; + + src = fetchFromGitHub { + owner = "amd"; + repo = "blis"; + rev = version; + hash = "sha256-bbbeo1yOKse9pzbsB6lQ7pULKdzu3G7zJzTUgPXiMZY="; + }; + + inherit blas64; + + nativeBuildInputs = [ + perl + python3 + ]; + + # Tests currently fail with non-Zen CPUs due to a floating point + # exception in one of the generic kernels. Try to re-enable the + # next release. + doCheck = false; + + enableParallelBuilding = true; + + configureFlags = [ + "--enable-cblas" + "--blas-int-size=${blasIntSize}" + ] ++ lib.optionals withOpenMP [ "--enable-threading=openmp" ] + ++ [ withArchitecture ]; + + postPatch = '' + patchShebangs configure build/flatten-headers.py + ''; + + postInstall = '' + ln -s $out/lib/libblis${threadingSuffix}.so.3 $out/lib/libblas.so.3 + ln -s $out/lib/libblis${threadingSuffix}.so.3 $out/lib/libcblas.so.3 + ln -s $out/lib/libblas.so.3 $out/lib/libblas.so + ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so + ''; + + meta = with lib; { + description = "BLAS-compatible library optimized for AMD CPUs"; + homepage = "https://developer.amd.com/amd-aocl/blas-library/"; + license = licenses.bsd3; + maintainers = [ ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff new file mode 100644 index 000000000000..3e3ef1e60ff5 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/add-lapacke.diff @@ -0,0 +1,34 @@ +diff --git a/Makefile b/Makefile +index 5549ce30..ac2ee51e 100644 +--- a/Makefile ++++ b/Makefile +@@ -583,14 +583,14 @@ endif + + # --- Shared library linker rules --- + +-$(LIBFLAME_SO_PATH): $(MK_ALL_FLAMEC_OBJS) ++$(LIBFLAME_SO_PATH): $(MK_ALL_FLAMEC_OBJS) $(LAPACKE_A_PATH) + ifeq ($(ENABLE_VERBOSE),yes) + ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + $(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $(LIBFLAME_A) + ifeq ($(OS_NAME),Darwin) +- $(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS) ++ $(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A),$(LAPACKE_A_PATH) $(LDFLAGS) + else +- $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS) ++ $(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),$(LAPACKE_A_PATH)--no-whole-archive $(LDFLAGS) + endif + else + # NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in +@@ -602,9 +602,9 @@ else + ifeq ($(FLA_ENABLE_MAX_ARG_LIST_HACK),yes) + @$(CAT) $(AR_OBJ_LIST_FILE) | xargs -n$(AR_CHUNK_SIZE) $(AR) $(ARFLAGS) $(LIBFLAME_A) + ifeq ($(OS_NAME),Darwin) +- @$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A) $(LDFLAGS) ++ @$(LINKER) $(SOFLAGS) -o $@ -Wl,-force_load,$(LIBFLAME_A),$(LAPACKE_A_PATH) $(LDFLAGS) + else +- @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),--no-whole-archive $(LDFLAGS) ++ @$(LINKER) $(SOFLAGS) -o $@ -Wl,--whole-archive,$(LIBFLAME_A),$(LAPACKE_A_PATH),--no-whole-archive $(LDFLAGS) + endif + else + # NOTE: Can't use $^ automatic variable as long as $(AR_OBJ_LIST_FILE) is in diff --git a/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix new file mode 100644 index 000000000000..b28fa43a2269 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/amd-libflame/default.nix @@ -0,0 +1,72 @@ +{ lib +, stdenv +, fetchFromGitHub +, gfortran +, python3 +, amd-blis + +, withOpenMP ? true +}: + +stdenv.mkDerivation rec { + pname = "amd-libflame"; + version = "3.0"; + + src = fetchFromGitHub { + owner = "amd"; + repo = "libflame"; + rev = version; + hash = "sha256-jESae5NqANw90RBbIHH2oGEq5/mudc4IONv50P/AeQ0="; + }; + + patches = [ + # The LAPACKE interface is compiled as a separate static library, + # we want the main dynamic library to provide LAPACKE symbols. + # This patch adds lapacke.a to the shared library as well. + ./add-lapacke.diff + ]; + + nativeBuildInputs = [ gfortran python3 ]; + + buildInputs = [ amd-blis ]; + + configureFlags = [ + # Build a dynamic library with a LAPACK interface. + "--disable-static-build" + "--enable-dynamic-build" + "--enable-lapack2flame" + + # Use C BLAS interface. + "--enable-cblas-interfaces" + + # Avoid overloading maximum number of arguments. + "--enable-max-arg-list-hack" + + # libflame by default leaves BLAS symbols unresolved and leaves it + # up to the application to explicitly link to a BLAS. This is + # problematic for us, since then the BLAS library becomes an + # implicit dependency. Moreover, since the point of the AMD forks + # is to optimized for recent AMD CPUs, link against AMD BLIS. + "LDFLAGS=-lcblas" + ] + ++ lib.optionals withOpenMP [ "--enable-multithreading=openmp" ]; + + enableParallelBuilding = true; + + postPatch = '' + patchShebangs build + ''; + + postInstall = '' + ln -s $out/lib/libflame.so.${version} $out/lib/liblapack.so.3 + ln -s $out/lib/libflame.so.${version} $out/lib/liblapacke.so.3 + ''; + + meta = with lib; { + description = "LAPACK-compatible linear algebra library optimized for AMD CPUs"; + homepage = "https://developer.amd.com/amd-aocl/blas-library/"; + license = licenses.bsd3; + maintainers = with maintainers; [ ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix new file mode 100644 index 000000000000..88336f21ed27 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/arpack/default.nix @@ -0,0 +1,62 @@ +{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake +, gfortran, blas, lapack, eigen }: + +stdenv.mkDerivation rec { + pname = "arpack"; + version = "3.8.0"; + + src = fetchFromGitHub { + owner = "opencollab"; + repo = "arpack-ng"; + rev = version; + sha256 = "sha256-nc710iLRqy/p3EaVgbEoCRzNJ9GpKqqQp33tbn7R6lA="; + }; + + patches = [ + # https://github.com/opencollab/arpack-ng/pull/301 + (fetchpatch { + name = "pkg-config-paths.patch"; + url = "https://github.com/opencollab/arpack-ng/commit/47fc83cb371a9cc8a8c058097de5e0298cd548f5.patch"; + excludes = [ "CHANGES" ]; + sha256 = "1aijvrfsxkgzqmkzq2dmaj8q3jdpg2hwlqpfl8ddk9scv17gh9m8"; + }) + ]; + + nativeBuildInputs = [ cmake gfortran ]; + buildInputs = assert (blas.isILP64 == lapack.isILP64); [ + blas + lapack + eigen + ]; + + doCheck = true; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=ON" + "-DINTERFACE64=${if blas.isILP64 then "1" else "0"}" + ]; + + preCheck = if stdenv.isDarwin then '' + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH''${DYLD_LIBRARY_PATH:+:}`pwd`/lib:${blas}/lib:${lapack}/lib + '' else '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}`pwd`/lib + '' + '' + # Prevent tests from using all cores + export OMP_NUM_THREADS=2 + ''; + + postFixup = lib.optionalString stdenv.isDarwin '' + install_name_tool -change libblas.dylib ${blas}/lib/libblas.dylib $out/lib/libarpack.dylib + ''; + + meta = { + homepage = "https://github.com/opencollab/arpack-ng"; + description = '' + A collection of Fortran77 subroutines to solve large scale eigenvalue + problems. + ''; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ ttuegel dotlambda ]; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix new file mode 100644 index 000000000000..cfdc102e0447 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/blas/default.nix @@ -0,0 +1,71 @@ +{ lib, stdenv, fetchurl, gfortran }: + +stdenv.mkDerivation rec { + pname = "blas"; + version = "3.10.0"; + + src = fetchurl { + url = "http://www.netlib.org/blas/${pname}-${version}.tgz"; + sha256 = "sha256-LjYNmcm9yEB6YYiMQKqFP7QhlCDruCZNtIbLiGBGirM="; + }; + + nativeBuildInputs = [ gfortran ]; + + configurePhase = '' + echo >make.inc "SHELL = ${stdenv.shell}" + echo >>make.inc "PLAT = _LINUX" + echo >>make.inc "FORTRAN = gfortran" + echo >>make.inc "OPTS = -O2 -fPIC" + echo >>make.inc "DRVOPTS = $$(OPTS)" + echo >>make.inc "NOOPT = -O0 -fPIC" + echo >>make.inc "LOADER = gfortran" + echo >>make.inc "LOADOPTS =" + echo >>make.inc "AR = gfortran" + echo >>make.inc "ARFLAGS = -shared -o" + echo >>make.inc "RANLIB = echo" + echo >>make.inc "BLASLIB = libblas.so.${version}" + ''; + + buildPhase = '' + make + echo >>make.inc "ARFLAGS = " + echo >>make.inc "BLASLIB = libblas.a" + echo >>make.inc "AR = ar rcs" + echo >>make.inc "RANLIB = ranlib" + make + ''; + + installPhase = + # FreeBSD's stdenv doesn't use Coreutils. + let dashD = if stdenv.isFreeBSD then "" else "-D"; in + (lib.optionalString stdenv.isFreeBSD "mkdir -p $out/lib ;") + + '' + install ${dashD} -m755 libblas.a "$out/lib/libblas.a" + install ${dashD} -m755 libblas.so.${version} "$out/lib/libblas.so.${version}" + ln -s libblas.so.${version} "$out/lib/libblas.so.3" + ln -s libblas.so.${version} "$out/lib/libblas.so" + # Write pkg-config alias. + # See also openblas/default.nix + mkdir $out/lib/pkgconfig + cat <<EOF > $out/lib/pkgconfig/blas.pc +Name: blas +Version: ${version} +Description: blas provided by the BLAS package. +Libs: -L$out/lib -lblas +EOF + ''; + + preFixup = lib.optionalString stdenv.isDarwin '' + for fn in $(find $out/lib -name "*.so*"); do + if [ -L "$fn" ]; then continue; fi + install_name_tool -id "$fn" "$fn" + done + ''; + + meta = { + description = "Basic Linear Algebra Subprograms"; + license = lib.licenses.publicDomain; + homepage = "http://www.netlib.org/blas/"; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix new file mode 100644 index 000000000000..847d8429c92f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/blis/default.nix @@ -0,0 +1,64 @@ +{ lib, stdenv +, fetchFromGitHub +, perl +, python3 + +# Enable BLAS interface with 64-bit integer width. +, blas64 ? false + +# Target architecture. x86_64 builds Intel and AMD kernels. +, withArchitecture ? "x86_64" + +# Enable OpenMP-based threading. +, withOpenMP ? true +}: + +let + blasIntSize = if blas64 then "64" else "32"; +in stdenv.mkDerivation rec { + pname = "blis"; + version = "0.8.1"; + + src = fetchFromGitHub { + owner = "flame"; + repo = "blis"; + rev = version; + sha256 = "sha256-D5T/itq9zyD5TkeJ4Ae1vS4yEWU51omyJoIkKQ2NLhY="; + }; + + inherit blas64; + + nativeBuildInputs = [ + perl + python3 + ]; + + doCheck = true; + + enableParallelBuilding = true; + + configureFlags = [ + "--enable-cblas" + "--blas-int-size=${blasIntSize}" + ] ++ lib.optionals withOpenMP [ "--enable-threading=openmp" ] + ++ [ withArchitecture ]; + + postPatch = '' + patchShebangs configure build/flatten-headers.py + ''; + + postInstall = '' + ln -s $out/lib/libblis.so.3 $out/lib/libblas.so.3 + ln -s $out/lib/libblis.so.3 $out/lib/libcblas.so.3 + ln -s $out/lib/libblas.so.3 $out/lib/libblas.so + ln -s $out/lib/libcblas.so.3 $out/lib/libcblas.so + ''; + + meta = with lib; { + description = "BLAS-compatible linear algebra library"; + homepage = "https://github.com/flame/blis"; + license = licenses.bsd3; + maintainers = [ ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix new file mode 100644 index 000000000000..870568c9ac95 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/brial/default.nix @@ -0,0 +1,46 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +, pkg-config +, boost +, m4ri +, gd +}: + +stdenv.mkDerivation rec { + version = "1.2.10"; + pname = "brial"; + + src = fetchFromGitHub { + owner = "BRiAl"; + repo = "BRiAl"; + rev = version; + sha256 = "1qg6ssp87rb8p37kahxmm88fbxqg6r540cky5v7wq7l19n2b1bss"; + }; + + # FIXME package boost-test and enable checks + doCheck = false; + + configureFlags = [ + "--with-boost-unit-test-framework=no" + ]; + + buildInputs = [ + boost + m4ri + gd + ]; + + nativeBuildInputs = [ + autoreconfHook + pkg-config + ]; + + meta = with lib; { + homepage = "https://github.com/BRiAl/BRiAl"; + description = "Legacy version of PolyBoRi maintained by sagemath developers"; + license = licenses.gpl2Plus; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix b/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix new file mode 100644 index 000000000000..202903b9aa18 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/default.nix @@ -0,0 +1,147 @@ +{ stdenv, lib, config, fetchFromGitHub +, cmake +, glog, gflags, gtest +, protobuf, snappy +, python, future, six, python-protobuf, numpy, pydot +, eigen +, doxygen +, useCuda ? (config.cudaSupport or false), cudatoolkit ? null +, useCudnn ? (config.cudnnSupport or false), cudnn ? null +, useOpenmp ? false, openmp ? null +, useOpencv3 ? true, opencv3 ? null +, useLeveldb ? false, leveldb ? null +, useLmdb ? true, lmdb ? null +, useRocksdb ? false, rocksdb ? null +, useZeromq ? false, zeromq ? null +, useMpi ? false, mpi ? null +# TODO: distributed computations +#, useGloo ? false +#, useNccl ? false +#, useNnpack ? false +}: + +assert useCuda -> cudatoolkit != null; +assert useCudnn -> (useCuda && cudnn != null); +assert useOpencv3 -> opencv3 != null; +assert useLeveldb -> leveldb != null; +assert useLmdb -> lmdb != null; +assert useRocksdb -> rocksdb != null; +assert useZeromq -> zeromq != null; +assert useMpi -> mpi != null; + +let + # Third party modules that caffe2 holds as git submodules. + # Download them and create symlinks from caffe2/third_party. + installExtraSrc = extra: '' + rmdir "third_party/${extra.dst}" + ln -s "${extra.src}" "third_party/${extra.dst}" + ''; + + cub = { + src = fetchFromGitHub { + owner = "NVlabs"; + repo = "cub"; + rev = "v1.7.4"; + sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66"; + }; + dst = "cub"; + }; + + pybind11 = { + src = fetchFromGitHub { + owner = "pybind"; + repo = "pybind11"; + rev = "86e2ad4f77442c3350f9a2476650da6bee253c52"; + sha256 = "05gi58dirvc8fgm0avpydvidzsbh2zrzgfaq671ym09f6dz0bcgz"; + }; + dst = "pybind11"; + }; + + ccVersion = lib.getVersion stdenv.cc; +in + +stdenv.mkDerivation rec { + pname = "caffe2"; + version = "0.8.1"; + src = fetchFromGitHub { + owner = "caffe2"; + repo = "caffe2"; + rev = "v${version}"; + sha256 = "18y7zjc69j6n5642l9caddl641b0djf3pjn4wacdsc1wk1jiyqk8"; + }; + + nativeBuildInputs = [ cmake doxygen gtest ]; + outputs = [ "bin" "out" ]; + propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle + + buildInputs = [ glog gflags protobuf snappy eigen ] + ++ lib.optional useCuda cudatoolkit + ++ lib.optional useCudnn cudnn + ++ lib.optional useOpenmp openmp + ++ lib.optional useOpencv3 opencv3 + ++ lib.optional useLeveldb leveldb + ++ lib.optional useLmdb lmdb + ++ lib.optional useRocksdb rocksdb + ++ lib.optional useZeromq zeromq + ; + propagatedBuildInputs = [ numpy future six python-protobuf pydot ]; + + patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [ + ./fix_compilation_on_gcc7.patch + ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ]; + + cmakeFlags = [ "-DBUILD_TEST=OFF" + "-DBUILD_PYTHON=ON" + ''-DUSE_CUDA=${if useCuda then "ON"else "OFF"}'' + ''-DUSE_OPENMP=${if useOpenmp then "ON"else "OFF"}'' + ''-DUSE_OPENCV=${if useOpencv3 then "ON"else "OFF"}'' + ''-DUSE_MPI=${if useMpi then "ON"else "OFF"}'' + ''-DUSE_LEVELDB=${if useLeveldb then "ON"else "OFF"}'' + ''-DUSE_LMDB=${if useLmdb then "ON"else "OFF"}'' + ''-DUSE_ROCKSDB=${if useRocksdb then "ON"else "OFF"}'' + ''-DUSE_ZMQ=${if useZeromq then "ON"else "OFF"}'' + "-DUSE_GLOO=OFF" + "-DUSE_NNPACK=OFF" + "-DUSE_NCCL=OFF" + "-DUSE_REDIS=OFF" + "-DUSE_FFMPEG=OFF" + ] + ++ lib.optional useCuda [ + "-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit}" + "-DCUDA_FAST_MATH=ON" + "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc" + ]; + + preConfigure = '' + ${installExtraSrc cub} + ${installExtraSrc pybind11} + # XXX hack + export NIX_CFLAGS_COMPILE="-I ${eigen}/include/eigen3/ $NIX_CFLAGS_COMPILE" + ''; + + postInstall = '' + moveToOutput "bin" "$bin" + mkdir -p $out/lib/${python.libPrefix} + ln -s $out/ $out/${python.sitePackages} + ''; + + doCheck = false; + + meta = { + homepage = "https://caffe2.ai/"; + description = "A new lightweight, modular, and scalable deep learning framework"; + longDescription = '' + Caffe2 aims to provide an easy and straightforward way for you to experiment + with deep learning and leverage community contributions of new models and + algorithms. You can bring your creations to scale using the power of GPUs in the + cloud or to the masses on mobile with Caffe2's cross-platform libraries. + ''; + platforms = with lib.platforms; linux; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ yuriaisaka ]; + # fails to compile with + # error: invalid conversion from 'const char*' to 'char*' + # TODO: Remove usage of python2, protobuf overwrite + broken = true; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch b/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch new file mode 100644 index 000000000000..f319f20233a2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/fix_compilation_on_gcc7.patch @@ -0,0 +1,46 @@ +diff --git a/caffe2/operators/recurrent_network_op.cc b/caffe2/operators/recurrent_network_op.cc +index dd4fded..5995e8a 100644 +--- a/caffe2/operators/recurrent_network_op.cc ++++ b/caffe2/operators/recurrent_network_op.cc +@@ -1,4 +1,4 @@ +-#include "recurrent_network_op.h" ++#include "caffe2/operators/recurrent_network_op.h" + #include "caffe2/core/workspace.h" + + namespace caffe2 { +diff --git a/caffe2/operators/recurrent_network_op.h b/caffe2/operators/recurrent_network_op.h +index 55328e5..ea898bc 100644 +--- a/caffe2/operators/recurrent_network_op.h ++++ b/caffe2/operators/recurrent_network_op.h +@@ -762,8 +762,8 @@ class AccumulateInputGradientOp : public Operator<Context> { + USE_OPERATOR_CONTEXT_FUNCTIONS; + + bool RunOnDevice() override { +- const auto t = +- OperatorBase::Input<Tensor<CPUContext>>(0).template data<int32_t>()[0]; ++ const auto& t0 = OperatorBase::Input<Tensor<CPUContext>>(0); ++ const auto t = t0.template data<int32_t>()[0]; + auto& og = Input(1); + auto* g = Output(0); + +diff --git a/caffe2/queue/queue_ops.h b/caffe2/queue/queue_ops.h +index f2c0a33..642343f 100644 +--- a/caffe2/queue/queue_ops.h ++++ b/caffe2/queue/queue_ops.h +@@ -17,13 +17,10 @@ class CreateBlobsQueueOp final : public Operator<Context> { + name(operator_def.output().Get(0)) {} + + bool RunOnDevice() override { +- const auto capacity = +- OperatorBase::template GetSingleArgument<int>("capacity", 1); +- const auto numBlobs = +- OperatorBase::template GetSingleArgument<int>("num_blobs", 1); ++ const auto capacity = GetSingleArgument("capacity", 1); ++ const auto numBlobs = GetSingleArgument("num_blobs", 1); + const auto enforceUniqueName = +- OperatorBase::template GetSingleArgument<int>( +- "enforce_unique_name", false); ++ GetSingleArgument("enforce_unique_name", false); + const auto fieldNames = + OperatorBase::template GetRepeatedArgument<std::string>("field_names"); + CAFFE_ENFORCE_EQ(this->OutputSize(), 1); diff --git a/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch b/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch new file mode 100644 index 000000000000..d908cb6ba80b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/caffe2/update_clang_cvtsh_bugfix.patch @@ -0,0 +1,55 @@ +diff --git a/caffe2/perfkernels/cvtsh_ss_bugfix.h b/caffe2/perfkernels/cvtsh_ss_bugfix.h +index bd06681..00172b7 100644 +--- a/caffe2/perfkernels/cvtsh_ss_bugfix.h ++++ b/caffe2/perfkernels/cvtsh_ss_bugfix.h +@@ -1,10 +1,36 @@ ++/** ++ * Copyright (c) 2016-present, Facebook, Inc. ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ + #pragma once + +-#if defined(__APPLE__) && (__clang_major__ < 8) ++// Apple clang was fixed in 8.1 ++#if defined(__apple_build_version__) && ((__clang_major__ < 8) || ((__clang_major__ == 8) && (__clang_minor__ < 1))) ++#define __APPLE_NEED_FIX 1 ++#endif ++ ++// Regular clang was fixed in 3.9 ++#if defined(__clang__) && (__clang_major__ < 4) && (__clang_minor__ < 9) ++#define __CLANG_NEED_FIX 1 ++#endif ++ ++#if __APPLE_NEED_FIX || __CLANG_NEED_FIX + + #include <emmintrin.h> + +-// This version of apple clang has a bug that _cvtsh_ss is not defined, see ++// This version of clang has a bug that _cvtsh_ss is not defined, see + // https://reviews.llvm.org/D16177 + static __inline float + __attribute__((__always_inline__, __nodebug__, __target__("f16c"))) +@@ -15,7 +41,10 @@ _cvtsh_ss(unsigned short a) + return r[0]; + } + +-#endif // defined(__APPLE__) && (__clang_major__ < 8) ++#endif // __APPLE_NEED_FIX || __CLANG_NEED_FIX ++ ++#undef __APPLE_NEED_FIX ++#undef __CLANG_NEED_FIX + + #ifdef _MSC_VER + diff --git a/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix new file mode 100644 index 000000000000..311ffefcfaad --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cholmod-extra/default.nix @@ -0,0 +1,35 @@ +{ lib, stdenv, fetchFromGitHub, gfortran, suitesparse, blas, lapack }: +stdenv.mkDerivation rec { + pname = "cholmod-extra"; + version = "1.2.0"; + + src = fetchFromGitHub { + repo = pname; + owner = "jluttine"; + rev = version; + sha256 = "0hz1lfp0zaarvl0dv0zgp337hyd8np41kmdpz5rr3fc6yzw7vmkg"; + }; + + nativeBuildInputs = [ gfortran ]; + buildInputs = [ suitesparse blas lapack ]; + + makeFlags = [ + "BLAS=-lcblas" + ]; + + installFlags = [ + "INSTALL_LIB=$(out)/lib" + "INSTALL_INCLUDE=$(out)/include" + ]; + + doCheck = true; + + meta = with lib; { + homepage = "https://github.com/jluttine/cholmod-extra"; + description = "A set of additional routines for SuiteSparse CHOLMOD Module"; + license = with licenses; [ gpl2Plus ]; + maintainers = with maintainers; [ jluttine ]; + platforms = with platforms; unix; + }; + +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix new file mode 100644 index 000000000000..a87d107b3a17 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/default.nix @@ -0,0 +1,68 @@ +{ lib, stdenv +, fetchFromGitHub +, cmake +, gfortran +, blas +, boost +, python3 +, ocl-icd +, opencl-headers +, Accelerate, CoreGraphics, CoreVideo, OpenCL +}: + +stdenv.mkDerivation rec { + pname = "clblas"; + version = "2.12"; + + src = fetchFromGitHub { + owner = "clMathLibraries"; + repo = "clBLAS"; + rev = "v${version}"; + sha256 = "154mz52r5hm0jrp5fqrirzzbki14c1jkacj75flplnykbl36ibjs"; + }; + + patches = [ ./platform.patch ]; + + postPatch = '' + sed -i -re 's/(set\(\s*Boost_USE_STATIC_LIBS\s+).*/\1OFF\ \)/g' src/CMakeLists.txt + ''; + + preConfigure = '' + cd src + ''; + + cmakeFlags = [ + "-DBUILD_TEST=OFF" + ]; + + nativeBuildInputs = [ cmake gfortran ]; + buildInputs = [ + blas + python3 + boost + ] ++ lib.optionals (!stdenv.isDarwin) [ + ocl-icd + opencl-headers + ] ++ lib.optionals stdenv.isDarwin [ + Accelerate + CoreGraphics + CoreVideo + ]; + propagatedBuildInputs = lib.optionals stdenv.isDarwin [ + OpenCL + ]; + + strictDeps = true; + + meta = with lib; { + homepage = "https://github.com/clMathLibraries/clBLAS"; + description = "A software library containing BLAS functions written in OpenCL"; + longDescription = '' + This package contains a library of BLAS functions on top of OpenCL. + ''; + license = licenses.asl20; + maintainers = with maintainers; [ artuuge ]; + platforms = platforms.unix; + }; + +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch new file mode 100644 index 000000000000..87404a426a4b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/clblas/platform.patch @@ -0,0 +1,34 @@ +diff --git a/src/library/tools/ktest/config.cpp b/src/library/tools/ktest/config.cpp +index 8b20128..faf9bde 100644 +--- a/src/library/tools/ktest/config.cpp ++++ b/src/library/tools/ktest/config.cpp +@@ -24,8 +24,6 @@ + + using namespace clMath; + +-static const char DEFAULT_PLATFORM_NAME[] = "AMD Accelerated Parallel Processing"; +- + Config::Config() : + defaultConfig_(""), + cpp_("ktest.cpp"), +@@ -35,7 +33,10 @@ Config::Config() : + hasFuncID_(false), hasSubdims_(false), + skipAccuracy_(false) + { +- setPlatform(DEFAULT_PLATFORM_NAME); ++ platform_ = NULL; ++ setPlatform(""); ++ ++ device_ = NULL; + setDevice(""); + + memset(&kargs_, 0, sizeof(kargs_)); +@@ -262,7 +263,7 @@ Config::setPlatform(const std::string& name) + continue; + } + if (name.empty()) { +- found = (strcmp(pname, DEFAULT_PLATFORM_NAME) == 0); ++ found = true; + } + else { + found = (strcmp(pname, name.c_str()) == 0); diff --git a/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix new file mode 100644 index 000000000000..0d8bafffb44f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cliquer/default.nix @@ -0,0 +1,38 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +}: + +stdenv.mkDerivation rec { + version = "1.22"; + pname = "cliquer"; + + # autotoolized version of the original cliquer + src = fetchFromGitHub { + owner = "dimpase"; + repo = "autocliquer"; + rev = "v${version}"; + sha256 = "00gcmrhi2fjn8b246w5a3b0pl7p6haxy5wjvd9kcqib1xanz59z4"; + }; + + doCheck = true; + + buildInputs = [ + autoreconfHook + ]; + + meta = with lib; { + homepage = "https://users.aalto.fi/~pat/cliquer.html"; + downloadPage = src.meta.homepage; # autocliquer + description = "Routines for clique searching"; + longDescription = '' + Cliquer is a set of C routines for finding cliques in an arbitrary weighted graph. + It uses an exact branch-and-bound algorithm developed by Patric Östergård. + It is designed with the aim of being efficient while still being flexible and + easy to use. + ''; + license = licenses.gpl2Plus; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix new file mode 100644 index 000000000000..3905e70d3401 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/clmagma/default.nix @@ -0,0 +1,75 @@ +{ lib, stdenv, fetchurl, gfortran, opencl-headers, clblas, ocl-icd, mkl, intel-ocl }: + +with lib; + +let + version = "1.3.0"; + incfile = builtins.toFile "make.inc.custom" '' + CC = g++ + FORT = gfortran + + ARCH = ar + ARCHFLAGS = cr + RANLIB = ranlib + + OPTS = -fPIC -O3 -DADD_ -Wall + FOPTS = -fPIC -O3 -DADD_ -Wall -x f95-cpp-input + F77OPTS = -fPIC -O3 -DADD_ -Wall + LDOPTS = -fPIC + + -include make.check-mkl + -include make.check-clblas + + # Gnu mkl is not available I guess? + #LIB = -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -lpthread -lm -fopenmp + LIB = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lm -fopenmp + LIB += -lclBLAS -lOpenCL + + LIBDIR = -L$(MKLROOT)/lib/intel64 \ + -L$(MKLROOT)/../compiler/lib/intel64 \ + -L$(clBLAS)/lib64 + + INC = -I$(clBLAS)/include + #-I$(AMDAPP)/include + ''; +in stdenv.mkDerivation { + name = "clmagma-${version}"; + src = fetchurl { + url = "http://icl.cs.utk.edu/projectsfiles/magma/cl/clmagma-${version}.tar.gz"; + sha256 = "1n27ny0xhwirw2ydn46pfcwy53gzia9zbam4irx44fd4d7f9ydv7"; + name = "clmagma-${version}.tar.gz"; + }; + + buildInputs = [ + gfortran + clblas + opencl-headers + ocl-icd + mkl + intel-ocl + ]; + + enableParallelBuilding=true; + + MKLROOT = "${mkl}"; + clBLAS = "${clblas}"; + + # Otherwise build looks for it in /run/opengl-driver/etc/OpenCL/vendors, + # which is not available. + OPENCL_VENDOR_PATH="${intel-ocl}/etc/OpenCL/vendors"; + + preBuild = '' + # By default it tries to use GPU, and thus fails for CPUs + sed -i "s/CL_DEVICE_TYPE_GPU/CL_DEVICE_TYPE_DEFAULT/" interface_opencl/clmagma_runtime.cpp + sed -i "s%/usr/local/clmagma%/$out%" Makefile.internal + cp ${incfile} make.inc + ''; + + meta = with lib; { + description = "Matrix Algebra on GPU and Multicore Architectures, OpenCL port"; + license = licenses.bsd3; + homepage = "http://icl.cs.utk.edu/magma/index.html"; + platforms = platforms.linux; + maintainers = with maintainers; [ volhovm ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix new file mode 100644 index 000000000000..663d61494c76 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/default.nix @@ -0,0 +1,77 @@ +# The following version combinations are supported: +# * cuDNN 7.4.2, cudatoolkit 10.0 +# * cuDNN 7.6.5, cudatoolkit 10.2 +# * cuDNN 8.1.1, cudatoolkit 11.0-11.2 +# * cuDNN 8.3.0, cudatoolkit 11.0-11.5 +{ callPackage +, cudatoolkit_10_0 +, cudatoolkit_10_2 +, cudatoolkit_11_0 +, cudatoolkit_11_1 +, cudatoolkit_11_2 +, cudatoolkit_11_3 +, cudatoolkit_11_4 +, cudatoolkit_11_5 +}: + +let + generic = args: callPackage (import ./generic.nix (removeAttrs args [ "cudatoolkit" ])) { + inherit (args) cudatoolkit; + }; +in +rec { + # cuDNN 7.x + # Still used by libtensorflow-bin. It should be upgraded at some point. + cudnn_7_4_cudatoolkit_10_0 = generic rec { + version = "7.4.2"; + cudatoolkit = cudatoolkit_10_0; + srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.4.2.24.tgz"; + sha256 = "18ys0apiz9afid2s6lvy9qbyi8g66aimb2a7ikl1f3dm09mciprf"; + }; + + # The `cudnn` alias still points to this in all-packages.nix. It should be + # upgraded at some point. + cudnn_7_6_cudatoolkit_10_2 = generic rec { + version = "7.6.5"; + cudatoolkit = cudatoolkit_10_2; + srcName = "cudnn-${cudatoolkit.majorVersion}-linux-x64-v7.6.5.32.tgz"; + sha256 = "084c13vzjdkb5s1996yilybg6dgav1lscjr1xdcgvlmfrbr6f0k0"; + }; + + cudnn_7_6_cudatoolkit_10 = cudnn_7_6_cudatoolkit_10_2; + + # cuDNN 8.x + # cuDNN 8.1 is still used by tensorflow at the time of writing (2022-02-17). + # See https://github.com/NixOS/nixpkgs/pull/158218 for more info. + cudnn_8_1_cudatoolkit_11_0 = generic rec { + version = "8.1.1"; + cudatoolkit = cudatoolkit_11_0; + # 8.1.0 is compatible with CUDA 11.0-11.2: + # https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-811/support-matrix/index.html + srcName = "cudnn-11.2-linux-x64-v8.1.1.33.tgz"; + hash = "sha256-mKh4TpKGLyABjSDCgbMNSgzZUfk2lPZDPM9K6cUCumo="; + }; + cudnn_8_1_cudatoolkit_11_1 = cudnn_8_1_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_1; }; + cudnn_8_1_cudatoolkit_11_2 = cudnn_8_1_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_2; }; + cudnn_8_1_cudatoolkit_11 = cudnn_8_1_cudatoolkit_11_2; + + # cuDNN 8.3 is necessary for the latest jaxlib, esp. jaxlib-bin. See + # https://github.com/google/jax/discussions/9455 for more info. + cudnn_8_3_cudatoolkit_11_0 = generic rec { + # 8.3.0 is the last version to respect the folder structure that generic.nix + # expects. Later versions have files in a subdirectory `local_installers`. + # See eg https://developer.download.nvidia.com/compute/redist/cudnn/v8.3.1/. + version = "8.3.0"; + cudatoolkit = cudatoolkit_11_0; + # 8.3.0 is compatible with CUDA 11.0-11.5: + # https://docs.nvidia.com/deeplearning/cudnn/archives/cudnn-830/support-matrix/index.html + srcName = "cudnn-11.5-linux-x64-v8.3.0.98.tgz"; + hash = "sha256-RMb1rVyxL7dPoMmh58qvTwTXVa3xGi5bbJ5BfaN2srI="; + }; + cudnn_8_3_cudatoolkit_11_1 = cudnn_8_3_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_1; }; + cudnn_8_3_cudatoolkit_11_2 = cudnn_8_3_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_2; }; + cudnn_8_3_cudatoolkit_11_3 = cudnn_8_3_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_3; }; + cudnn_8_3_cudatoolkit_11_4 = cudnn_8_3_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_4; }; + cudnn_8_3_cudatoolkit_11_5 = cudnn_8_3_cudatoolkit_11_0.override { cudatoolkit = cudatoolkit_11_5; }; + cudnn_8_3_cudatoolkit_11 = cudnn_8_3_cudatoolkit_11_5; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix new file mode 100644 index 000000000000..13fc0b679970 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cudnn/generic.nix @@ -0,0 +1,86 @@ +{ version +, srcName +, hash ? null +, sha256 ? null +}: + +assert (hash != null) || (sha256 != null); + +{ stdenv +, lib +, cudatoolkit +, fetchurl +, addOpenGLRunpath +, # The distributed version of CUDNN includes both dynamically liked .so files, + # as well as statically linked .a files. However, CUDNN is quite large + # (multiple gigabytes), so you can save some space in your nix store by + # removing the statically linked libraries if you are not using them. + # + # Setting this to true removes the statically linked .a files. + # Setting this to false keeps these statically linked .a files. + removeStatic ? false +}: + +stdenv.mkDerivation { + name = "cudatoolkit-${cudatoolkit.majorVersion}-cudnn-${version}"; + + inherit version; + + src = let + hash_ = if hash != null then { inherit hash; } else { inherit sha256; }; + in fetchurl ({ + # URL from NVIDIA docker containers: https://gitlab.com/nvidia/cuda/blob/centos7/7.0/runtime/cudnn4/Dockerfile + url = "https://developer.download.nvidia.com/compute/redist/cudnn/v${version}/${srcName}"; + } // hash_); + + nativeBuildInputs = [ addOpenGLRunpath ]; + + # Some cuDNN libraries depend on things in cudatoolkit, eg. + # libcudnn_ops_infer.so.8 tries to load libcublas.so.11. So we need to patch + # cudatoolkit into RPATH. See also https://github.com/NixOS/nixpkgs/blob/88a2ad974692a5c3638fcdc2c772e5770f3f7b21/pkgs/development/python-modules/jaxlib/bin.nix#L78-L98. + installPhase = '' + runHook preInstall + + function fixRunPath { + p=$(patchelf --print-rpath $1) + patchelf --set-rpath "''${p:+$p:}${lib.makeLibraryPath [ stdenv.cc.cc cudatoolkit.lib ]}:${cudatoolkit}/lib:\$ORIGIN/" $1 + } + + for lib in lib64/lib*.so; do + fixRunPath $lib + done + + mkdir -p $out + cp -a include $out/include + cp -a lib64 $out/lib64 + '' + lib.optionalString removeStatic '' + rm -f $out/lib64/*.a + '' + '' + runHook postInstall + ''; + + # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + postFixup = '' + for lib in $out/lib/lib*.so; do + addOpenGLRunpath $lib + done + ''; + + propagatedBuildInputs = [ + cudatoolkit + ]; + + passthru = { + inherit cudatoolkit; + majorVersion = lib.versions.major version; + }; + + meta = with lib; { + description = "NVIDIA CUDA Deep Neural Network library (cuDNN)"; + homepage = "https://developer.nvidia.com/cudnn"; + license = licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ mdaiter ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/cutensor/default.nix b/nixpkgs/pkgs/development/libraries/science/math/cutensor/default.nix new file mode 100644 index 000000000000..25633ca63e6b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cutensor/default.nix @@ -0,0 +1,49 @@ +{ callPackage +, cudatoolkit_10_1, cudatoolkit_10_2 +, cudatoolkit_11_0, cudatoolkit_11_1, cudatoolkit_11_2, cudatoolkit_11_3, cudatoolkit_11_4 +}: + +rec { + cutensor_cudatoolkit_10_1 = callPackage ./generic.nix rec { + version = "1.2.2.5"; + libPath = "lib/10.1"; + cudatoolkit = cudatoolkit_10_1; + # 1.2.2 is compatible with CUDA 11.0, 11.1, and 11.2: + # ephemeral doc at https://developer.nvidia.com/cutensor/downloads + sha256 = "1dl9bd71frhac9cb8lvnh71zfsnqxbxbfhndvva2zf6nh0my4klm"; + }; + + cutensor_cudatoolkit_10_2 = cutensor_cudatoolkit_10_1.override { + version = "1.3.1.3"; + libPath = "lib/10.2"; + cudatoolkit = cudatoolkit_10_2; + # 1.3.1 is compatible with CUDA 11.0, 11.1, and 11.2: + # ephemeral doc at https://developer.nvidia.com/cutensor/downloads + sha256 = "sha256-mNlVnabB2IC3HnYY0mb06RLqQzDxN9ePGVeBy3hkBC8="; + }; + + cutensor_cudatoolkit_10 = cutensor_cudatoolkit_10_2; + + cutensor_cudatoolkit_11_0 = cutensor_cudatoolkit_10_2.override { + libPath = "lib/11"; + cudatoolkit = cudatoolkit_11_0; + }; + + cutensor_cudatoolkit_11_1 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_1; + }; + + cutensor_cudatoolkit_11_2 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_2; + }; + + cutensor_cudatoolkit_11_3 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_3; + }; + + cutensor_cudatoolkit_11_4 = cutensor_cudatoolkit_11_0.override { + cudatoolkit = cudatoolkit_11_4; + }; + + cutensor_cudatoolkit_11 = cutensor_cudatoolkit_11_4; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/cutensor/generic.nix b/nixpkgs/pkgs/development/libraries/science/math/cutensor/generic.nix new file mode 100644 index 000000000000..0b2bd31b2c30 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/cutensor/generic.nix @@ -0,0 +1,69 @@ +{ stdenv +, lib +, libPath +, cudatoolkit +, fetchurl +, autoPatchelfHook +, addOpenGLRunpath + +, version +, sha256 +}: + +let + mostOfVersion = builtins.concatStringsSep "." + (lib.take 3 (lib.versions.splitVersion version)); +in + +stdenv.mkDerivation { + pname = "cudatoolkit-${cudatoolkit.majorVersion}-cutensor"; + inherit version; + + src = fetchurl { + url = "https://developer.download.nvidia.com/compute/cutensor/${mostOfVersion}/local_installers/libcutensor-${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}-${version}.tar.gz"; + inherit sha256; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ + autoPatchelfHook + addOpenGLRunpath + ]; + + buildInputs = [ + stdenv.cc.cc.lib + ]; + + propagatedBuildInputs = [ + cudatoolkit + ]; + + # Set RUNPATH so that libcuda in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + installPhase = '' + mkdir -p "$out" "$dev" + mv include "$dev" + mv ${libPath} "$out/lib" + + function finalRPathFixups { + for lib in $out/lib/lib*.so; do + addOpenGLRunpath $lib + done + } + postFixupHooks+=(finalRPathFixups) + ''; + + passthru = { + inherit cudatoolkit; + majorVersion = lib.versions.major version; + }; + + meta = with lib; { + description = "cuTENSOR: A High-Performance CUDA Library For Tensor Primitives"; + homepage = "https://developer.nvidia.com/cutensor"; + license = licenses.unfree; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ obsidian-systems-maintenance ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix new file mode 100644 index 000000000000..b60bd1fe76c1 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/ecos/default.nix @@ -0,0 +1,38 @@ +{ lib, stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "ecos"; + version = "2.0.7"; + + src = fetchFromGitHub { + owner = "embotech"; + repo = "ecos"; + rev = version; + sha256 = "1hsndim5kjvcwk5svqa4igawzahj982180xj1d7yd0dbjlgxc7w7"; + }; + + buildPhase = '' + make all shared + ''; + + doCheck = true; + checkPhase = '' + make test + ./runecos + ''; + + installPhase = '' + mkdir -p $out/lib + cp lib*.a lib*.so $out/lib + cp -r include $out/ + ''; + + meta = with lib; { + description = "A lightweight conic solver for second-order cone programming"; + homepage = "https://www.embotech.com/ECOS"; + downloadPage = "https://github.com/embotech/ecos/releases"; + license = licenses.gpl3; + platforms = platforms.all; + maintainers = with maintainers; [ bhipple ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix b/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix new file mode 100644 index 000000000000..2690d544c2c8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/fenics/default.nix @@ -0,0 +1,272 @@ +{ lib, stdenv +, fetchurl +, fetchpatch +, boost +, cmake +, doxygen +, eigen +, mpi4py +, numpy +, pkg-config +, pybind11 +, pytest +, pythonPackages +, six +, sympy +, gtest +, hdf5 +, mpi +, ply +, python +, scotch +, setuptools +, sphinx +, suitesparse +, swig +, zlib +, blas +, lapack +, nixosTests +}: +let + version = "2019.1.0"; + + # TODO: test with newer pytest + pytest = pythonPackages.callPackage + ../../../../python2-modules/pytest { + # hypothesis tests require pytest that causes dependency cycle + hypothesis = pythonPackages.hypothesis.override { + doCheck = false; + }; + }; + + dijitso = pythonPackages.buildPythonPackage { + pname = "dijitso"; + inherit version; + src = fetchurl { + url = "https://bitbucket.org/fenics-project/dijitso/downloads/dijitso-${version}.tar.gz"; + sha256 = "1ncgbr0bn5cvv16f13g722a0ipw6p9y6p4iasxjziwsp8kn5x97a"; + }; + propagatedBuildInputs = [ numpy six ]; + checkInputs = [ pytest ]; + preCheck = '' + export HOME=$PWD + ''; + checkPhase = '' + runHook preCheck + py.test test/ + runHook postCheck + ''; + meta = { + description = "Distributed just-in-time shared library building"; + homepage = "https://fenicsproject.org/"; + platforms = lib.platforms.all; + license = lib.licenses.lgpl3; + }; + }; + + fiat = pythonPackages.buildPythonPackage { + pname = "fiat"; + inherit version; + src = fetchurl { + url = "https://bitbucket.org/fenics-project/fiat/downloads/fiat-${version}.tar.gz"; + sha256 = "1sbi0fbr7w9g9ajr565g3njxrc3qydqjy3334vmz5xg0rd3106il"; + }; + propagatedBuildInputs = [ numpy six sympy ]; + checkInputs = [ pytest ]; + + preCheck = '' + # Workaround pytest 4.6.3 issue. + # See: https://bitbucket.org/fenics-project/fiat/pull-requests/59 + rm test/unit/test_quadrature.py + rm test/unit/test_reference_element.py + rm test/unit/test_fiat.py + ''; + checkPhase = '' + runHook preCheck + py.test test/unit/ + runHook postCheck + ''; + meta = { + description = "Automatic generation of finite element basis functions"; + homepage = "https://fenicsproject.org/"; + platforms = lib.platforms.all; + license = lib.licenses.lgpl3; + }; + }; + + ufl = pythonPackages.buildPythonPackage { + pname = "ufl"; + inherit version; + src = fetchurl { + url = "https://bitbucket.org/fenics-project/ufl/downloads/ufl-${version}.tar.gz"; + sha256 = "04daxwg4y9c51sdgvwgmlc82nn0fjw7i2vzs15ckdc7dlazmcfi1"; + }; + propagatedBuildInputs = [ numpy six ]; + checkInputs = [ pytest ]; + checkPhase = '' + runHook preCheck + py.test test/ + runHook postCheck + ''; + meta = { + description = "A domain-specific language for finite element variational forms"; + homepage = "https://fenicsproject.org/"; + platforms = lib.platforms.all; + license = lib.licenses.lgpl3; + }; + }; + + ffc = pythonPackages.buildPythonPackage { + pname = "ffc"; + inherit version; + src = fetchurl { + url = "https://bitbucket.org/fenics-project/ffc/downloads/ffc-${version}.tar.gz"; + sha256 = "1zdg6pziss4va74pd7jjl8sc3ya2gmhpypccmyd8p7c66ji23y2g"; + }; + nativeBuildInputs = [ + pybind11 + ]; + propagatedBuildInputs = [ + dijitso + fiat + numpy + six + sympy + ufl + setuptools + ]; + checkInputs = [ pytest ]; + preCheck = '' + export HOME=$PWD + rm test/unit/ufc/finite_element/test_evaluate.py + ''; + checkPhase = '' + runHook preCheck + py.test test/unit/ + runHook postCheck + ''; + meta = { + description = "A compiler for finite element variational forms"; + homepage = "https://fenicsproject.org/"; + platforms = lib.platforms.all; + license = lib.licenses.lgpl3; + }; + }; + dolfin = stdenv.mkDerivation { + pname = "dolfin"; + inherit version; + src = fetchurl { + url = "https://bitbucket.org/fenics-project/dolfin/downloads/dolfin-${version}.tar.gz"; + sha256 = "0kbyi4x5f6j4zpasch0swh0ch81w2h92rqm1nfp3ydi4a93vky33"; + }; + patches = [ + (fetchpatch { + name = "fix-double-prefix.patch"; + url = "https://bitbucket.org/josef_kemetmueller/dolfin/commits/328e94acd426ebaf2243c072b806be3379fd4340/raw"; + sha256 = "1zj7k3y7vsx0hz3gwwlxhq6gdqamqpcw90d4ishwx5ps5ckcsb9r"; + }) + ]; + propagatedBuildInputs = [ + dijitso + fiat + numpy + six + ufl + ]; + nativeBuildInputs = [ + cmake + doxygen + pkg-config + ]; + buildInputs = [ + boost + dijitso + eigen + ffc + fiat + hdf5 + mpi + numpy + blas + lapack + ply + python + scotch + six + sphinx + suitesparse + swig + sympy + ufl + zlib + ]; + cmakeFlags = [ + "-DDOLFIN_CXX_FLAGS=-std=c++11" + "-DDOLFIN_AUTO_DETECT_MPI=ON" + "-DDOLFIN_ENABLE_CHOLMOD=ON" + "-DDOLFIN_ENABLE_DOCS=ON" + "-DDOLFIN_ENABLE_HDF5=ON" + "-DDOLFIN_ENABLE_MPI=ON" + "-DDOLFIN_ENABLE_SCOTCH=ON" + "-DDOLFIN_ENABLE_UMFPACK=ON" + "-DDOLFIN_ENABLE_ZLIB=ON" + "-DDOLFIN_SKIP_BUILD_TESTS=ON" # Otherwise SCOTCH is not found + # TODO: Enable the following features + "-DDOLFIN_ENABLE_PARMETIS=OFF" + "-DDOLFIN_ENABLE_PETSC=OFF" + "-DDOLFIN_ENABLE_SLEPC=OFF" + "-DDOLFIN_ENABLE_TRILINOS=OFF" + ]; + installCheckPhase = '' + source $out/share/dolfin/dolfin.conf + make runtests + ''; + meta = { + description = "The FEniCS Problem Solving Environment in Python and C++"; + homepage = "https://fenicsproject.org/"; + license = lib.licenses.lgpl3; + }; + }; + python-dolfin = pythonPackages.buildPythonPackage rec { + pname = "dolfin"; + inherit version; + disabled = pythonPackages.isPy27; + src = dolfin.src; + sourceRoot = "${pname}-${version}/python"; + nativeBuildInputs = [ + pybind11 + cmake + ]; + dontUseCmakeConfigure = true; + preConfigure = '' + export CMAKE_PREFIX_PATH=${pybind11}/share/cmake/pybind11:$CMAKE_PREFIX_PATH + substituteInPlace setup.py --replace "pybind11==2.2.4" "pybind11" + substituteInPlace dolfin/jit/jit.py \ + --replace 'pkg-config.exists("dolfin")' 'pkg-config.exists("${dolfin}/lib/pkgconfig/dolfin.pc")' \ + --replace 'pkg-config.parse("dolfin")' 'pkg-config.parse("${dolfin}/lib/pkgconfig/dolfin.pc")' + ''; + buildInputs = [ + dolfin + boost + ]; + + propagatedBuildInputs = [ + dijitso + ffc + mpi4py + numpy + ufl + pythonPackages.pkgconfig + pythonPackages.pybind11 + ]; + doCheck = false; # Tries to orte_ess_init and call ssh to localhost + passthru.tests = { inherit (nixosTests) fenics; }; + meta = { + description = "Python bindings for the DOLFIN FEM compiler"; + homepage = "https://fenicsproject.org/"; + platforms = lib.platforms.all; + license = lib.licenses.lgpl3; + }; + }; +in python-dolfin diff --git a/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix new file mode 100644 index 000000000000..c956eae4f710 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/flintqs/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +, gmp +}: + +stdenv.mkDerivation rec { + version = "1.0"; + pname = "flintqs"; + + src = fetchFromGitHub { + owner = "sagemath"; + repo = "FlintQS"; + rev = "v${version}"; + sha256 = "1f0lnayz6j6qgasx8pbq61d2fqam0wwhsmh6h15l4vq58l1vvbwj"; + }; + + preAutoreconf = '' + touch ChangeLog + ''; + + buildInputs = [ + gmp + ]; + + nativeBuildInputs = [ + autoreconfHook + ]; + + doCheck = true; + + meta = with lib; { + homepage = "https://github.com/sagemath/FlintQS"; + description = "Highly optimized multi-polynomial quadratic sieve for integer factorization"; + license = with licenses; [ gpl2 ]; + maintainers = teams.sage.members; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix new file mode 100644 index 000000000000..e0dfef0b7eec --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/ipopt/default.nix @@ -0,0 +1,34 @@ +{ lib, stdenv, fetchurl, unzip, blas, lapack, gfortran }: + +assert (!blas.isILP64) && (!lapack.isILP64); + +stdenv.mkDerivation rec { + pname = "ipopt"; + version = "3.12.13"; + + src = fetchurl { + url = "https://www.coin-or.org/download/source/Ipopt/Ipopt-${version}.zip"; + sha256 = "0kzf05aypx8q5mr3sciclk926ans0yi2d2chjdxxgpi3sza609dx"; + }; + + CXXDEFS = [ "-DHAVE_RAND" "-DHAVE_CSTRING" "-DHAVE_CSTDIO" ]; + + configureFlags = [ + "--with-blas-lib=-lblas" + "--with-lapack-lib=-llapack" + ]; + + nativeBuildInputs = [ unzip gfortran ]; + + buildInputs = [ blas lapack ]; + + enableParallelBuilding = true; + + meta = with lib; { + description = "A software package for large-scale nonlinear optimization"; + homepage = "https://projects.coin-or.org/Ipopt"; + license = licenses.epl10; + platforms = platforms.unix; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix new file mode 100644 index 000000000000..d7a0dcfe06a7 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/itpp/default.nix @@ -0,0 +1,54 @@ +{ lib, stdenv +, fetchurl +, cmake +, gtest +, blas +, fftw +, liblapack +, gfortran +}: + +stdenv.mkDerivation rec { + pname = "it++"; + version = "4.3.1"; + + src = fetchurl { + url = "mirror://sourceforge/itpp/itpp-${version}.tar.bz2"; + sha256 = "0xxqag9wi0lg78xgw7b40rp6wxqp5grqlbs9z0ifvdfzqlhpcwah"; + }; + + nativeBuildInputs = [ cmake gfortran ]; + buildInputs = [ + fftw + liblapack + + # NOTE: OpenBLAS doesn't work here because IT++ doesn't pass aligned + # buffers, which causes segfaults in the optimized kernels :-( + blas + ]; + + cmakeFlags = [ + "-DBLAS_FOUND:BOOL=TRUE" + "-DBLAS_LIBRARIES:STRING=${blas}/lib/libblas.so" + "-DLAPACK_FOUND:BOOL=TRUE" + "-DLAPACK_LIBRARIES:STRING=${liblapack}/lib/liblapack.so" + "-DGTEST_DIR:PATH=${gtest.src}/googletest" + ]; + + doCheck = true; + + checkPhase = '' + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/itpp + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH''${DYLD_LIBRARY_PATH:+:}$PWD/itpp + ./gtests/itpp_gtests + ''; + + meta = with lib; { + description = "IT++ is a C++ library of mathematical, signal processing and communication classes and functions"; + homepage = "http://itpp.sourceforge.net/"; + license = licenses.gpl3; + platforms = platforms.unix; + maintainers = with maintainers; [ andrew-d ]; + broken = stdenv.isDarwin; # never built on Hydra https://hydra.nixos.org/job/nixpkgs/trunk/itpp.x86_64-darwin + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix new file mode 100644 index 000000000000..b1896917658c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/lcalc/default.nix @@ -0,0 +1,41 @@ +{ lib, stdenv +, autoreconfHook +, gengetopt +, pkg-config +, fetchFromGitLab +, pari +}: + +stdenv.mkDerivation rec { + version = "2.0.5"; + pname = "lcalc"; + + src = fetchFromGitLab { + owner = "sagemath"; + repo = pname; + rev = version; + sha256 = "sha256-RxWZ7T0I9zV7jUVnL6jV/PxEoU32KY7Q1UsOL5Lonuc="; + }; + + nativeBuildInputs = [ + autoreconfHook + gengetopt + pkg-config + ]; + + buildInputs = [ + pari + ]; + + configureFlags = [ + "--with-pari" + ]; + + meta = with lib; { + homepage = "https://gitlab.com/sagemath/lcalc"; + description = "A program for calculating with L-functions"; + license = with licenses; [ gpl2 ]; + maintainers = teams.sage.members; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix new file mode 100644 index 000000000000..cc5d3baf3442 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libbraiding/default.nix @@ -0,0 +1,34 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +}: + +stdenv.mkDerivation rec { + version = "1.1"; + pname = "libbraiding"; + + src = fetchFromGitHub { + owner = "miguelmarco"; + repo = "libbraiding"; + rev = version; + sha256 = "1n1j58y9jaiv0ya0y4fpfb3b05wv0h6k2babpnk2zifjw26xr366"; + }; + + nativeBuildInputs = [ + autoreconfHook + ]; + + # no tests included for now (2018-08-05), but can't hurt to activate + doCheck = true; + + meta = with lib; { + homepage = "https://github.com/miguelmarco/libbraiding/"; + description = "C++ library for computations on braid groups"; + longDescription = '' + A library to compute several properties of braids, including centralizer and conjugacy check. + ''; + license = licenses.gpl3; + maintainers = teams.sage.members; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix new file mode 100644 index 000000000000..d0f09290c3c7 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libhomfly/default.nix @@ -0,0 +1,35 @@ +{ lib, stdenv +, fetchFromGitHub +, autoreconfHook +, boehmgc +}: + +stdenv.mkDerivation rec { + version = "1.02r6"; + pname = "libhomfly"; + + src = fetchFromGitHub { + owner = "miguelmarco"; + repo = "libhomfly"; + rev = version; + sha256 = "sha256-s1Hgy6S9+uREKsgjOVQdQfnds6oSLo5UWTrt5DJnY2s="; + }; + + buildInputs = [ + boehmgc + ]; + + nativeBuildInputs = [ + autoreconfHook + ]; + + doCheck = true; + + meta = with lib; { + homepage = "https://github.com/miguelmarco/libhomfly/"; + description = "Library to compute the homfly polynomial of knots and links"; + license = licenses.unlicense; + maintainers = teams.sage.members; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix new file mode 100644 index 000000000000..f2a50cb2d3d4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/liblapack/default.nix @@ -0,0 +1,70 @@ +{ lib +, stdenv +, fetchFromGitHub +, fetchpatch +, gfortran +, cmake +, shared ? true +}: + +stdenv.mkDerivation rec { + pname = "liblapack"; + version = "3.10.0"; + + src = fetchFromGitHub { + owner = "Reference-LAPACK"; + repo = "lapack"; + rev = "v${version}"; + sha256 = "sha256-ewYUM+M7jDO5LLnB4joiKkqgXjEDmWbFZbgad8x98gc="; + }; + + patches = [ + (fetchpatch { + name = "CVE-2021-4048.patch"; + url = "https://github.com/Reference-LAPACK/lapack/commit/0631b6beaed60ba118b0b027c0f8d35397bf5df0.patch"; + sha256 = "1bqjw3f6ak9iz97y7ckn0rrfcgrzbn9prgfasl489qpxgzp2kjh8"; + }) + ]; + + nativeBuildInputs = [ gfortran cmake ]; + + # Configure stage fails on aarch64-darwin otherwise, due to either clang 11 or gfortran 10. + hardeningDisable = lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ "stackprotector" ]; + + cmakeFlags = [ + "-DCMAKE_Fortran_FLAGS=-fPIC" + "-DLAPACKE=ON" + "-DCBLAS=ON" + "-DBUILD_TESTING=ON" + ] ++ lib.optional shared "-DBUILD_SHARED_LIBS=ON"; + + doCheck = true; + + # Some CBLAS related tests fail on Darwin: + # 14 - CBLAS-xscblat2 (Failed) + # 15 - CBLAS-xscblat3 (Failed) + # 17 - CBLAS-xdcblat2 (Failed) + # 18 - CBLAS-xdcblat3 (Failed) + # 20 - CBLAS-xccblat2 (Failed) + # 21 - CBLAS-xccblat3 (Failed) + # 23 - CBLAS-xzcblat2 (Failed) + # 24 - CBLAS-xzcblat3 (Failed) + # + # Upstream issue to track: + # * https://github.com/Reference-LAPACK/lapack/issues/440 + ctestArgs = lib.optionalString stdenv.isDarwin "-E '^(CBLAS-(x[sdcz]cblat[23]))$'"; + + checkPhase = '' + runHook preCheck + ctest ${ctestArgs} + runHook postCheck + ''; + + meta = with lib; { + description = "Linear Algebra PACKage"; + homepage = "http://www.netlib.org/lapack/"; + maintainers = with maintainers; [ ]; + license = licenses.bsd3; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix new file mode 100644 index 000000000000..3c194648c2a3 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/liblbfgs/default.nix @@ -0,0 +1,18 @@ +{ lib, stdenv, fetchurl }: +stdenv.mkDerivation rec { + pname = "liblbfgs"; + version = "1.10"; + + configureFlags = [ "--enable-sse2" ]; + src = fetchurl { + url = "https://github.com/downloads/chokkan/liblbfgs/liblbfgs-${version}.tar.gz"; + sha256 = "1kv8d289rbz38wrpswx5dkhr2yh4fg4h6sszkp3fawxm09sann21"; + }; + + meta = { + description = "Library of Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS)"; + homepage = "http://www.chokkan.org/software/liblbfgs/"; + license = lib.licenses.mit; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix new file mode 100644 index 000000000000..b00de428c8d4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix @@ -0,0 +1,103 @@ +{ callPackage +, stdenv +, fetchzip +, lib +, libcxx + +, addOpenGLRunpath +, patchelf +, fixDarwinDylibNames + +, cudaSupport +}: + +let + # The binary libtorch distribution statically links the CUDA + # toolkit. This means that we do not need to provide CUDA to + # this derivation. However, we should ensure on version bumps + # that the CUDA toolkit for `passthru.tests` is still + # up-to-date. + version = "1.10.0"; + device = if cudaSupport then "cuda" else "cpu"; + srcs = import ./binary-hashes.nix version; + unavailable = throw "libtorch is not available for this platform"; + libcxx-for-libtorch = if stdenv.hostPlatform.system == "x86_64-darwin" then libcxx else stdenv.cc.cc.lib; +in stdenv.mkDerivation { + inherit version; + pname = "libtorch"; + + src = fetchzip srcs."${stdenv.targetPlatform.system}-${device}" or unavailable; + + nativeBuildInputs = + if stdenv.isDarwin then [ fixDarwinDylibNames ] + else [ patchelf ] ++ lib.optionals cudaSupport [ addOpenGLRunpath ]; + + dontBuild = true; + dontConfigure = true; + dontStrip = true; + + installPhase = '' + # Copy headers and CMake files. + mkdir -p $dev + cp -r include $dev + cp -r share $dev + + install -Dm755 -t $out/lib lib/*${stdenv.hostPlatform.extensions.sharedLibrary}* + + # We do not care about Java support... + rm -f $out/lib/lib*jni* 2> /dev/null || true + + # Fix up library paths for split outputs + substituteInPlace $dev/share/cmake/Torch/TorchConfig.cmake \ + --replace \''${TORCH_INSTALL_PREFIX}/lib "$out/lib" \ + + substituteInPlace \ + $dev/share/cmake/Caffe2/Caffe2Targets-release.cmake \ + --replace \''${_IMPORT_PREFIX}/lib "$out/lib" \ + ''; + + postFixup = let + rpath = lib.makeLibraryPath [ stdenv.cc.cc.lib ]; + in lib.optionalString stdenv.isLinux '' + find $out/lib -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do + echo "setting rpath for $lib..." + patchelf --set-rpath "${rpath}:$out/lib" "$lib" + ${lib.optionalString cudaSupport '' + addOpenGLRunpath "$lib" + ''} + done + '' + lib.optionalString stdenv.isDarwin '' + for f in $out/lib/*.dylib; do + otool -L $f + done + for f in $out/lib/*.dylib; do + install_name_tool -id $out/lib/$(basename $f) $f || true + for rpath in $(otool -L $f | grep rpath | awk '{print $1}');do + install_name_tool -change $rpath $out/lib/$(basename $rpath) $f + done + if otool -L $f | grep /usr/lib/libc++ >& /dev/null; then + install_name_tool -change /usr/lib/libc++.1.dylib ${libcxx-for-libtorch.outPath}/lib/libc++.1.0.dylib $f + fi + done + for f in $out/lib/*.dylib; do + otool -L $f + done + ''; + + outputs = [ "out" "dev" ]; + + passthru.tests.cmake = callPackage ./test { + inherit cudaSupport; + }; + + meta = with lib; { + description = "C++ API of the PyTorch machine learning framework"; + homepage = "https://pytorch.org/"; + # Includes CUDA and Intel MKL, but redistributions of the binary are not limited. + # https://docs.nvidia.com/cuda/eula/index.html + # https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html + license = licenses.bsd3; + maintainers = with maintainers; [ junjihashimoto ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix new file mode 100644 index 000000000000..156515f6eb51 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix @@ -0,0 +1,19 @@ +version : builtins.getAttr version { + "1.10.0" = { + x86_64-darwin-cpu = { + name = "libtorch-macos-1.10.0.zip"; + url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.10.0.zip"; + hash = "sha256-HSisxHs466c6XwvZEbkV/1kVNBzJOy3uVw9Bh497Vk8="; + }; + x86_64-linux-cpu = { + name = "libtorch-cxx11-abi-shared-with-deps-1.10.0-cpu.zip"; + url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.10.0%2Bcpu.zip"; + hash = "sha256-wAtA+AZx3HjaFbsrbyfkSXjYM0BP8H5HwCgyHbgJXJ0="; + }; + x86_64-linux-cuda = { + name = "libtorch-cxx11-abi-shared-with-deps-1.10.0-cu113.zip"; + url = "https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.10.0%2Bcu113.zip"; + hash = "sha256-jPylK4j0V8SEQ8cZU+O22P7kQ28wanIB0GkBzRGyTj8="; + }; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh b/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh new file mode 100755 index 000000000000..26b24198e235 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/prefetch.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p nix-prefetch-scripts + +set -eou pipefail + +version=$1 + +bucket="https://download.pytorch.org/libtorch" +CUDA_VERSION=cu113 + +url_and_key_list=( + "x86_64-darwin-cpu $bucket/cpu/libtorch-macos-${version}.zip libtorch-macos-${version}.zip" + "x86_64-linux-cpu $bucket/cpu/libtorch-cxx11-abi-shared-with-deps-${version}%2Bcpu.zip libtorch-cxx11-abi-shared-with-deps-${version}-cpu.zip" + "x86_64-linux-cuda $bucket/${CUDA_VERSION}/libtorch-cxx11-abi-shared-with-deps-${version}%2B${CUDA_VERSION}.zip libtorch-cxx11-abi-shared-with-deps-${version}-${CUDA_VERSION}.zip" +) + +hashfile="binary-hashes-$version.nix" +echo " \"$version\" = {" >> $hashfile + +for url_and_key in "${url_and_key_list[@]}"; do + key=$(echo "$url_and_key" | cut -d' ' -f1) + url=$(echo "$url_and_key" | cut -d' ' -f2) + name=$(echo "$url_and_key" | cut -d' ' -f3) + + echo "prefetching ${url}..." + hash=$(nix hash to-sri --type sha256 $(nix-prefetch-url --unpack "$url" --name "$name")) + + echo " $key = {" >> $hashfile + echo " name = \"$name\";" >> $hashfile + echo " url = \"$url\";" >> $hashfile + echo " hash = \"$hash\";" >> $hashfile + echo " };" >> $hashfile + + echo +done + +echo " };" >> $hashfile +echo "done." diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt new file mode 100644 index 000000000000..4e96704a4c17 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.0) +find_package(Torch REQUIRED) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") +add_executable(test test.cpp) +target_link_libraries(test "${TORCH_LIBRARIES}") diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix new file mode 100644 index 000000000000..eaea649d4340 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix @@ -0,0 +1,50 @@ +{ lib +, stdenv +, cmake +, libtorch-bin +, linkFarm +, symlinkJoin + +, cudaSupport +, cudatoolkit +, cudnn +}: +let + cudatoolkit_joined = symlinkJoin { + name = "${cudatoolkit.name}-unsplit"; + paths = [ cudatoolkit.out cudatoolkit.lib ]; + }; + + # We do not have access to /run/opengl-driver/lib in the sandbox, + # so use a stub instead. + cudaStub = linkFarm "cuda-stub" [{ + name = "libcuda.so.1"; + path = "${cudatoolkit}/lib/stubs/libcuda.so"; + }]; + +in stdenv.mkDerivation { + pname = "libtorch-test"; + version = libtorch-bin.version; + + src = ./.; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ libtorch-bin ] ++ + lib.optionals cudaSupport [ cudnn ]; + + cmakeFlags = lib.optionals cudaSupport + [ "-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit_joined}" ]; + + doCheck = true; + + installPhase = '' + touch $out + ''; + + checkPhase = lib.optionalString cudaSupport '' + LD_LIBRARY_PATH=${cudaStub}''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \ + '' + '' + ./test + ''; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp new file mode 100644 index 000000000000..ca238fba521d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp @@ -0,0 +1,20 @@ +#undef NDEBUG +#include <cassert> + +#include <iostream> + +#include <torch/torch.h> + +int main() { + torch::Tensor tensor = torch::eye(3); + + float checkData[] = { + 1, 0, 0, + 0, 1, 0, + 0, 0, 1 + }; + + torch::Tensor check = torch::from_blob(checkData, {3, 3}); + + assert(tensor.allclose(check)); +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix new file mode 100644 index 000000000000..063fead11650 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/lrs/default.nix @@ -0,0 +1,25 @@ +{lib, stdenv, fetchurl, gmp}: + +stdenv.mkDerivation rec { + pname = "lrs"; + version = "7.0"; + + src = fetchurl { + url = "http://cgm.cs.mcgill.ca/~avis/C/lrslib/archive/lrslib-070.tar.gz"; + sha256 = "1zjdmkjracz695k73c2pvipc0skpyn1wzagkhilsvcw9pqljpwg9"; + }; + + buildInputs = [ gmp ]; + + preBuild = '' + export makeFlags="$makeFlags prefix=$out"; + ''; + + meta = { + description = "Implementation of the reverse search algorithm for vertex enumeration/convex hull problems"; + license = lib.licenses.gpl2 ; + maintainers = [lib.maintainers.raskin]; + platforms = lib.platforms.linux; + homepage = "http://cgm.cs.mcgill.ca/~avis/C/lrs.html"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix new file mode 100644 index 000000000000..26e26e4ffdbc --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/m4ri/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv +, fetchFromBitbucket +, autoreconfHook +}: + +stdenv.mkDerivation rec { + version = "20200125"; + pname = "m4ri"; + + src = fetchFromBitbucket { + owner = "malb"; + repo = "m4ri"; + rev = "release-${version}"; + sha256 = "1dxgbv6zdyki3h61qlv7003wzhy6x14zmcaz9x19md1i7ng07w1k"; + }; + + doCheck = true; + + nativeBuildInputs = [ + autoreconfHook + ]; + + meta = with lib; { + homepage = "https://malb.bitbucket.io/m4ri/"; + description = "Library to do fast arithmetic with dense matrices over F_2"; + license = licenses.gpl2Plus; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix new file mode 100644 index 000000000000..38a633e58c71 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/m4rie/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv +, fetchFromBitbucket +, autoreconfHook +, m4ri +}: + +stdenv.mkDerivation rec { + version = "20200115"; + pname = "m4rie"; + + src = fetchFromBitbucket { + owner = "malb"; + repo = "m4rie"; + rev = "release-${version}"; + sha256 = "0s8if80x5d6mikbcfsbbxg347136spahp9f3x8i1hflbwl8xj9k8"; + }; + + doCheck = true; + + buildInputs = [ + m4ri + ]; + + nativeBuildInputs = [ + autoreconfHook + ]; + + meta = with lib; { + homepage = "https://malb.bitbucket.io/m4rie/"; + description = "Library for matrix multiplication, reduction and inversion over GF(2^k) for 2 <= k <= 10"; + longDescription = '' + M4RIE is a library for fast arithmetic with dense matrices over small finite fields of even characteristic. + It uses the M4RI library, implementing the same operations over the finite field F2. + ''; + license = licenses.gpl2Plus; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix new file mode 100644 index 000000000000..c5960dddf517 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/magma/default.nix @@ -0,0 +1,89 @@ +{ lib, stdenv, fetchurl, cmake, gfortran, ninja, cudatoolkit, libpthreadstubs, lapack, blas }: + +assert let majorIs = lib.versions.major cudatoolkit.version; + in majorIs == "9" || majorIs == "10" || majorIs == "11"; + +let + version = "2.5.4"; + + # We define a specific set of CUDA compute capabilities here, + # because CUDA 11 does not support compute capability 3.0. Also, + # we use it to enable newer capabilities that are not enabled + # by magma by default. The list of supported architectures + # can be found in magma's top-level CMakeLists.txt. + cudaCapabilities = rec { + cuda9 = [ + "Kepler" # 3.0, 3.5 + "Maxwell" # 5.0 + "Pascal" # 6.0 + "Volta" # 7.0 + ]; + + cuda10 = [ + "Turing" # 7.5 + ] ++ cuda9; + + cuda11 = [ + "sm_35" # sm_30 is not supported by CUDA 11 + "Maxwell" # 5.0 + "Pascal" # 6.0 + "Volta" # 7.0 + "Turing" # 7.5 + "Ampere" # 8.0 + ]; + }; + + capabilityString = lib.strings.concatStringsSep "," + cudaCapabilities."cuda${lib.versions.major cudatoolkit.version}"; + +in stdenv.mkDerivation { + pname = "magma"; + inherit version; + src = fetchurl { + url = "https://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-${version}.tar.gz"; + sha256 = "0rrvd21hczxlm8awc9z54fj7iqpjmsb518fy32s6ghz0g90znd3p"; + name = "magma-${version}.tar.gz"; + }; + + nativeBuildInputs = [ gfortran cmake ninja ]; + + buildInputs = [ cudatoolkit libpthreadstubs lapack blas ]; + + cmakeFlags = [ "-DGPU_TARGET=${capabilityString}" ]; + + doCheck = false; + + preConfigure = '' + export CC=${cudatoolkit.cc}/bin/gcc CXX=${cudatoolkit.cc}/bin/g++ + ''; + + enableParallelBuilding=true; + buildFlags = [ "magma" "magma_sparse" ]; + + # MAGMA's default CMake setup does not care about installation. So we copy files directly. + installPhase = '' + mkdir -p $out + mkdir -p $out/include + mkdir -p $out/lib + mkdir -p $out/lib/pkgconfig + cp -a ../include/*.h $out/include + #cp -a sparse-iter/include/*.h $out/include + cp -a lib/*.so $out/lib + cat ../lib/pkgconfig/magma.pc.in | \ + sed -e s:@INSTALL_PREFIX@:"$out": | \ + sed -e s:@CFLAGS@:"-I$out/include": | \ + sed -e s:@LIBS@:"-L$out/lib -lmagma -lmagma_sparse": | \ + sed -e s:@MAGMA_REQUIRED@:: \ + > $out/lib/pkgconfig/magma.pc + ''; + + meta = with lib; { + description = "Matrix Algebra on GPU and Multicore Architectures"; + license = licenses.bsd3; + homepage = "http://icl.cs.utk.edu/magma/index.html"; + platforms = platforms.unix; + maintainers = with maintainers; [ tbenst ]; + }; + + passthru.cudatoolkit = cudatoolkit; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix new file mode 100644 index 000000000000..41deec25d454 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/metis/default.nix @@ -0,0 +1,21 @@ +{ lib, stdenv, fetchurl, unzip, cmake }: + +stdenv.mkDerivation rec { + pname = "metis"; + version = "5.1.0"; + + src = fetchurl { + url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-${version}.tar.gz"; + sha256 = "1cjxgh41r8k6j029yxs8msp3z6lcnpm16g5pvckk35kc7zhfpykn"; + }; + + cmakeFlags = [ "-DGKLIB_PATH=../GKlib" ]; + nativeBuildInputs = [ unzip cmake ]; + + meta = { + description = "Serial graph partitioning and fill-reducing matrix ordering"; + homepage = "http://glaros.dtc.umn.edu/gkhome/metis/metis/overview"; + license = lib.licenses.asl20; + platforms = lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix new file mode 100644 index 000000000000..1f60f4d95388 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/default.nix @@ -0,0 +1,201 @@ +{ lib +, stdenv +, callPackage +, stdenvNoCC +, fetchurl +, rpmextract +, undmg +, darwin +, validatePkgConfig +, enableStatic ? stdenv.hostPlatform.isStatic +}: + +/* + For details on using mkl as a blas provider for python packages such as numpy, + numexpr, scipy, etc., see the Python section of the NixPkgs manual. +*/ +let + # Release notes and download URLs are here: + # https://registrationcenter.intel.com/en/products/ + version = "${mklVersion}.${rel}"; + + # Darwin is pinned to 2019.3 because the DMG does not unpack; see here for details: + # https://github.com/matthewbauer/undmg/issues/4 + mklVersion = if stdenvNoCC.isDarwin then "2019.3" else "2021.1.1"; + rel = if stdenvNoCC.isDarwin then "199" else "52"; + + # Intel openmp uses its own versioning. + openmpVersion = if stdenvNoCC.isDarwin then "19.0.3" else "19.1.3"; + openmpRel = "189"; + + # Thread Building Blocks release. + tbbRel = "119"; + + shlibExt = stdenvNoCC.hostPlatform.extensions.sharedLibrary; + + oneapi-mkl = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm"; + hash = "sha256-G2Y7iX3UN2YUJhxcMM2KmhONf0ls9owpGlOo8hHOfqA="; + }; + + oneapi-mkl-common = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-${mklVersion}-${mklVersion}-${rel}.noarch.rpm"; + hash = "sha256-HrMt2OcPIRxM8EL8SPjYTyuHJnC7RhPFUrvLhRH+7vc="; + }; + + oneapi-mkl-common-devel = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-common-devel-${mklVersion}-${mklVersion}-${rel}.noarch.rpm"; + hash = "sha256-XDE2WFJzEcpujFmO2AvqQdipZMvKB6/G+ksBe2sE438="; + }; + + oneapi-mkl-devel = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-mkl-devel-${mklVersion}-${mklVersion}-${rel}.x86_64.rpm"; + hash = "sha256-GhUJZ0Vr/ZXp10maie29/5ryU7zzX3F++wRCuuFcE0s="; + }; + + oneapi-openmp = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-openmp-${mklVersion}-${mklVersion}-${openmpRel}.x86_64.rpm"; + hash = "sha256-yP2c4aQAFNRffjLoIZgWXLcNXbiez8smsgu2wXitefU="; + }; + + oneapi-tbb = fetchurl { + url = "https://yum.repos.intel.com/oneapi/intel-oneapi-tbb-${mklVersion}-${mklVersion}-${tbbRel}.x86_64.rpm"; + hash = "sha256-K1BvhGoGVU2Zwy5vg2ZvJWBrSdh5uQwo0znt5039X0A="; + }; + +in stdenvNoCC.mkDerivation ({ + pname = "mkl"; + inherit version; + + dontUnpack = stdenvNoCC.isLinux; + + nativeBuildInputs = [ validatePkgConfig ] ++ (if stdenvNoCC.isDarwin + then + [ undmg darwin.cctools ] + else + [ rpmextract ]); + + buildPhase = if stdenvNoCC.isDarwin then '' + for f in Contents/Resources/pkg/*.tgz; do + tar xzvf $f + done + '' else '' + rpmextract ${oneapi-mkl} + rpmextract ${oneapi-mkl-common} + rpmextract ${oneapi-mkl-common-devel} + rpmextract ${oneapi-mkl-devel} + rpmextract ${oneapi-openmp} + rpmextract ${oneapi-tbb} + ''; + + installPhase = if stdenvNoCC.isDarwin then '' + for f in $(find . -name 'mkl*.pc') ; do + bn=$(basename $f) + substituteInPlace $f \ + --replace "prefix=<INSTALLDIR>/mkl" "prefix=$out" \ + --replace $\{MKLROOT} "$out" \ + --replace "lib/intel64_lin" "lib" \ + --replace "lib/intel64" "lib" + done + for f in $(find opt/intel -name 'mkl*iomp.pc') ; do + substituteInPlace $f \ + --replace "../compiler/lib" "lib" + done + + mkdir -p $out/lib + + cp -r compilers_and_libraries_${version}/mac/mkl/include $out/ + + cp -r compilers_and_libraries_${version}/licensing/mkl/en/license.txt $out/lib/ + cp -r compilers_and_libraries_${version}/mac/compiler/lib/* $out/lib/ + cp -r compilers_and_libraries_${version}/mac/mkl/lib/* $out/lib/ + cp -r compilers_and_libraries_${version}/mac/tbb/lib/* $out/lib/ + + mkdir -p $out/lib/pkgconfig + cp -r compilers_and_libraries_${version}/mac/mkl/bin/pkgconfig/* $out/lib/pkgconfig + '' else '' + for f in $(find . -name 'mkl*.pc') ; do + bn=$(basename $f) + substituteInPlace $f \ + --replace $\{MKLROOT} "$out" \ + --replace "lib/intel64" "lib" + + sed -r -i "s|^prefix=.*|prefix=$out|g" $f + done + + for f in $(find opt/intel -name 'mkl*iomp.pc') ; do + substituteInPlace $f --replace "../compiler/lib" "lib" + done + + # License + install -Dm0655 -t $out/share/doc/mkl opt/intel/oneapi/mkl/2021.1.1/licensing/en/license.txt + + # Dynamic libraries + install -Dm0755 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so* + install -Dm0755 -t $out/lib opt/intel/oneapi/compiler/2021.1.1/linux/compiler/lib/intel64_lin/*.so* + install -Dm0755 -t $out/lib opt/intel/oneapi/tbb/2021.1.1/lib/intel64/gcc4.8/*.so* + + # Headers + cp -r opt/intel/oneapi/mkl/${mklVersion}/include $out/ + '' + + (if enableStatic then '' + install -Dm0644 -t $out/lib opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.a + install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*.pc + '' else '' + cp opt/intel/oneapi/mkl/${mklVersion}/lib/intel64/*.so* $out/lib + install -Dm0644 -t $out/lib/pkgconfig opt/intel/oneapi/mkl/2021.1.1/tools/pkgconfig/*dynamic*.pc + '') + '' + # Setup symlinks for blas / lapack + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt} + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt} + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt} + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt} + '' + lib.optionalString stdenvNoCC.hostPlatform.isLinux '' + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libblas${shlibExt}".3" + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/libcblas${shlibExt}".3" + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapack${shlibExt}".3" + ln -s $out/lib/libmkl_rt${shlibExt} $out/lib/liblapacke${shlibExt}".3" + ''; + + # fixDarwinDylibName fails for libmkl_cdft_core.dylib because the + # larger updated load commands do not fit. Use install_name_tool + # explicitly and ignore the error. + postFixup = lib.optionalString stdenvNoCC.isDarwin '' + for f in $out/lib/*.dylib; do + install_name_tool -id $out/lib/$(basename $f) $f || true + done + install_name_tool -change @rpath/libiomp5.dylib $out/lib/libiomp5.dylib $out/lib/libmkl_intel_thread.dylib + install_name_tool -change @rpath/libtbb.dylib $out/lib/libtbb.dylib $out/lib/libmkl_tbb_thread.dylib + install_name_tool -change @rpath/libtbbmalloc.dylib $out/lib/libtbbmalloc.dylib $out/lib/libtbbmalloc_proxy.dylib + ''; + + # Per license agreement, do not modify the binary + dontStrip = true; + dontPatchELF = true; + + passthru.tests = { + pkg-config-dynamic-iomp = callPackage ./test { enableStatic = false; execution = "iomp"; }; + pkg-config-static-iomp = callPackage ./test { enableStatic = true; execution = "iomp"; }; + pkg-config-dynamic-seq = callPackage ./test { enableStatic = false; execution = "seq"; }; + pkg-config-static-seq = callPackage ./test { enableStatic = true; execution = "seq"; }; + }; + + meta = with lib; { + description = "Intel OneAPI Math Kernel Library"; + longDescription = '' + Intel OneAPI Math Kernel Library (Intel oneMKL) optimizes code with minimal + effort for future generations of Intel processors. It is compatible with your + choice of compilers, languages, operating systems, and linking and + threading models. + ''; + homepage = "https://software.intel.com/en-us/mkl"; + license = licenses.issl; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + maintainers = with maintainers; [ bhipple ]; + }; +} // lib.optionalAttrs stdenvNoCC.isDarwin { + src = fetchurl { + url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/tec/15235/m_mkl_${version}.dmg"; + sha256 = "14b3ciz7995sqcd6jz7hc8g2x4zwvqxmgxgni46vrlb7n523l62f"; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix new file mode 100644 index 000000000000..cb3355260d12 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/default.nix @@ -0,0 +1,41 @@ +{ stdenv +, pkg-config +, mkl + +, enableStatic ? false +, execution ? "seq" +}: + +let + linkType = if enableStatic then "static" else "dynamic"; +in stdenv.mkDerivation { + pname = "mkl-test"; + version = mkl.version; + + src = ./.; + + nativeBuildInputs = [ pkg-config ]; + + buildInputs = [ (mkl.override { inherit enableStatic; }) ]; + + doCheck = true; + + buildPhase = '' + # Check regular Nix build. + gcc test.c -o test $(pkg-config --cflags --libs mkl-${linkType}-ilp64-${execution}) + + # Clear flags to ensure that we are purely relying on options + # provided by pkg-config. + NIX_CFLAGS_COMPILE="" \ + NIX_LDFLAGS="" \ + gcc test.c -o test $(pkg-config --cflags --libs mkl-${linkType}-ilp64-${execution}) + ''; + + installPhase = '' + touch $out + ''; + + checkPhase = '' + ./test + ''; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c new file mode 100644 index 000000000000..9413ac0c68e9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/mkl/test/test.c @@ -0,0 +1,12 @@ +#include <assert.h> + +#include <mkl_cblas.h> + +int main() { + float u[] = {1., 2., 3.}; + float v[] = {4., 5., 6.}; + + float dp = cblas_sdot(3, u, 1, v, 1); + + assert(dp == 32.); +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix b/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix new file mode 100644 index 000000000000..7dd52f3b663d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/mongoose/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "mongoose"; + version = "2.0.4"; + + outputs = [ "bin" "out" "dev" ]; + + src = fetchFromGitHub { + owner = "ScottKolo"; + repo = "Mongoose"; + rev = "v${version}"; + sha256 = "0ymwd4n8p8s0ndh1vcbmjcsm0x2cc2b7v3baww5y6as12873bcrh"; + }; + + nativeBuildInputs = [ + cmake + ]; + + meta = with lib; { + description = "Graph Coarsening and Partitioning Library"; + homepage = "https://github.com/ScottKolo/Mongoose"; + license = licenses.gpl3; + maintainers = with maintainers; []; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix new file mode 100644 index 000000000000..5036ad890799 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/nccl/default.nix @@ -0,0 +1,48 @@ +{ lib, stdenv, fetchFromGitHub, which, cudatoolkit, addOpenGLRunpath }: + +stdenv.mkDerivation rec { + name = "nccl-${version}-cuda-${cudatoolkit.majorVersion}"; + version = "2.7.8-1"; + + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "nccl"; + rev = "v${version}"; + sha256 = "0xxiwaw239dc9g015fka3k1nvm5zyl00dzgxnwzkang61dys9wln"; + }; + + outputs = [ "out" "dev" ]; + + nativeBuildInputs = [ which addOpenGLRunpath ]; + + buildInputs = [ cudatoolkit ]; + + preConfigure = '' + patchShebangs src/collectives/device/gen_rules.sh + ''; + + makeFlags = [ + "CUDA_HOME=${cudatoolkit}" + "PREFIX=$(out)" + ]; + + postFixup = '' + moveToOutput lib/libnccl_static.a $dev + + # Set RUNPATH so that libnvidia-ml in /run/opengl-driver(-32)/lib can be found. + # See the explanation in addOpenGLRunpath. + addOpenGLRunpath $out/lib/lib*.so + ''; + + NIX_CFLAGS_COMPILE = [ "-Wno-unused-function" ]; + + enableParallelBuilding = true; + + meta = with lib; { + description = "Multi-GPU and multi-node collective communication primitives for NVIDIA GPUs"; + homepage = "https://developer.nvidia.com/nccl"; + license = licenses.bsd3; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ mdaiter orivej ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix new file mode 100644 index 000000000000..d61b6ee3acb0 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/openblas/default.nix @@ -0,0 +1,235 @@ +{ lib, stdenv, fetchFromGitHub, perl, which +# Most packages depending on openblas expect integer width to match +# pointer width, but some expect to use 32-bit integers always +# (for compatibility with reference BLAS). +, blas64 ? null +# Multi-threaded applications must not call a threaded OpenBLAS +# (the only exception is when an application uses OpenMP as its +# *only* form of multi-threading). See +# https://github.com/xianyi/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded +# https://github.com/xianyi/OpenBLAS/issues/2543 +# This flag builds a single-threaded OpenBLAS using the flags +# stated in thre. +, singleThreaded ? false +, buildPackages +# Select a specific optimization target (other than the default) +# See https://github.com/xianyi/OpenBLAS/blob/develop/TargetList.txt +, target ? null +# Select whether DYNAMIC_ARCH is enabled or not. +, dynamicArch ? null +# enable AVX512 optimized kernels. +# These kernels have been a source of trouble in the past. +# Use with caution. +, enableAVX512 ? false +, enableStatic ? stdenv.hostPlatform.isStatic +, enableShared ? !stdenv.hostPlatform.isStatic +}: + +with lib; + +let blas64_ = blas64; in + +let + setTarget = x: if target == null then x else target; + setDynamicArch = x: if dynamicArch == null then x else dynamicArch; + + # To add support for a new platform, add an element to this set. + configs = { + armv6l-linux = { + BINARY = 32; + TARGET = setTarget "ARMV6"; + DYNAMIC_ARCH = setDynamicArch false; + USE_OPENMP = true; + }; + + armv7l-linux = { + BINARY = 32; + TARGET = setTarget "ARMV7"; + DYNAMIC_ARCH = setDynamicArch false; + USE_OPENMP = true; + }; + + aarch64-darwin = { + BINARY = 64; + TARGET = setTarget "VORTEX"; + DYNAMIC_ARCH = setDynamicArch true; + USE_OPENMP = false; + MACOSX_DEPLOYMENT_TARGET = "11.0"; + }; + + aarch64-linux = { + BINARY = 64; + TARGET = setTarget "ARMV8"; + DYNAMIC_ARCH = setDynamicArch true; + USE_OPENMP = true; + }; + + i686-linux = { + BINARY = 32; + TARGET = setTarget "P2"; + DYNAMIC_ARCH = setDynamicArch true; + USE_OPENMP = true; + }; + + x86_64-darwin = { + BINARY = 64; + TARGET = setTarget "ATHLON"; + DYNAMIC_ARCH = setDynamicArch true; + NO_AVX512 = !enableAVX512; + USE_OPENMP = false; + MACOSX_DEPLOYMENT_TARGET = "10.7"; + }; + + x86_64-linux = { + BINARY = 64; + TARGET = setTarget "ATHLON"; + DYNAMIC_ARCH = setDynamicArch true; + NO_AVX512 = !enableAVX512; + USE_OPENMP = !stdenv.hostPlatform.isMusl; + }; + + powerpc64le-linux = { + BINARY = 64; + TARGET = setTarget "POWER5"; + DYNAMIC_ARCH = setDynamicArch true; + USE_OPENMP = !stdenv.hostPlatform.isMusl; + }; + + riscv64-linux = { + BINARY = 64; + TARGET = setTarget "RISCV64_GENERIC"; + DYNAMIC_ARCH = setDynamicArch false; + USE_OPENMP = true; + }; + }; +in + +let + config = + configs.${stdenv.hostPlatform.system} + or (throw "unsupported system: ${stdenv.hostPlatform.system}"); +in + +let + blas64 = + if blas64_ != null + then blas64_ + else hasPrefix "x86_64" stdenv.hostPlatform.system; + # Convert flag values to format OpenBLAS's build expects. + # `toString` is almost what we need other than bools, + # which we need to map {true -> 1, false -> 0} + # (`toString` produces empty string `""` for false instead of `0`) + mkMakeFlagValue = val: + if !builtins.isBool val then toString val + else if val then "1" else "0"; + mkMakeFlagsFromConfig = mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}"); + + shlibExt = stdenv.hostPlatform.extensions.sharedLibrary; + +in +stdenv.mkDerivation rec { + pname = "openblas"; + version = "0.3.19"; + + outputs = [ "out" "dev" ]; + + src = fetchFromGitHub { + owner = "xianyi"; + repo = "OpenBLAS"; + rev = "v${version}"; + sha256 = "sha256-EqA6oFM2theuvvuDOWeOx0Bv6AEFffmpWHJBzp23br0="; + }; + + inherit blas64; + + # Some hardening features are disabled due to sporadic failures in + # OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but + # with how these flags interact with hardening measures used downstream. + # In either case, OpenBLAS must only be used by trusted code--it is + # inherently unsuitable for security-conscious applications--so there should + # be no objection to disabling these hardening measures. + hardeningDisable = [ + # don't modify or move the stack + "stackprotector" "pic" + # don't alter index arithmetic + "strictoverflow" + # don't interfere with dynamic target detection + "relro" "bindnow" + ]; + + nativeBuildInputs = [ + perl + which + ]; + + depsBuildBuild = [ + buildPackages.gfortran + buildPackages.stdenv.cc + ]; + + makeFlags = mkMakeFlagsFromConfig (config // { + FC = "${stdenv.cc.targetPrefix}gfortran"; + CC = "${stdenv.cc.targetPrefix}${if stdenv.cc.isClang then "clang" else "cc"}"; + PREFIX = placeholder "out"; + NUM_THREADS = 64; + INTERFACE64 = blas64; + NO_STATIC = !enableStatic; + NO_SHARED = !enableShared; + CROSS = stdenv.hostPlatform != stdenv.buildPlatform; + HOSTCC = "cc"; + # Makefile.system only checks defined status + # This seems to be a bug in the openblas Makefile: + # on x86_64 it expects NO_BINARY_MODE= + # but on aarch64 it expects NO_BINARY_MODE=0 + NO_BINARY_MODE = if stdenv.isx86_64 + then toString (stdenv.hostPlatform != stdenv.buildPlatform) + else stdenv.hostPlatform != stdenv.buildPlatform; + } // (lib.optionalAttrs singleThreaded { + # As described on https://github.com/xianyi/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded + USE_THREAD = false; + USE_LOCKING = true; # available with openblas >= 0.3.7 + USE_OPENMP = false; # openblas will refuse building with both USE_OPENMP=1 and USE_THREAD=0 + })); + + doCheck = true; + checkTarget = "tests"; + + postInstall = '' + # Write pkgconfig aliases. Upstream report: + # https://github.com/xianyi/OpenBLAS/issues/1740 + for alias in blas cblas lapack; do + cat <<EOF > $out/lib/pkgconfig/$alias.pc +Name: $alias +Version: ${version} +Description: $alias provided by the OpenBLAS package. +Cflags: -I$out/include +Libs: -L$out/lib -lopenblas +EOF + done + + # Setup symlinks for blas / lapack + '' + lib.optionalString enableShared '' + ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt} + ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt} + ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt} + ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt} + '' + lib.optionalString (stdenv.hostPlatform.isLinux && enableShared) '' + ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt}.3 + ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt}.3 + ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt}.3 + ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt}.3 + '' + lib.optionalString enableStatic '' + ln -s $out/lib/libopenblas.a $out/lib/libblas.a + ln -s $out/lib/libopenblas.a $out/lib/libcblas.a + ln -s $out/lib/libopenblas.a $out/lib/liblapack.a + ln -s $out/lib/libopenblas.a $out/lib/liblapacke.a + ''; + + meta = with lib; { + description = "Basic Linear Algebra Subprograms"; + license = licenses.bsd3; + homepage = "https://github.com/xianyi/OpenBLAS"; + platforms = platforms.unix; + maintainers = with maintainers; [ ttuegel ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix new file mode 100644 index 000000000000..21c7d45a9099 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/openlibm/default.nix @@ -0,0 +1,23 @@ +{ lib, stdenv, fetchFromGitHub }: + +stdenv.mkDerivation rec { + pname = "openlibm"; + version = "0.8.1"; + + src = fetchFromGitHub { + owner = "JuliaLang"; + repo = "openlibm"; + rev = "v${version}"; + sha256 = "sha256-q7BYUU8oChjuBFbVnpT+vqIAu+BVotT4xY2Dn0hmWfc="; + }; + + makeFlags = [ "prefix=$(out)" ]; + + meta = { + description = "High quality system independent, portable, open source libm implementation"; + homepage = "https://openlibm.org/"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.ttuegel ]; + platforms = lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix new file mode 100644 index 000000000000..4422a908838f --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/openspecfun/default.nix @@ -0,0 +1,24 @@ +{ lib, stdenv, fetchFromGitHub, gfortran }: + +stdenv.mkDerivation rec { + pname = "openspecfun"; + version = "0.5.5"; + src = fetchFromGitHub { + owner = "JuliaLang"; + repo = "openspecfun"; + rev = "v${version}"; + sha256 = "sha256-fX2wc8LHUcF5nN/hiA60ZZ7emRTs0SznOm/0q6lD+Ko="; + }; + + makeFlags = [ "prefix=$(out)" ]; + + nativeBuildInputs = [ gfortran ]; + + meta = { + description = "A collection of special mathematical functions"; + homepage = "https://github.com/JuliaLang/openspecfun"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.ttuegel ]; + platforms = lib.platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix new file mode 100644 index 000000000000..ca3e4a243691 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/or-tools/default.nix @@ -0,0 +1,117 @@ +{ lib +, stdenv +, fetchFromGitHub +, cmake +, abseil-cpp +, bzip2 +, zlib +, lsb-release +, which +, protobuf +, cbc +, ensureNewerSourcesForZipFilesHook +, python +, swig4 +}: + +stdenv.mkDerivation rec { + pname = "or-tools"; + version = "9.1"; + disabled = python.pythonOlder "3.6"; # not supported upstream + + src = fetchFromGitHub { + owner = "google"; + repo = "or-tools"; + rev = "v${version}"; + sha256 = "sha256-dEYMPWpa3J9EqtCq3kubdUYJivNRTOKUpNDx3UC1IcQ="; + }; + + # The original build system uses cmake which does things like pull + # in dependencies through git and Makefile creation time. We + # obviously don't want to do this so instead we provide the + # dependencies straight from nixpkgs and use the make build method. + + # Cbc is linked against bzip2 and declares this in its pkgs-config file, + # but this makefile doesn't use pkgs-config, so we also have to add lbz2 + configurePhase = '' + substituteInPlace makefiles/Makefile.third_party.unix.mk \ + --replace 'COINUTILS_LNK = $(STATIC_COINUTILS_LNK)' \ + 'COINUTILS_LNK = $(STATIC_COINUTILS_LNK) -lbz2' + + cat <<EOF > Makefile.local + UNIX_ABSL_DIR=${abseil-cpp} + UNIX_PROTOBUF_DIR=${protobuf} + UNIX_CBC_DIR=${cbc} + USE_SCIP=OFF + EOF + ''; + + # Many of these 'samples' (which are really the tests) require using SCIP, and or-tools 8.1 + # will just crash if SCIP is not found because it doesn't fall back to using one of + # the available solvers: https://github.com/google/or-tools/blob/b77bd3ac69b7f3bb02f55b7bab6cbb4bab3917f2/ortools/linear_solver/linear_solver.cc#L427 + # We don't compile with SCIP because it does not have an open source license. + # See https://github.com/google/or-tools/issues/2395 + preBuild = '' + for file in ortools/linear_solver/samples/*.cc; do + if grep -q SCIP_MIXED_INTEGER_PROGRAMMING $file; then + substituteInPlace $file --replace SCIP_MIXED_INTEGER_PROGRAMMING CBC_MIXED_INTEGER_PROGRAMMING + fi; + done + + substituteInPlace ortools/linear_solver/samples/simple_mip_program.cc \ + --replace 'SCIP' 'CBC' + ''; + makeFlags = [ + "prefix=${placeholder "out"}" + "PROTOBUF_PYTHON_DESC=${python.pkgs.protobuf}/${python.sitePackages}/google/protobuf/descriptor_pb2.py" + ]; + buildFlags = [ "cc" "pypi_archive" ]; + + doCheck = true; + checkTarget = "test_cc"; + + installTargets = [ "install_cc" ]; + # The upstream install_python target installs to $HOME. + postInstall = '' + mkdir -p "$python/${python.sitePackages}" + (cd temp_python/ortools; PYTHONPATH="$python/${python.sitePackages}:$PYTHONPATH" python setup.py install '--prefix=$python') + ''; + + enableParallelBuilding = true; + + nativeBuildInputs = [ + cmake + lsb-release + swig4 + which + ensureNewerSourcesForZipFilesHook + python.pkgs.setuptools + python.pkgs.wheel + ]; + buildInputs = [ + zlib + bzip2 + python + ]; + propagatedBuildInputs = [ + abseil-cpp + protobuf + + python.pkgs.protobuf + python.pkgs.six + python.pkgs.absl-py + python.pkgs.mypy-protobuf + ]; + + outputs = [ "out" "python" ]; + + meta = with lib; { + homepage = "https://github.com/google/or-tools"; + license = licenses.asl20; + description = '' + Google's software suite for combinatorial optimization. + ''; + maintainers = with maintainers; [ andersk ]; + platforms = with platforms; linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix b/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix new file mode 100644 index 000000000000..b61cd8406064 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/osi/default.nix @@ -0,0 +1,42 @@ +{ stdenv, lib, fetchurl, gfortran, pkg-config +, blas, zlib, bzip2 +, withGurobi ? false, gurobi +, withCplex ? false, cplex }: + +stdenv.mkDerivation rec { + pname = "osi"; + version = "0.108.6"; + + src = fetchurl { + url = "https://www.coin-or.org/download/source/Osi/Osi-${version}.tgz"; + sha256 = "1n2jlpq4aikbp0ncs16f7q1pj7yk6kny1bh4fmjaqnwrjw63zvsp"; + }; + + buildInputs = + [ blas zlib bzip2 ] + ++ lib.optional withGurobi gurobi + ++ lib.optional withCplex cplex; + nativeBuildInputs = [ gfortran pkg-config ]; + configureFlags = + lib.optionals withGurobi [ "--with-gurobi-incdir=${gurobi}/include" "--with-gurobi-lib=-lgurobi${gurobi.libSuffix}" ] + ++ lib.optionals withCplex [ "--with-cplex-incdir=${cplex}/cplex/include/ilcplex" "--with-cplex-lib=-lcplex${cplex.libSuffix}" ]; + + NIX_LDFLAGS = + lib.optionalString withCplex "-L${cplex}/cplex/bin/${cplex.libArch}"; + + # Compile errors + NIX_CFLAGS_COMPILE = "-Wno-cast-qual"; + hardeningDisable = [ "format" ]; + + enableParallelBuilding = true; + + passthru = { inherit withGurobi withCplex; }; + + meta = with lib; { + description = "An abstract base class to a generic linear programming (LP) solver"; + homepage = "https://github.com/coin-or/Osi"; + license = licenses.epl10; + platforms = platforms.unix; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix new file mode 100644 index 000000000000..485ec06773bb --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/osqp/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv +, fetchFromGitHub +, cmake +}: + +stdenv.mkDerivation rec { + pname = "osqp"; + version = "0.6.2"; + + src = fetchFromGitHub { + owner = "oxfordcontrol"; + repo = "osqp"; + rev = "v${version}"; + sha256 = "sha256-RYk3zuZrJXPcF27eMhdoZAio4DZ+I+nFaUEg1g/aLNk="; + fetchSubmodules = true; + }; + + nativeBuildInputs = [ cmake ]; + + meta = with lib; { + description = "A quadratic programming solver using operator splitting"; + homepage = "https://osqp.org"; + license = licenses.asl20; + maintainers = with maintainers; [ taktoa ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix new file mode 100644 index 000000000000..eeb1d14b910a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/p4est-sc/default.nix @@ -0,0 +1,72 @@ +{ lib, stdenv, fetchFromGitHub +, autoreconfHook, pkg-config +, p4est-sc-debugEnable ? true, p4est-sc-mpiSupport ? true +, mpi, openssh, zlib +}: + +let + dbg = if debugEnable then "-dbg" else ""; + debugEnable = p4est-sc-debugEnable; + mpiSupport = p4est-sc-mpiSupport; + isOpenmpi = mpiSupport && mpi.pname == "openmpi"; +in +stdenv.mkDerivation { + pname = "p4est-sc${dbg}"; + version = "unstable-2021-06-14"; + + # fetch an untagged snapshot of the prev3-develop branch + src = fetchFromGitHub { + owner = "cburstedde"; + repo = "libsc"; + rev = "1ae814e3fb1cc5456652e0d77550386842cb9bfb"; + sha256 = "14vm0b162jh8399pgpsikbwq4z5lkrw9vfzy3drqykw09n6nc53z"; + }; + + strictDeps = true; + nativeBuildInputs = [ autoreconfHook pkg-config ]; + propagatedNativeBuildInputs = lib.optional mpiSupport mpi + ++ lib.optional isOpenmpi openssh + ; + propagatedBuildInputs = [ zlib ]; + inherit debugEnable mpiSupport; + + postPatch = '' + echo "dist_scaclocal_DATA += config/sc_v4l2.m4" >> Makefile.am + ''; + preConfigure = '' + echo "2.8.0" > .tarball-version + ${if mpiSupport then "unset CC" else ""} + ''; + + configureFlags = [ "--enable-pthread=-pthread" ] + ++ lib.optional debugEnable "--enable-debug" + ++ lib.optional mpiSupport "--enable-mpi" + ; + + dontDisableStatic = true; + enableParallelBuilding = true; + makeFlags = [ "V=0" ]; + + preCheck = '' + export OMPI_MCA_rmaps_base_oversubscribe=1 + export HYDRA_IFACE=lo + ''; + + # disallow Darwin checks due to prototype incompatibility of qsort_r + # to be fixed in a future version of the source code + doCheck = !stdenv.isDarwin && stdenv.hostPlatform == stdenv.buildPlatform; + + meta = { + branch = "prev3-develop"; + description = "Support for parallel scientific applications"; + longDescription = '' + The SC library provides support for parallel scientific applications. + Its main purpose is to support the p4est software library, hence + this package is called p4est-sc, but it works standalone, too. + ''; + homepage = "https://www.p4est.org/"; + downloadPage = "https://github.com/cburstedde/libsc.git"; + license = lib.licenses.lgpl21Plus; + maintainers = [ lib.maintainers.cburstedde ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix new file mode 100644 index 000000000000..c38b0d623bac --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/p4est/default.nix @@ -0,0 +1,59 @@ +{ lib, stdenv, fetchFromGitHub +, autoreconfHook, pkg-config +, p4est-withMetis ? true, metis +, p4est-sc +}: + +let + inherit (p4est-sc) debugEnable mpiSupport; + dbg = if debugEnable then "-dbg" else ""; + withMetis = p4est-withMetis; +in +stdenv.mkDerivation { + pname = "p4est${dbg}"; + version = "unstable-2021-06-22"; + + # fetch an untagged snapshot of the prev3-develop branch + src = fetchFromGitHub { + owner = "cburstedde"; + repo = "p4est"; + rev = "7423ac5f2b2b64490a7a92e5ddcbd251053c4dee"; + sha256 = "0vffnf48rzw6d0as4c3x1f31b4kapmdzr1hfj5rz5ngah72gqrph"; + }; + + strictDeps = true; + nativeBuildInputs = [ autoreconfHook pkg-config ]; + propagatedBuildInputs = [ p4est-sc ]; + buildInputs = lib.optional withMetis metis; + inherit debugEnable mpiSupport withMetis; + + patches = [ ./p4est-metis.patch ]; + postPatch = '' + sed -i -e "s:\(^\s*ACLOCAL_AMFLAGS.*\)\s@P4EST_SC_AMFLAGS@\s*$:\1 -I ${p4est-sc}/share/aclocal:" Makefile.am + ''; + preConfigure = '' + echo "2.8.0" > .tarball-version + ${if mpiSupport then "unset CC" else ""} + ''; + + configureFlags = p4est-sc.configureFlags + ++ [ "--with-sc=${p4est-sc}" ] + ++ lib.optional withMetis "--with-metis" + ; + + inherit (p4est-sc) makeFlags dontDisableStatic enableParallelBuilding preCheck doCheck; + + meta = { + branch = "prev3-develop"; + description = "Parallel AMR on Forests of Octrees"; + longDescription = '' + The p4est software library provides algorithms for parallel AMR. + AMR refers to Adaptive Mesh Refinement, a technique in scientific + computing to cover the domain of a simulation with an adaptive mesh. + ''; + homepage = "https://www.p4est.org/"; + downloadPage = "https://github.com/cburstedde/p4est.git"; + license = lib.licenses.gpl2Plus; + maintainers = [ lib.maintainers.cburstedde ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch b/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch new file mode 100644 index 000000000000..46b8dc8af08c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/p4est/p4est-metis.patch @@ -0,0 +1,26 @@ +diff --git a/src/p4est_connectivity.c b/src/p4est_connectivity.c +index 95339136..c93528f2 100644 +--- a/src/p4est_connectivity.c ++++ b/src/p4est_connectivity.c +@@ -3715,6 +3715,7 @@ p4est_connectivity_reorder_newid (sc_MPI_Comm comm, int k, + sc_array_t * newid) + { + const int n = (int) conn->num_trees; ++ int metis_n; + int *xadj; + int *adjncy; + int *part; +@@ -3862,10 +3863,12 @@ p4est_connectivity_reorder_newid (sc_MPI_Comm comm, int k, + + P4EST_GLOBAL_INFO ("Entering metis\n"); + /* now call metis */ ++ metis_n = n; + P4EST_EXECUTE_ASSERT_INT +- (METIS_PartGraphRecursive (&n, &ncon, xadj, adjncy, NULL, NULL, ++ (METIS_PartGraphRecursive (&metis_n, &ncon, xadj, adjncy, NULL, NULL, + NULL, &k, NULL, NULL, NULL, &volume, part), + METIS_OK); ++ P4EST_ASSERT (metis_n == n); + P4EST_GLOBAL_INFO ("Done metis\n"); + + P4EST_GLOBAL_STATISTICSF ("metis volume %d\n", volume); diff --git a/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix new file mode 100644 index 000000000000..db70bf8dd7a4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/parmetis/default.nix @@ -0,0 +1,34 @@ +{ lib, stdenv +, fetchurl +, cmake +, mpi +}: + +stdenv.mkDerivation rec { + pname = "parmetis"; + version = "4.0.3"; + + src = fetchurl { + url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/parmetis/parmetis-${version}.tar.gz"; + sha256 = "0pvfpvb36djvqlcc3lq7si0c5xpb2cqndjg8wvzg35ygnwqs5ngj"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ mpi ]; + + # metis and GKlib are packaged with distribution + # AUR https://aur.archlinux.org/packages/parmetis/ has reported that + # it easier to build with the included packages as opposed to using the metis + # package. Compilation time is short. + configurePhase = '' + make config metis_path=$PWD/metis gklib_path=$PWD/metis/GKlib prefix=$out + ''; + + meta = with lib; { + description = "An MPI-based parallel library that implements a variety of algorithms for partitioning unstructured graphs, meshes, and for computing fill-reducing orderings of sparse matrices"; + homepage = "http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview"; + platforms = platforms.all; + license = licenses.unfree; + maintainers = [ maintainers.costrouc ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix new file mode 100644 index 000000000000..4a4208e1cbe4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/petsc/default.nix @@ -0,0 +1,79 @@ +{ lib +, stdenv +, fetchurl +, darwin +, gfortran +, python3 +, blas +, lapack +, mpi # generic mpi dependency +, openssh # required for openmpi tests +, petsc-withp4est ? true +, p4est +, zlib # propagated by p4est but required by petsc +}: + +# This version of PETSc does not support a non-MPI p4est build +assert petsc-withp4est -> p4est.mpiSupport; + +stdenv.mkDerivation rec { + pname = "petsc"; + version = "3.16.4"; + + src = fetchurl { + url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz"; + sha256 = "sha256-IpzOIr3P7bH+gn0wbtGvypc3eGzcPwVit0oZZsEkPK8="; + }; + + mpiSupport = !withp4est || p4est.mpiSupport; + withp4est = petsc-withp4est; + + strictDeps = true; + nativeBuildInputs = [ python3 gfortran ] + ++ lib.optional mpiSupport mpi + ++ lib.optional (mpiSupport && mpi.pname == "openmpi") openssh + ; + buildInputs = [ blas lapack ] + ++ lib.optional withp4est p4est + ; + + prePatch = lib.optionalString stdenv.isDarwin '' + substituteInPlace config/install.py \ + --replace /usr/bin/install_name_tool ${darwin.cctools}/bin/install_name_tool + ''; + + preConfigure = '' + export FC="${gfortran}/bin/gfortran" F77="${gfortran}/bin/gfortran" + patchShebangs ./lib/petsc/bin + configureFlagsArray=( + $configureFlagsArray + ${if !mpiSupport then '' + "--with-mpi=0" + '' else '' + "--CC=mpicc" + "--with-cxx=mpicxx" + "--with-fc=mpif90" + "--with-mpi=1" + ''} + ${if withp4est then '' + "--with-p4est=1" + "--with-zlib-include=${zlib.dev}/include" + "--with-zlib-lib=-L${zlib}/lib -lz" + '' else ""} + "--with-blas=1" + "--with-lapack=1" + ) + ''; + + configureScript = "python ./configure"; + + enableParallelBuilding = true; + doCheck = stdenv.hostPlatform == stdenv.buildPlatform; + + meta = with lib; { + description = "Portable Extensible Toolkit for Scientific computation"; + homepage = "https://www.mcs.anl.gov/petsc/index.html"; + license = licenses.bsd2; + maintainers = with maintainers; [ cburstedde ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix new file mode 100644 index 000000000000..a257b84ca54b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/planarity/default.nix @@ -0,0 +1,39 @@ +{ lib, stdenv +, fetchFromGitHub +, fetchpatch +, autoreconfHook +}: + +stdenv.mkDerivation rec { + pname = "planarity"; + version = "3.0.0.5"; + + src = fetchFromGitHub { + owner = "graph-algorithms"; + repo = "edge-addition-planarity-suite"; + rev = "Version_${version}"; + sha256 = "01cm7ay1njkfsdnmnvh5zwc7wg7x189hq1vbfhh9p3ihrbnmqzh8"; + }; + + nativeBuildInputs = [ + autoreconfHook + ]; + + doCheck = true; + + patches = [ + # declare variables declared in headers as extern, not yet merged upstream + (fetchpatch { + url = "https://github.com/graph-algorithms/edge-addition-planarity-suite/pull/3.patch"; + sha256 = "1nqjc4clr326imz4jxqxcxv2hgh1sjgzll27k5cwkdin8lnmmil8"; + }) + ]; + + meta = with lib; { + homepage = "https://github.com/graph-algorithms/edge-addition-planarity-suite"; + description = "A library for implementing graph algorithms"; + license = licenses.bsd3; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/primecount/default.nix b/nixpkgs/pkgs/development/libraries/science/math/primecount/default.nix new file mode 100644 index 000000000000..e1390ce6416e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/primecount/default.nix @@ -0,0 +1,33 @@ +{ lib, stdenv, fetchFromGitHub, cmake, primesieve }: + +stdenv.mkDerivation rec { + pname = "primecount"; + version = "7.2"; + + nativeBuildInputs = [ cmake ]; + + buildInputs = [ primesieve ]; + + src = fetchFromGitHub { + owner = "kimwalisch"; + repo = "primecount"; + rev = "v${version}"; + sha256 = "sha256-/Cb/HkD4UQ9gXsRpvRiEuQBoRd0THxNHsBaAAa+CqQo="; + }; + + cmakeFlags = [ + "-DBUILD_STATIC_LIBS=OFF" + "-DBUILD_SHARED_LIBS=ON" + "-DBUILD_TESTS=ON" + "-DBUILD_PRIMECOUNT=ON" + "-DBUILD_LIBPRIMESIEVE=ON" + ]; + + meta = with lib; { + description = "Fast prime counting function implementations"; + homepage = "https://github.com/kimwalisch/primecount"; + license = licenses.bsd2; + platforms = platforms.unix; + maintainers = teams.sage.members; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/primesieve/default.nix b/nixpkgs/pkgs/development/libraries/science/math/primesieve/default.nix new file mode 100644 index 000000000000..0cf263218a3b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/primesieve/default.nix @@ -0,0 +1,23 @@ +{ lib, stdenv, fetchFromGitHub, cmake }: + +stdenv.mkDerivation rec { + pname = "primesieve"; + version = "7.8"; + + nativeBuildInputs = [ cmake ]; + + src = fetchFromGitHub { + owner = "kimwalisch"; + repo = "primesieve"; + rev = "v${version}"; + sha256 = "sha256-M35CP/xEyC7mEh84kaGsgfsDI9fnanHraNPgTvpqimI="; + }; + + meta = with lib; { + description = "Fast C/C++ prime number generator"; + homepage = "https://primesieve.org/"; + license = licenses.bsd2; + platforms = platforms.unix; + maintainers = with maintainers; [ abbradar ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix new file mode 100644 index 000000000000..c00d579702cc --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/rankwidth/default.nix @@ -0,0 +1,27 @@ +{ lib, stdenv +, fetchurl +}: + +stdenv.mkDerivation rec { + pname = "rankwidth"; + version = "0.9"; + + src = fetchurl { + url = "mirror://sageupstream/rw/rw-${version}.tar.gz"; + sha256 = "sha256-weA1Bv4lzfy0KMBR/Fay0q/7Wwb7o/LOdWYxRmvvtEE="; + }; + + configureFlags = [ + "--enable-executable=no" # no igraph dependency + ]; + + # check phase is empty for now (as of version 0.9) + doCheck = true; + + meta = with lib; { + description = "Calculates rank-width and rank-decompositions"; + license = with licenses; [ gpl2Plus ]; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix new file mode 100644 index 000000000000..b4b670884989 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/rubiks/default.nix @@ -0,0 +1,81 @@ +{ lib, stdenv +, fetchurl +, fetchpatch +, coreutils +}: + +stdenv.mkDerivation rec { + pname = "rubiks"; + version = "20070912"; + + src = fetchurl { + url = "mirror://sageupstream/rubiks/rubiks-${version}.tar.bz2"; + sha256 = "0zdmkb0j1kyspdpsszzb2k3279xij79jkx0dxd9f3ix1yyyg3yfq"; + }; + + preConfigure = '' + export INSTALL="${coreutils}/bin/install" + ''; + + # everything is done in `make install` + buildPhase = "true"; + + installFlags = [ + "PREFIX=$(out)" + ]; + + patches = [ + # Fix makefiles which use all the variables in all the wrong ways and + # hardcode values for some variables. + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-cu2-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "1ry3w1mk9q4jqd91zlaa1bdiiplld4hpfjaldbhlmzlgrrc99qmq"; + }) + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-mcube-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "0zsbh6k3kqdg82fv0kzghr1x7pafisv943gmssqscp107bhg77bz"; + }) + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/dietz-solver-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "0vhw70ylnmydgjhwx8jjlb2slccj4pfqn6vzirkyz1wp8apsmfhp"; + }) + (fetchpatch { + url = "https://git.sagemath.org/sage.git/plain/build/pkgs/rubiks/patches/reid-Makefile.patch?id=07d6c37d18811e2b377a9689790a7c5e24da16ba"; + sha256 = "1r311sn012xs135s0d21qwsig2kld7rdcq19nm0zbnklviid57df"; + }) + ]; + + meta = with lib; { + homepage = "https://wiki.sagemath.org/spkg/rubiks"; + description = "Several programs for working with Rubik's cubes"; + # The individual websites are no longer available + longDescription = '' + There are several programs for working with Rubik's cubes, by three + different people. Look inside the directories under /src to see + specific info and licensing. In summary the three contributers are: + + + Michael Reid (GPL) http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html + optimal - uses many pre-computed tables to find an optimal + solution to the 3x3x3 Rubik's cube + + + Dik T. Winter (MIT License) + cube - uses Kociemba's algorithm to iteratively find a short + solution to the 3x3x3 Rubik's cube + size222 - solves a 2x2x2 Rubik's cube + + + Eric Dietz (GPL) http://www.wrongway.org/?rubiksource + cu2 - A fast, non-optimal 2x2x2 solver + cubex - A fast, non-optimal 3x3x3 solver + mcube - A fast, non-optimal 4x4x4 solver + ''; + license = with licenses; [ + gpl2 # Michael Reid's and Eric Dietz software + mit # Dik T. Winter's software + ]; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix new file mode 100644 index 000000000000..9a7374f4f49c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/scalapack/default.nix @@ -0,0 +1,74 @@ +{ lib, stdenv, fetchFromGitHub, cmake, openssh +, mpi, blas, lapack +} : + +assert blas.isILP64 == lapack.isILP64; + +stdenv.mkDerivation rec { + pname = "scalapack"; + version = "2.2.0"; + + src = fetchFromGitHub { + owner = "Reference-ScaLAPACK"; + repo = pname; + rev = "v${version}"; + sha256 = "0hiap5i9ik6xpvl721n2slanlqygagc1pg2bcjb27ans6balhsfh"; + }; + + passthru = { inherit (blas) isILP64; }; + + # Required to activate ILP64. + # See https://github.com/Reference-ScaLAPACK/scalapack/pull/19 + postPatch = lib.optionalString passthru.isILP64 '' + sed -i 's/INTSZ = 4/INTSZ = 8/g' TESTING/EIG/* TESTING/LIN/* + sed -i 's/INTGSZ = 4/INTGSZ = 8/g' TESTING/EIG/* TESTING/LIN/* + + # These tests are not adapted to ILP64 + sed -i '/xssep/d;/xsgsep/d;/xssyevr/d' TESTING/CMakeLists.txt + ''; + + nativeBuildInputs = [ cmake ]; + checkInputs = [ openssh ]; + buildInputs = [ blas lapack ]; + propagatedBuildInputs = [ mpi ]; + + doCheck = true; + + preConfigure = '' + cmakeFlagsArray+=( + -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF + -DLAPACK_LIBRARIES="-llapack" + -DBLAS_LIBRARIES="-lblas" + -DCMAKE_Fortran_COMPILER=${mpi}/bin/mpif90 + ${lib.optionalString passthru.isILP64 '' + -DCMAKE_Fortran_FLAGS="-fdefault-integer-8" + -DCMAKE_C_FLAGS="-DInt=long" + ''} + ) + ''; + + # Increase individual test timeout from 1500s to 10000s because hydra's builds + # sometimes fail due to this + checkFlagsArray = [ "ARGS=--timeout 10000" ]; + + preCheck = '' + # make sure the test starts even if we have less than 4 cores + export OMPI_MCA_rmaps_base_oversubscribe=1 + + # Fix to make mpich run in a sandbox + export HYDRA_IFACE=lo + + # Run single threaded + export OMP_NUM_THREADS=1 + + export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}`pwd`/lib + ''; + + meta = with lib; { + homepage = "http://www.netlib.org/scalapack/"; + description = "Library of high-performance linear algebra routines for parallel distributed memory machines"; + license = licenses.bsd3; + platforms = [ "x86_64-linux" ]; + maintainers = with maintainers; [ costrouc markuskowa ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix new file mode 100644 index 000000000000..a945e99ec9cb --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/scs/default.nix @@ -0,0 +1,52 @@ +{ lib, stdenv, fetchFromGitHub, blas, lapack, gfortran, fixDarwinDylibNames }: + +assert (!blas.isILP64) && (!lapack.isILP64); + +stdenv.mkDerivation rec { + pname = "scs"; + version = "3.1.0"; + + src = fetchFromGitHub { + owner = "cvxgrp"; + repo = "scs"; + rev = version; + sha256 = "sha256-yoh25DmvY7fohAvABCiSLkvr7TskGd0ED2K3rIa/IeM="; + }; + + # Actually link and add libgfortran to the rpath + postPatch = '' + substituteInPlace scs.mk \ + --replace "#-lgfortran" "-lgfortran" \ + --replace "gcc" "cc" + ''; + + nativeBuildInputs = lib.optional stdenv.isDarwin fixDarwinDylibNames; + + buildInputs = [ blas lapack gfortran.cc.lib ]; + + doCheck = true; + + # Test demo requires passing data and seed; numbers chosen arbitrarily. + postCheck = '' + ./out/demo_socp_indirect 42 0.42 0.42 42 + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/lib + cp -r include $out/ + cp out/*.a out/*.so out/*.dylib $out/lib/ + runHook postInstall + ''; + + meta = with lib; { + description = "Splitting Conic Solver"; + longDescription = '' + Numerical optimization package for solving large-scale convex cone problems + ''; + homepage = "https://github.com/cvxgrp/scs"; + license = licenses.mit; + platforms = platforms.all; + maintainers = [ maintainers.bhipple ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix b/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix new file mode 100644 index 000000000000..6e94d093a2cb --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/default.nix @@ -0,0 +1,52 @@ +{ lib, stdenv, fetchurl, perl }: + +stdenv.mkDerivation rec { + pname = "spooles"; + version = "2.2"; + + src = fetchurl { + url = "http://www.netlib.org/linalg/spooles/spooles.${version}.tgz"; + sha256 = "1pf5z3vvwd8smbpibyabprdvcmax0grzvx2y0liy98c7x6h5jid8"; + }; + + sourceRoot = "."; + + patches = [ + ./spooles.patch + ]; + + postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace makefile --replace '-Wl,-soname' '-Wl,-install_name' + ''; + + buildPhase = '' + make lib + ''; + + installPhase = '' + mkdir -p $out/lib $out/include/spooles + cp libspooles.a libspooles.so.2.2 $out/lib/ + ln -s libspooles.so.2.2 $out/lib/libspooles.so.2 + ln -s libspooles.so.2 $out/lib/libspooles.so + for h in *.h; do + if [ $h != 'MPI.h' ]; then + cp $h $out/include/spooles + d=`basename $h .h` + if [ -d $d ]; then + mkdir $out/include/spooles/$d + cp $d/*.h $out/include/spooles/$d + fi + fi + done + ''; + + nativeBuildInputs = [ perl ]; + + meta = with lib; { + homepage = "http://www.netlib.org/linalg/spooles/"; + description = "Library for solving sparse real and complex linear systems of equations"; + license = licenses.publicDomain; + maintainers = with maintainers; [ gebner ]; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch b/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch new file mode 100644 index 000000000000..71fb4a7f44e1 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/spooles/spooles.patch @@ -0,0 +1,188 @@ +diff --git a/I2Ohash/src/util.c b/I2Ohash/src/util.c +index 72d082e..f32f667 100644 +--- a/I2Ohash/src/util.c ++++ b/I2Ohash/src/util.c +@@ -39,9 +39,10 @@ fflush(stdout) ; + */ + loc1 = (key1 + 1) % hashtable->nlist ; + loc2 = (key2 + 1) % hashtable->nlist ; +-loc = (loc1*loc2) % hashtable->nlist ; ++long int loc3 = (long int)loc1*(long int)loc2 % hashtable->nlist ; ++loc =(int) loc3; + #if MYDEBUG > 0 +-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ; ++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ; + fflush(stdout) ; + #endif + /* +@@ -158,9 +159,10 @@ fflush(stdout) ; + #endif + loc1 = (key1 + 1) % hashtable->nlist ; + loc2 = (key2 + 1) % hashtable->nlist ; +-loc = (loc1*loc2) % hashtable->nlist ; ++long int loc3 = (long int)loc1*(long int)loc2 % hashtable->nlist ; ++loc =(int) loc3; + #if MYDEBUG > 0 +-fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %d", loc1, loc2, loc) ; ++fprintf(stdout, "\n loc1 = %d, loc2 = %d, loc3 = %ld, loc = %d", loc1, loc2, loc3, loc) ; + fflush(stdout) ; + #endif + /* +diff --git a/MPI/makefile b/MPI/makefile +index 0c09f86..d25e70a 100644 +--- a/MPI/makefile ++++ b/MPI/makefile +@@ -2,7 +2,7 @@ all_drivers : + cd drivers ; make drivers + + lib : +- cd src ; make spoolesMPI.a ++ cd src ; make makeLib + + clean : + cd src ; make clean +diff --git a/MPI/src/makefile b/MPI/src/makefile +index f7650b7..71e4c49 100644 +--- a/MPI/src/makefile ++++ b/MPI/src/makefile +@@ -42,3 +42,8 @@ $(OBJ).a : \ + + clean : + - rm -f *.a *.o ++ ++makeLib : ++ perl ../../makeLib > makeG ++ make -f makeG ++ rm -f makeG +diff --git a/MT/makefile b/MT/makefile +index 9b86a32..d25e70a 100644 +--- a/MT/makefile ++++ b/MT/makefile +@@ -2,7 +2,7 @@ all_drivers : + cd drivers ; make drivers + + lib : +- cd src ; make spoolesMT.a ++ cd src ; make makeLib + + clean : + cd src ; make clean +diff --git a/Make.inc b/Make.inc +index f99eb8f..2de8a25 100644 +--- a/Make.inc ++++ b/Make.inc +@@ -12,7 +12,7 @@ + # for solaris + # + # CC = gcc +- CC = /usr/lang-4.0/bin/cc ++# CC = /usr/lang-4.0/bin/cc + # + # for sgi + # +@@ -28,7 +28,7 @@ + # + # OPTLEVEL = + # OPTLEVEL = -g -v +- OPTLEVEL = -O ++ OPTLEVEL = -O3 + # OPTLEVEL = -xO5 -v + # OPTLEVEL = -O3 + # OPTLEVEL = -O4 +@@ -43,7 +43,7 @@ + # set any load flags + # + # LDFLAGS = -Wl,+parallel -Wl,+tm,spp2000 # for hp exemplar +- LDFLAGS = ++# LDFLAGS = + # + #--------------------------------------------------------------------- + # +@@ -103,7 +103,7 @@ + # MPI install library + # + # MPI_INSTALL_DIR = +- MPI_INSTALL_DIR = /usr/local/mpich-1.0.13 ++# MPI_INSTALL_DIR = /usr/lib/openmpi + # + #--------------------------------------------------------------------- + # +@@ -142,6 +142,6 @@ + # MPI include path + # + # MPI_INCLUDE_DIR = +- MPI_INCLUDE_DIR = -I$(MPI_INSTALL_DIR)/include ++# MPI_INCLUDE_DIR = -I/usr/include/mpi + # + #--------------------------------------------------------------------- +diff --git a/Utilities/src/iohb.c b/Utilities/src/iohb.c +index ac38f7b..ac34034 100644 +--- a/Utilities/src/iohb.c ++++ b/Utilities/src/iohb.c +@@ -1725,7 +1725,7 @@ static void upcase(char* S) + + static void IOHBTerminate(char* message) + { +- fprintf(stderr,message); ++ fputs(message, stderr); + exit(1); + } + +diff --git a/makeLib b/makeLib +index 1780f39..7697b06 100755 +--- a/makeLib ++++ b/makeLib +@@ -64,14 +64,19 @@ foreach $src ( @srcnames ) { + $srcname = " \\\n " . $src ; + print $srcname ; + } ++print "\n\n.SUFFIXES: .c .o .lo .a .so" ; + print "\n\nOBJ_FILES = \$\{SRC:.c=.o\}" ; ++print "\n\nLOBJ_FILES = \$\{SRC:.c=.lo\}" ; + print "\n\n" ; + print <<'EOF' ; + .c.o : +- $(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o ++ $(PURIFY) $(CC) -c $(CFLAGS) $*.c -o $(OBJ)_$*.o $(MPI_INCLUDE_DIR) + +-../../spooles.a : ${OBJ_FILES} +- $(AR) $(ARFLAGS) ../../spooles.a $(OBJ)_*.o ++.c.lo : ++ $(PURIFY) $(CC) -c $(CFLAGS) $*.c -fPIC -DPIC -o $(OBJ)_$*.lo $(MPI_INCLUDE_DIR) ++ ++../../libspooles.a : ${OBJ_FILES} ${LOBJ_FILES} ++ $(AR) $(ARFLAGS) ../../libspooles.a $(OBJ)_*.o + rm -f $(OBJ)_*.o +- $(RANLIB) ../../spooles.a ++ $(RANLIB) ../../libspooles.a + EOF +diff --git a/makefile b/makefile +index f014c7d..7c8042a 100755 +--- a/makefile ++++ b/makefile +@@ -124,7 +124,9 @@ lib : + cd ZV ; make lib + cd misc ; make lib + #cd MPI ; make lib +-#cd MT ; make lib ++ cd MT ; make lib ++ $(CC) -shared */*/*.lo -Wl,-soname,libspooles.so.2.2 -o libspooles.so.2.2 -lpthread -lm ++ ln -s libspooles.so.2.2 libspooles.so + + global : + cd A2/src ; make -f makeGlobalLib +diff --git a/timings.h b/timings.h +index 23df189..685800b 100644 +--- a/timings.h ++++ b/timings.h +@@ -2,9 +2,8 @@ + #define _TIMINGS_ + #include <sys/time.h> + static struct timeval TV ; +-static struct timezone TZ ; + #define MARKTIME(t) \ +- gettimeofday(&TV, &TZ) ; \ ++ gettimeofday(&TV, NULL) ; \ + t = (TV.tv_sec + 0.000001*TV.tv_usec) + #endif + diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix new file mode 100644 index 000000000000..4c0059184ee3 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse-graphblas/default.nix @@ -0,0 +1,32 @@ +{ lib, stdenv +, fetchFromGitHub +, cmake +, gnum4 +}: + +stdenv.mkDerivation rec { + pname = "suitesparse-graphblas"; + version = "6.1.4"; + + outputs = [ "out" "dev" ]; + + src = fetchFromGitHub { + owner = "DrTimothyAldenDavis"; + repo = "GraphBLAS"; + rev = "v${version}"; + sha256 = "sha256-pjb4Q9b+5hcI0ZYoez46V/ve4+1GJORu2ZGweceaWDY="; + }; + + nativeBuildInputs = [ + cmake + gnum4 + ]; + + meta = with lib; { + description = "Graph algorithms in the language of linear algebra"; + homepage = "http://faculty.cse.tamu.edu/davis/GraphBLAS.html"; + license = licenses.asl20; + maintainers = with maintainers; []; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix new file mode 100644 index 000000000000..b8ce3eca888c --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.2.nix @@ -0,0 +1,43 @@ +{ lib, stdenv, fetchurl, gfortran, blas, lapack }: + +let + int_t = if blas.isILP64 then "int64_t" else "int32_t"; +in +stdenv.mkDerivation rec { + version = "4.2.1"; + pname = "suitesparse"; + src = fetchurl { + url = "http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-${version}.tar.gz" ; + sha256 = "1ga69637x7kdkiy3w3lq9dvva7220bdangv2lch2wx1hpi83h0p8"; + }; + + nativeBuildInputs = [ gfortran ]; + buildInputs = [ blas lapack ]; + + preConfigure = '' + mkdir -p $out/lib + mkdir -p $out/include + + sed -i "SuiteSparse_config/SuiteSparse_config.mk" \ + -e 's/METIS .*$/METIS =/' \ + -e 's/METIS_PATH .*$/METIS_PATH =/' \ + -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \ + -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/' + ''; + + makeFlags = [ + "PREFIX=\"$(out)\"" + "INSTALL_LIB=$(out)/lib" + "INSTALL_INCLUDE=$(out)/include" + "BLAS=-lblas" + "LAPACK=-llapack" + ]; + + meta = with lib; { + homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html"; + description = "A suite of sparse matrix algorithms"; + license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ]; + maintainers = with maintainers; [ ttuegel ]; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix new file mode 100644 index 000000000000..1ebac6ac445d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/4.4.nix @@ -0,0 +1,100 @@ +{ lib, stdenv, fetchurl, gfortran, blas, lapack +, enableCuda ? false, cudatoolkit +}: + +let + version = "4.4.4"; + name = "suitesparse-${version}"; + + int_t = if blas.isILP64 then "int64_t" else "int32_t"; + SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary; +in +stdenv.mkDerivation { + inherit name; + + src = fetchurl { + url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${version}.tar.gz"; + sha256 = "1zdn1y0ij6amj7smmcslkqgbqv9yy5cwmbyzqc9v6drzdzllgbpj"; + }; + + preConfigure = '' + mkdir -p $out/lib + mkdir -p $out/include + + sed -i "SuiteSparse_config/SuiteSparse_config.mk" \ + -e 's/METIS .*$/METIS =/' \ + -e 's/METIS_PATH .*$/METIS_PATH =/' \ + -e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION -DLONGBLAS=${int_t}/' \ + -e '/UMFPACK_CONFIG/ s/$/-DLONGBLAS=${int_t}/' + '' + + lib.optionalString stdenv.isDarwin '' + sed -i "SuiteSparse_config/SuiteSparse_config.mk" \ + -e 's/^[[:space:]]*\(LIB = -lm\) -lrt/\1/' + '' + + lib.optionalString enableCuda '' + sed -i "SuiteSparse_config/SuiteSparse_config.mk" \ + -e 's|^[[:space:]]*\(CUDA_ROOT =\)|CUDA_ROOT = ${cudatoolkit}|' \ + -e 's|^[[:space:]]*\(GPU_BLAS_PATH =\)|GPU_BLAS_PATH = $(CUDA_ROOT)|' \ + -e 's|^[[:space:]]*\(GPU_CONFIG =\)|GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS -DCHOLMOD_OMP_NUM_THREADS=$(NIX_BUILD_CORES) |' \ + -e 's|^[[:space:]]*\(CUDA_PATH =\)|CUDA_PATH = $(CUDA_ROOT)|' \ + -e 's|^[[:space:]]*\(CUDART_LIB =\)|CUDART_LIB = $(CUDA_ROOT)/lib64/libcudart.so|' \ + -e 's|^[[:space:]]*\(CUBLAS_LIB =\)|CUBLAS_LIB = $(CUDA_ROOT)/lib64/libcublas.so|' \ + -e 's|^[[:space:]]*\(CUDA_INC_PATH =\)|CUDA_INC_PATH = $(CUDA_ROOT)/include/|' \ + -e 's|^[[:space:]]*\(NV20 =\)|NV20 = -arch=sm_20 -Xcompiler -fPIC|' \ + -e 's|^[[:space:]]*\(NV30 =\)|NV30 = -arch=sm_30 -Xcompiler -fPIC|' \ + -e 's|^[[:space:]]*\(NV35 =\)|NV35 = -arch=sm_35 -Xcompiler -fPIC|' \ + -e 's|^[[:space:]]*\(NVCC =\) echo|NVCC = $(CUDA_ROOT)/bin/nvcc|' \ + -e 's|^[[:space:]]*\(NVCCFLAGS =\)|NVCCFLAGS = $(NV20) -O3 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_60,code=sm_60|' + ''; + + makeFlags = [ + "PREFIX=\"$(out)\"" + "INSTALL_LIB=$(out)/lib" + "INSTALL_INCLUDE=$(out)/include" + "BLAS=-lblas" + "LAPACK=-llapack" + ]; + + NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin " -DNTIMER"; + + postInstall = '' + # Build and install shared library + ( + cd "$(mktemp -d)" + for i in "$out"/lib/lib*.a; do + ar -x $i + done + ${if enableCuda then cudatoolkit else stdenv.cc.outPath}/bin/${if enableCuda then "nvcc" else "cc"} *.o ${if stdenv.isDarwin then "-dynamiclib" else "--shared"} -o "$out/lib/libsuitesparse${SHLIB_EXT}" -lblas ${lib.optionalString enableCuda "-lcublas"} + ) + for i in umfpack cholmod amd camd colamd spqr; do + ln -s libsuitesparse${SHLIB_EXT} "$out"/lib/lib$i${SHLIB_EXT} + done + + # Install documentation + outdoc=$out/share/doc/${name} + mkdir -p $outdoc + cp -r AMD/Doc $outdoc/amd + cp -r BTF/Doc $outdoc/bft + cp -r CAMD/Doc $outdoc/camd + cp -r CCOLAMD/Doc $outdoc/ccolamd + cp -r CHOLMOD/Doc $outdoc/cholmod + cp -r COLAMD/Doc $outdoc/colamd + cp -r CXSparse/Doc $outdoc/cxsparse + cp -r KLU/Doc $outdoc/klu + cp -r LDL/Doc $outdoc/ldl + cp -r RBio/Doc $outdoc/rbio + cp -r SPQR/Doc $outdoc/spqr + cp -r UMFPACK/Doc $outdoc/umfpack + ''; + + nativeBuildInputs = [ gfortran ]; + buildInputs = [ blas lapack ]; + + meta = with lib; { + homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html"; + description = "A suite of sparse matrix algorithms"; + license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ]; + maintainers = with maintainers; [ ttuegel ]; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix new file mode 100644 index 000000000000..5a6de9f64e83 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -0,0 +1,74 @@ +{ lib, stdenv +, fetchFromGitHub +, gfortran +, blas, lapack +, metis +, fixDarwinDylibNames +, gmp +, mpfr +, enableCuda ? false +, cudatoolkit +}: + +stdenv.mkDerivation rec { + pname = "suitesparse"; + version = "5.10.1"; + + outputs = [ "out" "dev" "doc" ]; + + src = fetchFromGitHub { + owner = "DrTimothyAldenDavis"; + repo = "SuiteSparse"; + rev = "v${version}"; + sha256 = "sha256-ifuoXgVQp2vHR/reC/Hjbt3vqaKpql3Nfxdb/Cgv/aU="; + }; + + nativeBuildInputs = [ + ] ++ lib.optional stdenv.isDarwin fixDarwinDylibNames; + + # Use compatible indexing for lapack and blas used + buildInputs = assert (blas.isILP64 == lapack.isILP64); [ + blas lapack + metis + gfortran.cc.lib + gmp + mpfr + ] ++ lib.optional enableCuda cudatoolkit; + + preConfigure = '' + # Mongoose and GraphBLAS are packaged separately + sed -i "Makefile" -e '/GraphBLAS\|Mongoose/d' + ''; + + makeFlags = [ + "INSTALL=${placeholder "out"}" + "INSTALL_INCLUDE=${placeholder "dev"}/include" + "JOBS=$(NIX_BUILD_CORES)" + "MY_METIS_LIB=-lmetis" + ] ++ lib.optionals blas.isILP64 [ + "CFLAGS=-DBLAS64" + ] ++ lib.optionals enableCuda [ + "CUDA_PATH=${cudatoolkit}" + "CUDART_LIB=${cudatoolkit.lib}/lib/libcudart.so" + "CUBLAS_LIB=${cudatoolkit}/lib/libcublas.so" + ] ++ lib.optionals stdenv.isDarwin [ + # Unless these are set, the build will attempt to use `Accelerate` on darwin, see: + # https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v5.10.1/SuiteSparse_config/SuiteSparse_config.mk#L368 + "BLAS=-lblas" + "LAPACK=-llapack" + ] + ; + + buildFlags = [ + # Build individual shared libraries, not demos + "library" + ]; + + meta = with lib; { + homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html"; + description = "A suite of sparse matrix algorithms"; + license = with licenses; [ bsd2 gpl2Plus lgpl21Plus ]; + maintainers = with maintainers; [ ttuegel ]; + platforms = with platforms; unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch new file mode 100644 index 000000000000..29d86238af08 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/add-superlu-lib-as-dependency-for-the-unit-tests.patch @@ -0,0 +1,7 @@ +--- a/TESTING/MATGEN/CMakeLists.txt ++++ b/TESTING/MATGEN/CMakeLists.txt +@@ -97,3 +97,4 @@ if(enable_complex16) + endif() + + add_library(matgen ${sources}) ++target_link_libraries(matgen superlu) diff --git a/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix new file mode 100644 index 000000000000..26dd00d96069 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/superlu/default.nix @@ -0,0 +1,37 @@ +{ lib, stdenv, fetchurl, cmake, + gfortran, blas, lapack}: + +assert (!blas.isILP64) && (!lapack.isILP64); + +stdenv.mkDerivation rec { + version = "5.2.1"; + pname = "superlu"; + + src = fetchurl { + url = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/superlu_${version}.tar.gz"; + sha256 = "0qzlb7cd608q62kyppd0a8c65l03vrwqql6gsm465rky23b6dyr8"; + }; + + nativeBuildInputs = [ cmake gfortran ]; + + propagatedBuildInputs = [ blas ]; + + cmakeFlags = [ + "-DBUILD_SHARED_LIBS=true" + "-DUSE_XSDK_DEFAULTS=true" + ]; + + patches = [ + ./add-superlu-lib-as-dependency-for-the-unit-tests.patch + ]; + + doCheck = true; + checkTarget = "test"; + + meta = { + homepage = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/"; + license = "http://crd-legacy.lbl.gov/~xiaoye/SuperLU/License.txt"; + description = "A library for the solution of large, sparse, nonsymmetric systems of linear equations"; + platforms = lib.platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch b/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch new file mode 100644 index 000000000000..cbcf18b4cdb2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/sympow/clean-extra-logfile-output-from-pari.patch @@ -0,0 +1,39 @@ +commit 433a8b99da9d71e96434bd421c2468cbda29d37c +Author: Mauricio Collares <mauricio@collares.org> +Date: Tue Mar 2 22:07:11 2021 -0300 + + trim logfile information from pari 2.13 output + + Pari (since commit 609fb01faf827d91dfa9136849a647a3bbfe8036) prints + extra logfile information such as + + [logfile is "/tmp/nix-shell.2BquN9/home/.sympow/datafiles/P02HM.txt"] + + which messes up sympow's parsing. This commit reuses the same trimming + mechanism already in sympow to trim this new message. + +diff --git a/Configure b/Configure +index 1ef9756..776bec2 100755 +--- a/Configure ++++ b/Configure +@@ -322,7 +322,7 @@ echo "datafiles/param_data: \$(OTHERb)" >> $FILE + echo " \$(MKDIR) -p datafiles" >> $FILE + echo " \$(TOUCH) datafiles/param_data" >> $FILE + echo " \$(SH) armd.sh" >> $FILE +-echo " \$(SED) -i -e '/logfile =/d' datafiles/*.txt" >> $FILE ++echo " \$(SED) -i -e '/logfile /d' datafiles/*.txt" >> $FILE + echo "sympow.1: sympow" >> $FILE + echo " \$(HELP2MAN) \$(H2MFLAGS) -s 1 -n \"SYMPOW program\" -I sympow.h2m -o \$@ ./\$<" >> $FILE + echo "clean:" >> $FILE +diff --git a/generate.c b/generate.c +index dbb811f..783320c 100644 +--- a/generate.c ++++ b/generate.c +@@ -148,6 +148,7 @@ static void trimit(char *A) + " -e '" + "/^\?/d" ";" + "/^(/d" ";" ++ "/logfile /d" ";" + "/Warning:/d" ";" + "/^About to find TOO_BIG/d" ";" + "/^Now working backwards/d" ";" diff --git a/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix new file mode 100644 index 000000000000..c31c705d39d0 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/sympow/default.nix @@ -0,0 +1,76 @@ +{ lib, stdenv +, fetchFromGitLab +, makeWrapper +, which +, autoconf +, help2man +, file +, pari +}: + +stdenv.mkDerivation rec { + version = "2.023.6"; + pname = "sympow"; + + src = fetchFromGitLab { + group = "rezozer"; + owner = "forks"; + repo = "sympow"; + rev = "v${version}"; + sha256 = "132l0xv00ld1svvv9wh99wfra4zzjv2885h2sq0dsl98wiyvi5zl"; + }; + + patches = [ ./clean-extra-logfile-output-from-pari.patch ]; + + postUnpack = '' + patchShebangs . + ''; + + nativeBuildInputs = [ + makeWrapper + which + autoconf + help2man + file + pari + ]; + + configurePhase = '' + runHook preConfigure + export PREFIX="$out" + export VARPREFIX="$out" # see comment on postInstall + ./Configure # doesn't take any options + runHook postConfigure + ''; + + # Usually, sympow has 3 levels of caching: statically distributed in /usr/, + # shared in /var and per-user in ~/.sympow. The shared cache assumes trust in + # other users and a shared /var is not compatible with nix's approach, so we + # set VARPREFIX to the read-only $out. This effectively disables shared + # caching. See https://trac.sagemath.org/ticket/3360#comment:36 and sympow's + # README for more details on caching. + # sympow will complain at runtime about the lack of write-permissions on the + # shared cache. We pass the `-quiet` flag by default to disable this. + postInstall = '' + wrapProgram "$out/bin/sympow" --add-flags '-quiet' + ''; + + # Example from the README as a sanity check. + doInstallCheck = true; + installCheckPhase = '' + export HOME="$TMP/home" + mkdir -p "$HOME" + "$out/bin/sympow" -sp 2p16 -curve "[1,2,3,4,5]" | grep '8.3705' + ''; + + meta = with lib; { + description = "Compute special values of symmetric power elliptic curve L-functions"; + license = { + shortName = "sympow"; + fullName = "Custom, BSD-like. See COPYING file."; + free = true; + }; + maintainers = teams.sage.members; + platforms = platforms.linux; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix new file mode 100644 index 000000000000..cf2346bad271 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/default.nix @@ -0,0 +1,181 @@ +{ stdenv +, bash +, abseil-cpp +, fetchFromGitHub +, fetchFromGitLab +, fetchpatch +, fetchurl +, flatbuffers +, hostPlatform +, lib +, zlib +}: +let + tflite-eigen = fetchFromGitLab { + owner = "libeigen"; + repo = "eigen"; + rev = "3d9051ea84a5089b277c88dac456b3b1576bfa7f"; + sha256 = "1y3f2jvimb5i904f4n37h23cv2pkdlbz8656s0kga1y7c0p50wif"; + }; + + gemmlowp-src = fetchFromGitHub { + owner = "google"; + repo = "gemmlowp"; + rev = "fda83bdc38b118cc6b56753bd540caa49e570745"; + sha256 = "1sbp8kmr2azwlvfbzryy1frxi99jhsh1nc93bdbxdf8zdgpv0kxl"; + }; + + neon-2-sse-src = fetchFromGitHub { + owner = "intel"; + repo = "ARM_NEON_2_x86_SSE"; + rev = "1200fe90bb174a6224a525ee60148671a786a71f"; + sha256 = "0fhxch711ck809dpq1myxz63jiiwfcnxvj45ww0kg8s0pqpn5kv6"; + }; + + farmhash-src = fetchFromGitHub { + owner = "google"; + repo = "farmhash"; + rev = "816a4ae622e964763ca0862d9dbd19324a1eaf45"; + sha256 = "1mqxsljq476n1hb8ilkrpb39yz3ip2hnc7rhzszz4sri8ma7qzp6"; + }; + + fft2d-src = fetchurl { + url = "http://www.kurims.kyoto-u.ac.jp/~ooura/fft2d.tgz"; + sha256 = "ada7e99087c4ed477bfdf11413f2ba8db8a840ba9bbf8ac94f4f3972e2a7cec9"; + }; + + fp16-src = fetchFromGitHub { + owner = "Maratyszcza"; + repo = "FP16"; + rev = "4dfe081cf6bcd15db339cf2680b9281b8451eeb3"; + sha256 = "06a8dfl3a29r93nxpp6hpywsajz5d555n3sqd3i6krybb6swnvh7"; + }; + + ruy-src = fetchFromGitHub { + owner = "google"; + repo = "ruy"; + rev = "23633b37099b614a2f836ef012cafc8087fdb98c"; + sha256 = "14k9hz6ss8qy8nsajk6lrq25f6qxrldxky31ijw0dpqnfnnswrx4"; + }; + + cpuinfo-src = fetchFromGitHub { + owner = "pytorch"; + repo = "cpuinfo"; + rev = "5916273f79a21551890fd3d56fc5375a78d1598d"; + sha256 = "0q6760xdxsg18acdv8vq3yrq7ksr7wsm8zbyan01zf2khnb6fw4x"; + }; +in +stdenv.mkDerivation rec { + pname = "tensorflow-lite"; + version = "2.5.0"; + + src = fetchFromGitHub { + owner = "tensorflow"; + repo = "tensorflow"; + rev = "v${version}"; + sha256 = "1jdw2i1rq06zqd6aabh7bbm0avsg4pygnfmd7gviv0blhih9054l"; + }; + + patches = [ + # TODO: remove on the next version bump + (fetchpatch { + name = "include-schema-conversion-utils-source.patch"; + url = "https://github.com/tensorflow/tensorflow/commit/f3c4f4733692150fd6174f2cd16438cfaba2e5ab.patch"; + sha256 = "0zx4hbz679kn79f30159rl1mq74dg45cvaawii0cyv48z472yy4k"; + }) + # TODO: remove on the next version bump + (fetchpatch { + name = "cxxstandard-var.patch"; + url = "https://github.com/tensorflow/tensorflow/commit/9b128ae4200e10b4752f903492d1e7d11957ed5c.patch"; + sha256 = "1q0izdwdji5fbyqll6k4dmkzfykyvvz5cvc6hysdj285nkn2wy6h"; + }) + ]; + + buildInputs = [ zlib flatbuffers ]; + + dontConfigure = true; + + postPatch = '' + substituteInPlace ./tensorflow/lite/tools/make/Makefile \ + --replace /bin/bash ${bash}/bin/bash \ + --replace /bin/sh ${bash}/bin/sh + ''; + + makefile = "tensorflow/lite/tools/make/Makefile"; + + preBuild = + let + includes = + lib.concatMapStringsSep + " " + (subdir: "-I $PWD/tensorflow/lite/tools/make/downloads/${subdir}") + [ + "neon_2_sse" + "gemmlowp" + "absl" + "fp16/include" + "farmhash/src" + "ruy" + "cpuinfo" + "cpuinfo/src" + "cpuinfo/include" + "cpuinfo/deps/clog/include" + "eigen" + ]; + in + '' + # enter the vendoring lair of doom + + prefix="$PWD/tensorflow/lite/tools/make/downloads" + + mkdir -p "$prefix" + + tar xzf ${fft2d-src} -C "$prefix" + + ln -s ${ruy-src} "$prefix/ruy" + ln -s ${gemmlowp-src} "$prefix/gemmlowp" + ln -s ${neon-2-sse-src} "$prefix/neon_2_sse" + ln -s ${farmhash-src} "$prefix/farmhash" + ln -s ${cpuinfo-src} "$prefix/cpuinfo" + ln -s ${fp16-src} "$prefix/fp16" + ln -s ${tflite-eigen} "$prefix/eigen" + + # tensorflow lite is using the *source* of flatbuffers + ln -s ${flatbuffers.src} "$prefix/flatbuffers" + + # tensorflow lite expects to compile abseil into `libtensorflow-lite.a` + ln -s ${abseil-cpp.src} "$prefix/absl" + + # set CXXSTANDARD=c++17 here because abseil-cpp in nixpkgs is set as + # such and would be used in dependents like libedgetpu + buildFlagsArray+=( + INCLUDES="-I $PWD ${includes}" + CXXSTANDARD="-std=c++17" + TARGET_TOOLCHAIN_PREFIX="" + -j$NIX_BUILD_CORES + all) + ''; + + installPhase = '' + mkdir "$out" + + # copy the static lib and binaries into the output dir + cp -r ./tensorflow/lite/tools/make/gen/linux_${hostPlatform.uname.processor}/{bin,lib} "$out" + + find ./tensorflow/lite -type f -name '*.h' | while read f; do + path="$out/include/''${f/.\//}" + install -D "$f" "$path" + + # remove executable bit from headers + chmod -x "$path" + done + ''; + + meta = with lib; { + description = "An open source deep learning framework for on-device inference."; + homepage = "https://www.tensorflow.org/lite"; + license = licenses.asl20; + maintainers = with maintainers; [ cpcloud ]; + platforms = [ "x86_64-linux" "aarch64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/eigen_include_dir.patch b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/eigen_include_dir.patch new file mode 100644 index 000000000000..6fa3c703efa9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow-lite/eigen_include_dir.patch @@ -0,0 +1,45 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 28103856e..a36909c0e 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -449,13 +449,6 @@ install(FILES + DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel + ) + +-if(EIGEN_BUILD_PKGCONFIG) +- configure_file(eigen3.pc.in eigen3.pc @ONLY) +- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc +- DESTINATION ${PKGCONFIG_INSTALL_DIR} +- ) +-endif() +- + install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) + + add_subdirectory(doc EXCLUDE_FROM_ALL) +@@ -570,8 +563,15 @@ set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} ) + set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} ) + set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} ) + set ( EIGEN_DEFINITIONS "") +-set ( EIGEN_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" ) + set ( EIGEN_ROOT_DIR ${CMAKE_INSTALL_PREFIX} ) ++GNUInstallDirs_get_absolute_install_dir(EIGEN_INCLUDE_DIR INCLUDE_INSTALL_DIR) ++ ++if(EIGEN_BUILD_PKGCONFIG) ++ configure_file(eigen3.pc.in eigen3.pc @ONLY) ++ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc ++ DESTINATION ${PKGCONFIG_INSTALL_DIR} ++ ) ++endif() + + # Interface libraries require at least CMake 3.0 + if (NOT CMAKE_VERSION VERSION_LESS 3.0) +diff --git a/eigen3.pc.in b/eigen3.pc.in +index 3368a3aa1..d6778bf06 100644 +--- a/eigen3.pc.in ++++ b/eigen3.pc.in +@@ -6,4 +6,4 @@ Description: A C++ template library for linear algebra: vectors, matrices, and r + Requires: + Version: @EIGEN_VERSION_NUMBER@ + Libs: +-Cflags: -I${prefix}/@INCLUDE_INSTALL_DIR@ ++Cflags: -I@EIGEN_INCLUDE_DIR@ diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow/bin.nix b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/bin.nix new file mode 100644 index 000000000000..b57d1191933b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/bin.nix @@ -0,0 +1,71 @@ +{ lib, stdenv +, fetchurl +, addOpenGLRunpath +, cudaSupport ? false, symlinkJoin, cudatoolkit, cudnn +}: + +with lib; +let + broken = !stdenv.isLinux && !stdenv.isDarwin; + + tfType = if cudaSupport then "gpu" else "cpu"; + + system = + if stdenv.isLinux then "linux" + else "darwin"; + + platform = "x86_64"; + + rpath = makeLibraryPath ([stdenv.cc.libc stdenv.cc.cc.lib] + ++ optionals cudaSupport [ cudatoolkit.out cudatoolkit.lib cudnn ]); + + packages = import ./binary-hashes.nix; + + patchLibs = + if stdenv.isDarwin + then '' + install_name_tool -id $out/lib/libtensorflow.dylib $out/lib/libtensorflow.dylib + install_name_tool -id $out/lib/libtensorflow_framework.dylib $out/lib/libtensorflow_framework.dylib + '' + else '' + patchelf --set-rpath "${rpath}:$out/lib" $out/lib/libtensorflow.so + patchelf --set-rpath "${rpath}" $out/lib/libtensorflow_framework.so + ${optionalString cudaSupport '' + addOpenGLRunpath $out/lib/libtensorflow.so $out/lib/libtensorflow_framework.so + ''} + ''; + +in stdenv.mkDerivation rec { + pname = "libtensorflow"; + inherit (packages) version; + + src = fetchurl packages."${tfType}-${system}-${platform}"; + + nativeBuildInputs = optional cudaSupport addOpenGLRunpath; + + # Patch library to use our libc, libstdc++ and others + buildCommand = '' + mkdir -pv $out + tar -C $out -xzf $src + chmod -R +w $out + ${patchLibs} + + # Write pkg-config file. + mkdir $out/lib/pkgconfig + cat > $out/lib/pkgconfig/tensorflow.pc << EOF + Name: TensorFlow + Version: ${version} + Description: Library for computation using data flow graphs for scalable machine learning + Requires: + Libs: -L$out/lib -ltensorflow + Cflags: -I$out/include/tensorflow + EOF + ''; + + meta = { + description = "C API for TensorFlow"; + homepage = "https://www.tensorflow.org/install/lang_c"; + license = licenses.asl20; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix new file mode 100644 index 000000000000..b606e45477a9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/binary-hashes.nix @@ -0,0 +1,15 @@ +{ +version = "2.4.0"; +"cpu-linux-x86_64" = { + url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.4.0.tar.gz"; + sha256 = "022p5jjwmb8rhyyis3cpk2lw45apl2vz49m2rgxmd75h783x1gjk"; +}; +"gpu-linux-x86_64" = { + url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-2.4.0.tar.gz"; + sha256 = "1fclvbrn3fs8qmhmh3lzni7s7wl1w30a071b4gzh9ifnxdhip6lq"; +}; +"cpu-darwin-x86_64" = { + url = "https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.4.0.tar.gz"; + sha256 = "09x096nslg04c8sr7bd5v68a5gfinc0f1h36lbzn8bahs8b1agi3"; +}; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh new file mode 100755 index 000000000000..d571d38f7719 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/tensorflow/prefetcher.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# ./prefetcher.sh 2.4.0 binary-hashes.nix + +version="$1" +hashfile="$2" +rm -f $hashfile +echo "{" >> $hashfile +echo "version = \"$version\";" >> $hashfile +for sys in "linux" "darwin"; do + for tfpref in "cpu" "gpu"; do + for platform in "x86_64"; do + if [ $sys = "darwin" ] && [ $tfpref = "gpu" ]; then + continue + fi + url=https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-$tfpref-$sys-$platform-$version.tar.gz + hash=$(nix-prefetch-url $url) + echo "\"${tfpref}-${sys}-${platform}\" = {" >> $hashfile + echo " url = \"$url\";" >> $hashfile + echo " sha256 = \"$hash\";" >> $hashfile + echo "};" >> $hashfile + done + done +done +echo "}" >> $hashfile + diff --git a/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix b/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix new file mode 100644 index 000000000000..19d2119622e9 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/trilinos/default.nix @@ -0,0 +1,100 @@ +{ stdenv +, lib +, fetchFromGitHub +, blas +, boost +, cmake +, gfortran +, lapack +, mpi +, suitesparse +, swig +, withMPI ? false +}: + +# NOTE: Not all packages are enabled. We specifically enable the ones +# required to build Xyce. If the need comes, we can enable more of them. + +let + flagsBase = '' + -G "Unix Makefiles" + -DBUILD_SHARED_LIBS=ON + -DCMAKE_CXX_FLAGS="-O3 -fPIC" + -DCMAKE_C_FLAGS="-O3 -fPIC" + -DCMAKE_Fortran_FLAGS="-O3 -fPIC" + -DTrilinos_ENABLE_NOX=ON + -DNOX_ENABLE_LOCA=ON + -DTrilinos_ENABLE_EpetraExt=ON + -DEpetraExt_BUILD_BTF=ON + -DEpetraExt_BUILD_EXPERIMENTAL=ON + -DEpetraExt_BUILD_GRAPH_REORDERINGS=ON + -DTrilinos_ENABLE_TrilinosCouplings=ON + -DTrilinos_ENABLE_Ifpack=ON + -DTrilinos_ENABLE_AztecOO=ON + -DTrilinos_ENABLE_Belos=ON + -DTrilinos_ENABLE_Teuchos=ON + -DTeuchos_ENABLE_COMPLEX=ON + -DTrilinos_ENABLE_Amesos=ON + -DAmesos_ENABLE_KLU=ON + -DTrilinos_ENABLE_Amesos2=ON + -DAmesos2_ENABLE_KLU2=ON + -DAmesos2_ENABLE_Basker=ON + -DTrilinos_ENABLE_Sacado=ON + -DTrilinos_ENABLE_Stokhos=ON + -DTrilinos_ENABLE_Kokkos=ON + -DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES=OFF + -DTrilinos_ENABLE_CXX11=ON + -DTPL_ENABLE_AMD=ON + -DTPL_ENABLE_BLAS=ON + -DTPL_ENABLE_LAPACK=ON + ''; + flagsParallel = '' + -DCMAKE_C_COMPILER=mpicc + -DCMAKE_CXX_COMPILER=mpic++ + -DCMAKE_Fortran_COMPILER=mpif77 + -DTrilinos_ENABLE_Isorropia=ON + -DTrilinos_ENABLE_Zoltan=ON + -DTPL_ENABLE_MPI=ON + ''; +in +stdenv.mkDerivation rec { + pname = "trilinos"; + version = "12.12.1"; # Xyce 7.4 requires version 12.12.1 + + src = fetchFromGitHub { + owner = "trilinos"; + repo = "Trilinos"; + rev = "${pname}-release-${lib.replaceStrings [ "." ] [ "-" ] version}"; + sha256 = "sha256-Nqjr7RAlUHm6vs87a1P84Y7BIZEL0Vs/A1Z6dykfv+o="; + }; + + nativeBuildInputs = [ cmake gfortran swig ]; + + buildInputs = [ blas boost lapack suitesparse ] ++ lib.optionals withMPI [ mpi ]; + + preConfigure = + if withMPI then '' + cmakeFlagsArray+=(${flagsBase} ${flagsParallel}) + '' + else '' + cmakeFlagsArray+=(${flagsBase}) + ''; + + passthru = { + inherit withMPI; + }; + + meta = with lib; { + description = "Engineering and scientific problems algorithms"; + longDescription = '' + The Trilinos Project is an effort to develop algorithms and enabling + technologies within an object-oriented software framework for the + solution of large-scale, complex multi-physics engineering and scientific + problems. + ''; + homepage = "https://trilinos.org"; + license = licenses.bsd3; + maintainers = with maintainers; [ fbeffa ]; + platforms = platforms.all; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix new file mode 100644 index 000000000000..38d5d91e0837 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/math/zn_poly/default.nix @@ -0,0 +1,74 @@ +{ stdenv +, lib +, fetchFromGitLab +, fetchpatch +, gmp +, python2 +, tune ? false # tune to hardware, impure +}: + +stdenv.mkDerivation rec { + version = "0.9.1"; + pname = "zn_poly"; + + # sage has picked up the maintenance (bug fixes and building, not development) + # from the original, now unmaintained project which can be found at + # http://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/ + src = fetchFromGitLab { + owner = "sagemath"; + repo = "zn_poly"; + rev = version; + sha256 = "0ra5vy585bqq7g3317iw6fp44iqgqvds3j0l1va6mswimypq4vxb"; + }; + + buildInputs = [ + gmp + ]; + + nativeBuildInputs = [ + python2 # needed by ./configure to create the makefile + ]; + + # name of library file ("libzn_poly.so") + libbasename = "libzn_poly"; + libext = stdenv.targetPlatform.extensions.sharedLibrary; + + makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ]; + + # Tuning (either autotuning or with hand-written paramters) is possible + # but not implemented here. + # It seems buggy anyways (see homepage). + buildFlags = [ "all" "${libbasename}${libext}" ]; + + configureFlags = lib.optionals (!tune) [ + "--disable-tuning" + ]; + + patches = [ + # fix format-security by not passing variables directly to printf + # https://gitlab.com/sagemath/zn_poly/merge_requests/1 + (fetchpatch { + name = "format-security.patch"; + url = "https://gitlab.com/timokau/zn_poly/commit/1950900a80ec898d342b8bcafa148c8027649766.patch"; + sha256 = "1gks9chvsfpc6sg5h3nqqfia4cgvph7jmj9dw67k7dk7kv9y0rk1"; + }) + ]; + + # `make install` fails to install some header files and the lib file. + installPhase = '' + mkdir -p "$out/include/zn_poly" + mkdir -p "$out/lib" + cp "${libbasename}"*"${libext}" "$out/lib" + cp include/*.h "$out/include/zn_poly" + ''; + + doCheck = true; + + meta = with lib; { + homepage = "https://web.maths.unsw.edu.au/~davidharvey/code/zn_poly/"; + description = "Polynomial arithmetic over Z/nZ"; + license = with licenses; [ gpl3 ]; + maintainers = teams.sage.members; + platforms = platforms.unix; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix b/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix new file mode 100644 index 000000000000..3f0d50fd32be --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/networking/ns-3/default.nix @@ -0,0 +1,110 @@ +{ stdenv +, fetchFromGitLab +, python +, wafHook + +# for binding generation +, castxml ? null + +# can take a long time, generates > 30000 images/graphs +, enableDoxygen ? false + +# e.g. "optimized" or "debug". If not set, use default one +, build_profile ? null + +# --enable-examples +, withExamples ? false + +# very long +, withManual ? false, doxygen ? null, graphviz ? null, imagemagick ? null +# for manual, tetex is used to get the eps2pdf binary +# texlive to get latexmk. building manual still fails though +, dia, tetex ? null, ghostscript ? null, texlive ? null + +# generates python bindings +, pythonSupport ? false, ncurses ? null + +# All modules can be enabled by choosing 'all_modules'. +# we include here the DCE mandatory ones +, modules ? [ "core" "network" "internet" "point-to-point" "point-to-point-layout" "fd-net-device" "netanim" ] +, lib +}: + +let + pythonEnv = python.withPackages(ps: + lib.optional withManual ps.sphinx + ++ lib.optionals pythonSupport (with ps;[ pybindgen pygccxml ]) + ); +in +stdenv.mkDerivation rec { + pname = "ns-3"; + version = "35"; + + src = fetchFromGitLab { + owner = "nsnam"; + repo = "ns-3-dev"; + rev = "ns-3.${version}"; + sha256 = "sha256-3w+lCWWra9sndL8+vkGfH5plrDYYCMFi1PzwIVRku6I="; + }; + + nativeBuildInputs = [ wafHook python ]; + + outputs = [ "out" ] ++ lib.optional pythonSupport "py"; + + # ncurses is a hidden dependency of waf when checking python + buildInputs = lib.optionals pythonSupport [ castxml ncurses ] + ++ lib.optional enableDoxygen [ doxygen graphviz imagemagick ] + ++ lib.optional withManual [ dia tetex ghostscript texlive.combined.scheme-medium ]; + + propagatedBuildInputs = [ pythonEnv ]; + + postPatch = '' + patchShebangs doc/ns3_html_theme/get_version.sh + ''; + + wafConfigureFlags = with lib; [ + "--enable-modules=${concatStringsSep "," modules}" + "--with-python=${pythonEnv.interpreter}" + ] + ++ optional (build_profile != null) "--build-profile=${build_profile}" + ++ optional withExamples " --enable-examples " + ++ optional doCheck " --enable-tests " + ; + + doCheck = true; + + buildTargets = "build" + + lib.optionalString enableDoxygen " doxygen" + + lib.optionalString withManual "sphinx"; + + # to prevent fatal error: 'backward_warning.h' file not found + CXXFLAGS = "-D_GLIBCXX_PERMIT_BACKWARD_HASH"; + + postBuild = with lib; let flags = concatStringsSep ";" ( + optional enableDoxygen "./waf doxygen" + ++ optional withManual "./waf sphinx" + ); + in "${flags}" + ; + + postInstall = '' + moveToOutput "${pythonEnv.libPrefix}" "$py" + ''; + + # we need to specify the proper interpreter else ns3 can check against a + # different version + checkPhase = '' + ${pythonEnv.interpreter} ./test.py --nowaf + ''; + + # strictoverflow prevents clang from discovering pyembed when bindings + hardeningDisable = [ "fortify" "strictoverflow"]; + + meta = with lib; { + homepage = "http://www.nsnam.org"; + license = licenses.gpl3; + description = "A discrete time event network simulator"; + platforms = with platforms; unix; + maintainers = with maintainers; [ teto rgrunbla ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix b/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix new file mode 100644 index 000000000000..adf8bdd54b72 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/robotics/edgetpu-compiler/default.nix @@ -0,0 +1,58 @@ +{ autoPatchelfHook +, dpkg +, fetchurl +, lib +, libcxx +, stdenv +}: +stdenv.mkDerivation rec { + pname = "edgetpu-compiler"; + version = "15.0"; + + src = fetchurl rec { + url = "https://packages.cloud.google.com/apt/pool/${pname}_${version}_amd64_${sha256}.deb"; + sha256 = "ce03822053c2bddbb8640eaa988396ae66f9bc6b9d6d671914acd1727c2b445a"; + }; + + nativeBuildInputs = [ + autoPatchelfHook + dpkg + ]; + + buildInputs = [ + libcxx + ]; + + unpackPhase = '' + mkdir bin pkg + + dpkg -x $src pkg + + rm -r pkg/usr/share/lintian + + cp pkg/usr/bin/edgetpu_compiler_bin/edgetpu_compiler ./bin + cp -r pkg/usr/share . + + rm -r pkg + ''; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r ./{bin,share} $out + + runHook postInstall + ''; + + meta = with lib; { + description = "A command line tool that compiles a TensorFlow Lite model into an Edge TPU compatible file."; + homepage = "https://coral.ai/docs/edgetpu/compiler"; + license = licenses.asl20; + maintainers = with maintainers; [ cpcloud ]; + platforms = [ "x86_64-linux" ]; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix new file mode 100644 index 000000000000..b3eed2e326e6 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/science/robotics/ispike/default.nix @@ -0,0 +1,22 @@ +{ lib, stdenv, fetchurl, cmake, boost }: + +stdenv.mkDerivation rec { + pname = "ispike"; + version = "2.1.1"; + + src = fetchurl { + url = "mirror://sourceforge/ispike/${pname}-${version}.tar.gz"; + sha256 = "0khrxp43bi5kisr8j4lp9fl4r5marzf7b4inys62ac108sfb28lp"; + }; + + nativeBuildInputs = [ cmake ]; + buildInputs = [ boost ]; + + meta = { + description = "Spiking neural interface between iCub and a spiking neural simulator"; + homepage = "https://sourceforge.net/projects/ispike/"; + license = lib.licenses.lgpl3; + platforms = lib.platforms.linux; + maintainers = [ lib.maintainers.nico202 ]; + }; +} |