From 8a5d7e794449908d0c1009a0559d97c28497f714 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:14:07 -0600 Subject: [PATCH 1/6] openblas: version bump to 0.2.13 --- pkgs/development/libraries/science/math/openblas/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/science/math/openblas/default.nix b/pkgs/development/libraries/science/math/openblas/default.nix index 6ca1f4ccada..a452037a235 100644 --- a/pkgs/development/libraries/science/math/openblas/default.nix +++ b/pkgs/development/libraries/science/math/openblas/default.nix @@ -4,12 +4,12 @@ let local = config.openblas.preferLocalBuild or false; localTarget = config.openblas.target or ""; in stdenv.mkDerivation rec { - version = "0.2.11"; + version = "0.2.13"; name = "openblas-${version}"; src = fetchurl { url = "https://github.com/xianyi/OpenBLAS/tarball/v${version}"; - sha256 = "1va4yhzgj2chcj6kaxgfbzirajp1zgvkic61959aka2xq2c5igms"; + sha256 = "1asg5mix13ipxgj5h2yj2p0r8km1di5jbcjkn5gmhb37nx7qfv6k"; name = "openblas-${version}.tar.gz"; }; From 91657e30cae8ffc1dd228a5045f875ccfc62ed8e Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:16:46 -0600 Subject: [PATCH 2/6] atlas: fix generic options Build atlas with the generic options recommended by the upstream documentation for distributions. The expression now takes the parameter 'threads' which configures the number of threads atlas will use. The default is to build serial atlas ('threads = "0"'). The expression also takes the parameter 'cacheEdge' which is the L2 cache per core, in bytes. This reduces build time because the cache size doesn't need to be detected. It also reduces impurity, since different build nodes on Hydra may have different hardware. It is set to 256k by default, which is recommended for distributions by the upstream documentation. --- .../libraries/science/math/atlas/default.nix | 68 +++++++++++++++---- 1 file changed, 53 insertions(+), 15 deletions(-) diff --git a/pkgs/development/libraries/science/math/atlas/default.nix b/pkgs/development/libraries/science/math/atlas/default.nix index 938778734e0..3cdab4df16f 100644 --- a/pkgs/development/libraries/science/math/atlas/default.nix +++ b/pkgs/development/libraries/science/math/atlas/default.nix @@ -1,5 +1,7 @@ { stdenv, fetchurl, gfortran, tolerateCpuTimingInaccuracy ? true, shared ? false -, cpuConfig ? if stdenv.isi686 then "-b 32 -A 18 -V 1" else "-b 64 -A 31 -V 384" +, cpuConfig ? if stdenv.isi686 then "-b 32 -A 12 -V 1" else "-b 64 -A 14 -V 384" +, cacheEdge ? "262144" +, threads ? "0" }: # Atlas detects the CPU and optimizes its build accordingly. This is great when @@ -9,27 +11,40 @@ # cannot execute. # # To avoid these issues, the build is configured using the 'cpuConfig' -# parameter as follows: +# parameter. Upstream recommends these defaults for distributions: # # | x86 CPU | x86_64 CPU | # |---------------------------------------------+------------------------| # | -b 32 | -b 64 | -# | -A 18 (Pentium II) | -A 31 (Athlon K7) | -# | -V 1 (No SIMD: Pentium II doesn't have SSE) | -V 384 (SSE1 and SSE2) | +# | -A 12 (x86x87) | -A 14 (x86SSE2) | +# | -V 1 (No SIMD) | -V 384 (SSE1 and SSE2) | # -# Users who want to compile a highly optimized version of ATLAS that's suitable -# for their local machine can override these settings accordingly. +# These defaults should give consistent performance across machines. +# Performance will be substantially lower than an optimized build, but a build +# optimized for one machine will give even worse performance on others. If you +# are a serious user of Atlas (e.g., you write code that uses it) you should +# compile an optimized version for each of your machines. +# +# The parameter 'cacheEdge' sets the L2 cache per core (in bytes). Setting this +# parameter reduces build time because some tests to detect the L2 cache size +# will not be run. It will also reduce impurity; different build nodes on Hydra +# may have different L2 cache sizes, but fixing the L2 cache size should +# account for that. This also makes the performance of binary substitutes more +# consistent. # # The -V flags can change with each release as new instruction sets are added # because upstream thinks it's a good idea to add entries at the start of an # enum, rather than the end. If the build suddenly fails with messages about # missing instruction sets, you may need to poke around in the source a bit. +# +# Upstream recommends the x86x87/x86SSE2 architectures for generic x86/x86_64 +# for distribution builds. Additionally, we set 'cacheEdge' to reduce impurity. +# Otherwise, the cache parameters will be detected by timing which will be +# highly variable on Hydra. let + inherit (stdenv.lib) optional optionalString; version = "3.10.2"; - - optionalString = stdenv.lib.optionalString; - optional = stdenv.lib.optional; in stdenv.mkDerivation { @@ -50,27 +65,50 @@ stdenv.mkDerivation { patches = optional tolerateCpuTimingInaccuracy ./disable-timing-accuracy-check.patch; # Configure outside of the source directory. - preConfigure = '' mkdir build; cd build; configureScript=../configure; ''; + preConfigure = '' + mkdir build + cd build + configureScript=../configure + ''; # * -fPIC is passed even in non-shared builds so that the ATLAS code can be # used to inside of shared libraries, like Octave does. # # * -t 0 disables use of multi-threading. It's not quite clear what the # consequences of that setting are and whether it's necessary or not. - configureFlags = "-Fa alg -fPIC -t 0 ${cpuConfig}" + optionalString shared " --shared"; + configureFlags = [ + "-Fa alg" + "-fPIC" + "-t ${threads}" + cpuConfig + ] ++ optional shared "--shared"; + + postConfigure = '' + if [[ -n "${cacheEdge}" ]]; then + echo '#define CacheEdge ${cacheEdge}' >> include/atlas_cacheedge.h + echo '#define CacheEdge ${cacheEdge}' >> include/atlas_tcacheedge.h + fi + ''; doCheck = true; + postInstall = '' + # Avoid name collision with the real lapack (ATLAS only builds a partial + # lapack). + mv $out/lib/liblapack.a $out/lib/liblapack_atlas.a + ''; + meta = { homepage = "http://math-atlas.sourceforge.net/"; description = "Automatically Tuned Linear Algebra Software (ATLAS)"; license = stdenv.lib.licenses.bsd3; longDescription = '' - The ATLAS (Automatically Tuned Linear Algebra Software) project is an ongoing - research effort focusing on applying empirical techniques in order to provide - portable performance. At present, it provides C and Fortran77 interfaces to a - portably efficient BLAS implementation, as well as a few routines from LAPACK. + The ATLAS (Automatically Tuned Linear Algebra Software) project is an + ongoing research effort focusing on applying empirical techniques in + order to provide portable performance. At present, it provides C and + Fortran77 interfaces to a portably efficient BLAS implementation, as well + as a few routines from LAPACK. ''; maintainers = with stdenv.lib.maintainers; [ ttuegel ]; From 3ce76d4dd0a4482bb09420fb1e5aad814d57196a Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:27:55 -0600 Subject: [PATCH 3/6] atlas: optionally build with full lapack --- .../libraries/science/math/atlas/default.nix | 12 ++++++++---- pkgs/top-level/all-packages.nix | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/science/math/atlas/default.nix b/pkgs/development/libraries/science/math/atlas/default.nix index 3cdab4df16f..f4bda4f4735 100644 --- a/pkgs/development/libraries/science/math/atlas/default.nix +++ b/pkgs/development/libraries/science/math/atlas/default.nix @@ -2,6 +2,7 @@ , cpuConfig ? if stdenv.isi686 then "-b 32 -A 12 -V 1" else "-b 64 -A 14 -V 384" , cacheEdge ? "262144" , threads ? "0" +, liblapack, withLapack }: # Atlas detects the CPU and optimizes its build accordingly. This is great when @@ -48,7 +49,7 @@ let in stdenv.mkDerivation { - name = "atlas-${version}"; + name = "atlas-${version}" + optionalString withLapack "-with-lapack"; src = fetchurl { url = "mirror://sourceforge/math-atlas/atlas${version}.tar.bz2"; @@ -81,7 +82,8 @@ stdenv.mkDerivation { "-fPIC" "-t ${threads}" cpuConfig - ] ++ optional shared "--shared"; + ] ++ optional shared "--shared" + ++ optional withLapack "--with-netlib-lapack-tarfile=${liblapack.src}"; postConfigure = '' if [[ -n "${cacheEdge}" ]]; then @@ -94,8 +96,10 @@ stdenv.mkDerivation { postInstall = '' # Avoid name collision with the real lapack (ATLAS only builds a partial - # lapack). - mv $out/lib/liblapack.a $out/lib/liblapack_atlas.a + # lapack unless withLapack = true). + if ${if withLapack then "false" else "true"}; then + mv $out/lib/liblapack.a $out/lib/liblapack_atlas.a + fi ''; meta = { diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 34b877150a7..bf0a029532a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -12174,8 +12174,12 @@ let # great feature, but it's of limited use with pre-built binaries # coming from a central build farm. tolerateCpuTimingInaccuracy = true; + liblapack = liblapack_3_5_0; + withLapack = false; }; + atlasWithLapack = atlas.override { withLapack = true; }; + blas = callPackage ../development/libraries/science/math/blas { }; content = builderDefsPackage ../applications/science/math/content { From 893f277bd709ae23faff90ffe419c0c9f986295b Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:28:20 -0600 Subject: [PATCH 4/6] arpack: version bump to 3.2.0 --- pkgs/development/libraries/science/math/arpack/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/science/math/arpack/default.nix b/pkgs/development/libraries/science/math/arpack/default.nix index 71f9ef2a2b6..54c0bbca8db 100644 --- a/pkgs/development/libraries/science/math/arpack/default.nix +++ b/pkgs/development/libraries/science/math/arpack/default.nix @@ -1,12 +1,13 @@ { stdenv, fetchurl, gfortran, openblas }: -let version = "3.1.5"; +let + version = "3.2.0"; in stdenv.mkDerivation { name = "arpack-${version}"; src = fetchurl { - url = "http://forge.scilab.org/index.php/p/arpack-ng/downloads/get/arpack-ng_${version}.tar.gz"; - sha256 = "05fmg4m0yri47rzgsl2mnr1qbzrs7qyd557p3v9wwxxw0rwcwsd2"; + url = "https://github.com/opencollab/arpack-ng/archive/${version}.tar.gz"; + sha256 = "1fwch6vipms1ispzg2djvbzv5wag36f1dmmr3xs3mbp6imfyhvff"; }; buildInputs = [ gfortran ]; From 81c0f94d74c0f2f0e040560a003381f2861a71d7 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:28:57 -0600 Subject: [PATCH 5/6] arpack: build against atlasWithLapack --- .../libraries/science/math/arpack/default.nix | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pkgs/development/libraries/science/math/arpack/default.nix b/pkgs/development/libraries/science/math/arpack/default.nix index 54c0bbca8db..296c5f6b920 100644 --- a/pkgs/development/libraries/science/math/arpack/default.nix +++ b/pkgs/development/libraries/science/math/arpack/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, gfortran, openblas }: +{ stdenv, fetchurl, gfortran, atlasWithLapack }: let version = "3.2.0"; @@ -10,23 +10,17 @@ stdenv.mkDerivation { sha256 = "1fwch6vipms1ispzg2djvbzv5wag36f1dmmr3xs3mbp6imfyhvff"; }; - buildInputs = [ gfortran ]; - propagatedBuildInputs = [ openblas ]; - - preConfigure = '' - substituteInPlace arpack.pc.in \ - --replace "@BLAS_LIBS@" "-L${openblas}/lib @BLAS_LIBS@" - ''; + buildInputs = [ gfortran atlasWithLapack ]; # Auto-detection fails because gfortran brings in BLAS by default - configureFlags="--with-blas=-lopenblas --with-lapack=-lopenblas"; + configureFlags="--with-blas=-latlas --with-lapack=-latlas"; meta = { homepage = "http://forge.scilab.org/index.php/p/arpack-ng/"; - description = "A collection of Fortran77 subroutines to solve large scale eigenvalue problems"; - # Looks like OpenBLAS is not that easy to build - # there is a sgemm_itcopy undefined reference on 32-bit, for example - platforms = ["x86_64-linux"]; + description = '' + A collection of Fortran77 subroutines to solve large scale eigenvalue + problems. + ''; license = stdenv.lib.licenses.bsd3; maintainers = [ stdenv.lib.maintainers.ttuegel ]; }; From d582090a15912b5838720a8e0a51accacf043c03 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 15 Dec 2014 11:29:30 -0600 Subject: [PATCH 6/6] suitesparse: add version 4.4.1 --- .../math/suitesparse/0001-disable-metis.patch | 36 ++ .../suitesparse/0002-set-install-dir.patch | 27 ++ .../suitesparse/0003-blas-lapack-flags.patch | 27 ++ .../math/suitesparse/4.2.nix} | 0 .../math/suitesparse/SuiteSparse_config.mk | 452 ++++++++++++++++++ .../science/math/suitesparse/default.nix | 58 +++ .../math}/suitesparse/disable-metis.patch | 0 pkgs/top-level/all-packages.nix | 8 +- 8 files changed, 605 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/libraries/science/math/suitesparse/0001-disable-metis.patch create mode 100644 pkgs/development/libraries/science/math/suitesparse/0002-set-install-dir.patch create mode 100644 pkgs/development/libraries/science/math/suitesparse/0003-blas-lapack-flags.patch rename pkgs/development/libraries/{suitesparse/default.nix => science/math/suitesparse/4.2.nix} (100%) create mode 100644 pkgs/development/libraries/science/math/suitesparse/SuiteSparse_config.mk create mode 100644 pkgs/development/libraries/science/math/suitesparse/default.nix rename pkgs/development/libraries/{ => science/math}/suitesparse/disable-metis.patch (100%) diff --git a/pkgs/development/libraries/science/math/suitesparse/0001-disable-metis.patch b/pkgs/development/libraries/science/math/suitesparse/0001-disable-metis.patch new file mode 100644 index 00000000000..b0f7715f755 --- /dev/null +++ b/pkgs/development/libraries/science/math/suitesparse/0001-disable-metis.patch @@ -0,0 +1,36 @@ +From 456b26d0c9101adaa5876954baac0ca0e872dab6 Mon Sep 17 00:00:00 2001 +From: Thomas Tuegel +Date: Mon, 15 Dec 2014 10:18:01 -0600 +Subject: [PATCH 1/3] disable metis + +--- + SuiteSparse_config/SuiteSparse_config.mk | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/SuiteSparse_config/SuiteSparse_config.mk b/SuiteSparse_config/SuiteSparse_config.mk +index ba2da23..e1514bf 100644 +--- a/SuiteSparse_config/SuiteSparse_config.mk ++++ b/SuiteSparse_config/SuiteSparse_config.mk +@@ -212,8 +212,8 @@ XERBLA = + # The path is relative to where it is used, in CHOLMOD/Lib, CHOLMOD/MATLAB, etc. + # You may wish to use an absolute path. METIS is optional. Compile + # CHOLMOD with -DNPARTITION if you do not wish to use METIS. +-METIS_PATH = ../../metis-4.0 +-METIS = ../../metis-4.0/libmetis.a ++# METIS_PATH = ../../metis-4.0 ++# METIS = ../../metis-4.0/libmetis.a + + #------------------------------------------------------------------------------ + # UMFPACK configuration: +@@ -273,7 +273,7 @@ UMFPACK_CONFIG = + # -DNSUNPERF for Solaris only. If defined, do not use the Sun + # Performance Library + +-CHOLMOD_CONFIG = $(GPU_CONFIG) ++CHOLMOD_CONFIG = $(GPU_CONFIG) -DNPARTITION + + # uncomment this line to compile CHOLMOD without METIS: + # CHOLMOD_CONFIG = -DNPARTITION +-- +2.1.3 + diff --git a/pkgs/development/libraries/science/math/suitesparse/0002-set-install-dir.patch b/pkgs/development/libraries/science/math/suitesparse/0002-set-install-dir.patch new file mode 100644 index 00000000000..ef861f68091 --- /dev/null +++ b/pkgs/development/libraries/science/math/suitesparse/0002-set-install-dir.patch @@ -0,0 +1,27 @@ +From e0fee492a315ce1ef8697b056af210beb1465334 Mon Sep 17 00:00:00 2001 +From: Thomas Tuegel +Date: Mon, 15 Dec 2014 10:18:12 -0600 +Subject: [PATCH 2/3] set install dir + +--- + SuiteSparse_config/SuiteSparse_config.mk | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/SuiteSparse_config/SuiteSparse_config.mk b/SuiteSparse_config/SuiteSparse_config.mk +index e1514bf..f1046a6 100644 +--- a/SuiteSparse_config/SuiteSparse_config.mk ++++ b/SuiteSparse_config/SuiteSparse_config.mk +@@ -95,8 +95,8 @@ F77LIB = + # LIB = -lm + + # For "make install" +-INSTALL_LIB = /usr/local/lib +-INSTALL_INCLUDE = /usr/local/include ++INSTALL_LIB = @out@/lib ++INSTALL_INCLUDE = @out@/include + + # Which version of MAKE you are using (default is "make") + # MAKE = make +-- +2.1.3 + diff --git a/pkgs/development/libraries/science/math/suitesparse/0003-blas-lapack-flags.patch b/pkgs/development/libraries/science/math/suitesparse/0003-blas-lapack-flags.patch new file mode 100644 index 00000000000..db0b1c45655 --- /dev/null +++ b/pkgs/development/libraries/science/math/suitesparse/0003-blas-lapack-flags.patch @@ -0,0 +1,27 @@ +From a99cca30cfd965683564ae024e8ecc615c61697a Mon Sep 17 00:00:00 2001 +From: Thomas Tuegel +Date: Mon, 15 Dec 2014 10:24:08 -0600 +Subject: [PATCH 3/3] blas lapack flags + +--- + SuiteSparse_config/SuiteSparse_config.mk | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/SuiteSparse_config/SuiteSparse_config.mk b/SuiteSparse_config/SuiteSparse_config.mk +index f1046a6..1710162 100644 +--- a/SuiteSparse_config/SuiteSparse_config.mk ++++ b/SuiteSparse_config/SuiteSparse_config.mk +@@ -119,8 +119,8 @@ INSTALL_INCLUDE = @out@/include + # naming the BLAS and LAPACK library (*.a or *.so) files. + + # This is probably slow ... it might connect to the Standard Reference BLAS: +- BLAS = -lblas -lgfortran +- LAPACK = -llapack ++ BLAS = @blasFlags@ ++ LAPACK = @lapackFlags@ + + # MKL + # BLAS = -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -lpthread -lm +-- +2.1.3 + diff --git a/pkgs/development/libraries/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/4.2.nix similarity index 100% rename from pkgs/development/libraries/suitesparse/default.nix rename to pkgs/development/libraries/science/math/suitesparse/4.2.nix diff --git a/pkgs/development/libraries/science/math/suitesparse/SuiteSparse_config.mk b/pkgs/development/libraries/science/math/suitesparse/SuiteSparse_config.mk new file mode 100644 index 00000000000..157a20d7b5a --- /dev/null +++ b/pkgs/development/libraries/science/math/suitesparse/SuiteSparse_config.mk @@ -0,0 +1,452 @@ +#=============================================================================== +# SuiteSparse_config.mk: common configuration file for the SuiteSparse +#=============================================================================== + +# This file contains all configuration settings for all packages authored or +# co-authored by Tim Davis: +# +# Package Version Description +# ------- ------- ----------- +# AMD 1.2 or later approximate minimum degree ordering +# COLAMD 2.4 or later column approximate minimum degree ordering +# CCOLAMD 1.0 or later constrained column approximate minimum degree ordering +# CAMD any constrained approximate minimum degree ordering +# UMFPACK 4.5 or later sparse LU factorization, with the BLAS +# CHOLMOD any sparse Cholesky factorization, update/downdate +# KLU 0.8 or later sparse LU factorization, BLAS-free +# BTF 0.8 or later permutation to block triangular form +# LDL 1.2 or later concise sparse LDL' +# CXSparse any extended version of CSparse (int/long, real/complex) +# SuiteSparseQR any sparse QR factorization +# RBio 2.0 or later read/write sparse matrices in Rutherford-Boeing format +# +# By design, this file is NOT included in the CSparse makefile. +# That package is fully stand-alone. CSparse is primarily for teaching; +# production code should use CXSparse. +# +# The SuiteSparse_config directory and the above packages should all appear in +# a single directory, in order for the Makefile's within each package to find +# this file. +# +# To enable an option of the form "# OPTION = ...", edit this file and +# delete the "#" in the first column of the option you wish to use. +# +# The use of METIS 4.0.1 is optional. To exclude METIS, you must compile with +# CHOLMOD_CONFIG set to -DNPARTITION. See below for details. However, if you +# do not have a metis-4.0 directory inside the SuiteSparse directory, the +# */Makefile's that optionally rely on METIS will automatically detect this +# and compile without METIS. + +#------------------------------------------------------------------------------ +# Generic configuration +#------------------------------------------------------------------------------ + +# Using standard definitions from the make environment, typically: +# +# CC cc C compiler +# CXX g++ C++ compiler +# CFLAGS [ ] flags for C and C++ compiler +# CPPFLAGS [ ] flags for C and C++ compiler +# TARGET_ARCH [ ] target architecture +# FFLAGS [ ] flags for Fortran compiler +# RM rm -f delete a file +# AR ar create a static *.a library archive +# ARFLAGS rv flags for ar +# MAKE make make itself (sometimes called gmake) +# +# You can redefine them here, but by default they are used from the +# default make environment. + +# To use OpenMP add -openmp to the CFLAGS +# If OpenMP is used, it is recommended to define CHOLMOD_OMP_NUM_THREADS +# as the number of cores per socket on the machine being used to maximize +# memory performance + CFLAGS = +# CFLAGS = -g +# for the icc compiler and OpenMP: +# CFLAGS = -openmp + +# C and C++ compiler flags. The first three are standard for *.c and *.cpp +# Add -DNTIMER if you do use any timing routines (otherwise -lrt is required). +# CF = $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -O3 -fexceptions -fPIC -DNTIMER + CF = $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -O3 -fexceptions -fPIC +# for the MKL BLAS: +# CF = $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -O3 -fexceptions -fPIC -I$(MKLROOT)/include -D_GNU_SOURCE +# with no optimization: +# CF = $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -fexceptions -fPIC + +# ranlib, and ar, for generating libraries. If you don't need ranlib, +# just change it to RANLAB = echo +RANLIB = ranlib +ARCHIVE = $(AR) $(ARFLAGS) + +# copy and delete a file +CP = cp -f +MV = mv -f + +# Fortran compiler (not required for 'make' or 'make library') +F77 = gfortran +F77FLAGS = $(FFLAGS) -O +F77LIB = + +# C and Fortran libraries. Remove -lrt if you don't have it. + LIB = -lm -lrt +# Using the following requires CF = ... -DNTIMER on POSIX C systems. +# LIB = -lm + +# For "make install" +INSTALL_LIB = @out@/lib +INSTALL_INCLUDE = @out@/include + +# Which version of MAKE you are using (default is "make") +# MAKE = make +# MAKE = gmake + +#------------------------------------------------------------------------------ +# BLAS and LAPACK configuration: +#------------------------------------------------------------------------------ + +# UMFPACK and CHOLMOD both require the BLAS. CHOLMOD also requires LAPACK. +# See Kazushige Goto's BLAS at http://www.cs.utexas.edu/users/flame/goto/ or +# http://www.tacc.utexas.edu/~kgoto/ for the best BLAS to use with CHOLMOD. +# LAPACK is at http://www.netlib.org/lapack/ . You can use the standard +# Fortran LAPACK along with Goto's BLAS to obtain very good performance. +# CHOLMOD gets a peak numeric factorization rate of 3.6 Gflops on a 3.2 GHz +# Pentium 4 (512K cache, 4GB main memory) with the Goto BLAS, and 6 Gflops +# on a 2.5Ghz dual-core AMD Opteron. + +# These settings will probably not work, since there is no fixed convention for +# naming the BLAS and LAPACK library (*.a or *.so) files. + +# This is probably slow ... it might connect to the Standard Reference BLAS: + BLAS = -lf77blas -latlas -lcblas -lgfortran + LAPACK = -llapack -latlas -lcblas + +# MKL +# BLAS = -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -lpthread -lm +# LAPACK = + +# ACML +# BLAS = -lacml -lgfortran +# LAPACK = + +# OpenBLAS +# BLAS = -lopenblas +# LAPACK = + +# NOTE: this next option for the "Goto BLAS" has nothing to do with a "goto" +# statement. Rather, the Goto BLAS is written by Dr. Kazushige Goto. +# Using the Goto BLAS: +# BLAS = -lgoto -lgfortran -lgfortranbegin +# BLAS = -lgoto2 -lgfortran -lgfortranbegin -lpthread + +# Using non-optimized versions: +# BLAS = -lblas_plain -lgfortran -lgfortranbegin +# LAPACK = -llapack_plain + +# BLAS = -lblas_plain -lgfortran -lgfortranbegin +# LAPACK = -llapack + +# The BLAS might not contain xerbla, an error-handling routine for LAPACK and +# the BLAS. Also, the standard xerbla requires the Fortran I/O library, and +# stops the application program if an error occurs. A C version of xerbla +# distributed with this software (SuiteSparse_config/xerbla/libcerbla.a) +# includes a Fortran-callable xerbla routine that prints nothing and does not +# stop the application program. This is optional. + +# XERBLA = ../../SuiteSparse_config/xerbla/libcerbla.a + +# If you wish to use the XERBLA in LAPACK and/or the BLAS instead, +# use this option: +XERBLA = + +# If you wish to use the Fortran SuiteSparse_config/xerbla/xerbla.f instead, +# use this: + +# XERBLA = ../../SuiteSparse_config/xerbla/libxerbla.a + +#------------------------------------------------------------------------------ +# GPU configuration for CHOLMOD and SPQR +#------------------------------------------------------------------------------ + +# no cuda + CUDA_ROOT = + GPU_BLAS_PATH = + GPU_CONFIG = + CUDA_PATH = + CUDART_LIB = + CUBLAS_LIB = + CUDA_INC_PATH = + NV20 = + NV30 = + NV35 = + NVCC = echo + NVCCFLAGS = + +# with cuda for CHOLMOD +# CUDA_ROOT = /usr/local/cuda +# GPU_BLAS_PATH = $(CUDA_ROOT) +# with 4 cores (default): +# GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS +# with 10 cores: +# GPU_CONFIG = -I$(CUDA_ROOT)/include -DGPU_BLAS -DCHOLMOD_OMP_NUM_THREADS=10 +# CUDA_PATH = $(CUDA_ROOT) +# CUDART_LIB = $(CUDA_ROOT)/lib64/libcudart.so +# CUBLAS_LIB = $(CUDA_ROOT)/lib64/libcublas.so +# CUDA_INC_PATH = $(CUDA_ROOT)/include/ +# NV20 = -arch=sm_20 -Xcompiler -fPIC +# NV30 = -arch=sm_30 -Xcompiler -fPIC +# NV35 = -arch=sm_35 -Xcompiler -fPIC +# NVCC = $(CUDA_ROOT)/bin/nvcc +# NVCCFLAGS = $(NV20) -O3 -gencode=arch=compute_20,code=sm_20 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_35,code=sm_35 + +# was NVCC = $(CUDA_ROOT)/bin/nvcc $(NV35) $(NV30) $(NV20) + +#------------------------------------------------------------------------------ +# METIS, optionally used by CHOLMOD +#------------------------------------------------------------------------------ + +# If you do not have METIS, or do not wish to use it in CHOLMOD, you must +# compile CHOLMOD with the -DNPARTITION flag. + +# The path is relative to where it is used, in CHOLMOD/Lib, CHOLMOD/MATLAB, etc. +# You may wish to use an absolute path. METIS is optional. Compile +# CHOLMOD with -DNPARTITION if you do not wish to use METIS. +# METIS_PATH = ../../metis-4.0 +# METIS = ../../metis-4.0/libmetis.a + +#------------------------------------------------------------------------------ +# UMFPACK configuration: +#------------------------------------------------------------------------------ + +# Configuration flags for UMFPACK. See UMFPACK/Source/umf_config.h for details. +# +# -DNBLAS do not use the BLAS. UMFPACK will be very slow. +# -D'LONGBLAS=long' or -DLONGBLAS='long long' defines the integers used by +# LAPACK and the BLAS (defaults to 'int') +# -DNSUNPERF do not use the Sun Perf. Library (default is use it on Solaris) +# -DNRECIPROCAL do not multiply by the reciprocal +# -DNO_DIVIDE_BY_ZERO do not divide by zero +# -DNCHOLMOD do not use CHOLMOD as a ordering method. If -DNCHOLMOD is +# included in UMFPACK_CONFIG, then UMFPACK does not rely on +# CHOLMOD, CAMD, CCOLAMD, COLAMD, and METIS. + +UMFPACK_CONFIG = + +# uncomment this line to compile UMFPACK without CHOLMOD: +# UMFPACK_CONFIG = -DNCHOLMOD + +#------------------------------------------------------------------------------ +# CHOLMOD configuration +#------------------------------------------------------------------------------ + +# CHOLMOD Library Modules, which appear in libcholmod.a: +# Core requires: none +# Check requires: Core +# Cholesky requires: Core, AMD, COLAMD. optional: Partition, Supernodal +# MatrixOps requires: Core +# Modify requires: Core +# Partition requires: Core, CCOLAMD, METIS. optional: Cholesky +# Supernodal requires: Core, BLAS, LAPACK +# +# CHOLMOD test/demo Modules (all are GNU GPL, do not appear in libcholmod.a): +# Tcov requires: Core, Check, Cholesky, MatrixOps, Modify, Supernodal +# optional: Partition +# Valgrind same as Tcov +# Demo requires: Core, Check, Cholesky, MatrixOps, Supernodal +# optional: Partition +# +# Configuration flags: +# -DNCHECK do not include the Check module. License GNU LGPL +# -DNCHOLESKY do not include the Cholesky module. License GNU LGPL +# -DNPARTITION do not include the Partition module. License GNU LGPL +# also do not include METIS. +# -DNCAMD do not use CAMD, etc from Partition module. GNU LGPL +# -DNGPL do not include any GNU GPL Modules in the CHOLMOD library: +# -DNMATRIXOPS do not include the MatrixOps module. License GNU GPL +# -DNMODIFY do not include the Modify module. License GNU GPL +# -DNSUPERNODAL do not include the Supernodal module. License GNU GPL +# +# -DNPRINT do not print anything. +# -D'LONGBLAS=long' or -DLONGBLAS='long long' defines the integers used by +# LAPACK and the BLAS (defaults to 'int') +# -DNSUNPERF for Solaris only. If defined, do not use the Sun +# Performance Library + +CHOLMOD_CONFIG = $(GPU_CONFIG) -DNPARTITION + +# uncomment this line to compile CHOLMOD without METIS: +# CHOLMOD_CONFIG = -DNPARTITION + +#------------------------------------------------------------------------------ +# SuiteSparseQR configuration: +#------------------------------------------------------------------------------ + +# The SuiteSparseQR library can be compiled with the following options: +# +# -DNPARTITION do not include the CHOLMOD partition module +# -DNEXPERT do not include the functions in SuiteSparseQR_expert.cpp +# -DHAVE_TBB enable the use of Intel's Threading Building Blocks (TBB) + +# default, without timing, without TBB: +SPQR_CONFIG = $(GPU_CONFIG) +# with TBB: +# SPQR_CONFIG = -DHAVE_TBB + +# This is needed for IBM AIX: (but not for and C codes, just C++) +# SPQR_CONFIG = -DBLAS_NO_UNDERSCORE + +# with TBB, you must select this: +# TBB = -ltbb +# without TBB: +TBB = + +#------------------------------------------------------------------------------ +# code formatting +#------------------------------------------------------------------------------ + +# Use "grep" only, if you do not have "indent" +# PRETTY = grep -v "^\#" +# PRETTY = grep -v "^\#" | indent -bl -nce -ss -bli0 -i4 -sob -l120 + PRETTY = grep -v "^\#" | indent -bl -nce -bli0 -i4 -sob -l120 + +#------------------------------------------------------------------------------ +# Linux +#------------------------------------------------------------------------------ + +# Using default compilers: +# CC = gcc +# CF = $(CFLAGS) -O3 -fexceptions + +# alternatives: +# CF = $(CFLAGS) -g -fexceptions \ +# -Wall -W -Wshadow -Wmissing-prototypes -Wstrict-prototypes \ +# -Wredundant-decls -Wnested-externs -Wdisabled-optimization -ansi \ +# -funit-at-a-time +# CF = $(CFLAGS) -O3 -fexceptions \ +# -Wall -W -Werror -Wshadow -Wmissing-prototypes -Wstrict-prototypes \ +# -Wredundant-decls -Wnested-externs -Wdisabled-optimization -ansi +# CF = $(CFLAGS) -O3 -fexceptions -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE +# CF = $(CFLAGS) -O3 +# CF = $(CFLAGS) -O3 -g -fexceptions +# CF = $(CFLAGS) -g -fexceptions \ +# -Wall -W -Wshadow \ +# -Wredundant-decls -Wdisabled-optimization -ansi + +# consider: +# -fforce-addr -fmove-all-movables -freduce-all-givs -ftsp-ordering +# -frename-registers -ffast-math -funroll-loops + +# Using the Goto BLAS: +# BLAS = -lgoto -lfrtbegin -lg2c $(XERBLA) -lpthread + +# Using Intel's icc and ifort compilers: +# (does not work for mexFunctions unless you add a mexopts.sh file) +# F77 = ifort +# CC = icc +# CF = $(CFLAGS) -O3 -xN -vec_report=0 +# CF = $(CFLAGS) -g + +# 64bit: +# F77FLAGS = -O -m64 +# CF = $(CFLAGS) -O3 -fexceptions -m64 +# BLAS = -lgoto64 -lfrtbegin -lg2c -lpthread $(XERBLA) +# LAPACK = -llapack64 + +# SUSE Linux 10.1, AMD Opteron, with GOTO Blas +# F77 = gfortran +# BLAS = -lgoto_opteron64 -lgfortran + +# SUSE Linux 10.1, Intel Pentium, with GOTO Blas +# F77 = gfortran +# BLAS = -lgoto -lgfortran + +#------------------------------------------------------------------------------ +# Mac +#------------------------------------------------------------------------------ + +# As recommended by macports, http://suitesparse.darwinports.com/ +# I've tested them myself on Mac OSX 10.6.1 and 10.6.8 (Snow Leopard), +# on my MacBook Air, and they work fine. + +# F77 = gfortran +# CF = $(CFLAGS) -O3 -fno-common -fexceptions -DNTIMER +# BLAS = -framework Accelerate +# LAPACK = -framework Accelerate +# LIB = -lm + +#------------------------------------------------------------------------------ +# Solaris +#------------------------------------------------------------------------------ + +# 32-bit +# CF = $(CFLAGS) -KPIC -dalign -xc99=%none -Xc -xlibmieee -xO5 -xlibmil -m32 + +# 64-bit +# CF = $(CFLAGS) -fast -KPIC -xc99=%none -xlibmieee -xlibmil -m64 -Xc + +# FFLAGS = -fast -KPIC -dalign -xlibmil -m64 + +# The Sun Performance Library includes both LAPACK and the BLAS: +# BLAS = -xlic_lib=sunperf +# LAPACK = + + +#------------------------------------------------------------------------------ +# Compaq Alpha +#------------------------------------------------------------------------------ + +# 64-bit mode only +# CF = $(CFLAGS) -O2 -std1 +# BLAS = -ldxml +# LAPACK = + +#------------------------------------------------------------------------------ +# IBM RS 6000 +#------------------------------------------------------------------------------ + +# BLAS = -lessl +# LAPACK = + +# 32-bit mode: +# CF = $(CFLAGS) -O4 -qipa -qmaxmem=16384 -qproto +# F77FLAGS = -O4 -qipa -qmaxmem=16384 + +# 64-bit mode: +# CF = $(CFLAGS) -O4 -qipa -qmaxmem=16384 -q64 -qproto +# F77FLAGS = -O4 -qipa -qmaxmem=16384 -q64 + +#------------------------------------------------------------------------------ +# SGI IRIX +#------------------------------------------------------------------------------ + +# BLAS = -lscsl +# LAPACK = + +# 32-bit mode +# CF = $(CFLAGS) -O + +# 64-bit mode (32 bit int's and 64-bit long's): +# CF = $(CFLAGS) -64 +# F77FLAGS = -64 + +# SGI doesn't have ranlib +# RANLIB = echo + +#------------------------------------------------------------------------------ +# AMD Opteron (64 bit) +#------------------------------------------------------------------------------ + +# BLAS = -lgoto_opteron64 -lg2c +# LAPACK = -llapack_opteron64 + +# SUSE Linux 10.1, AMD Opteron +# F77 = gfortran +# BLAS = -lgoto_opteron64 -lgfortran +# LAPACK = -llapack_opteron64 + +#------------------------------------------------------------------------------ +# remove object files and profile output +#------------------------------------------------------------------------------ + +CLEAN = *.o *.obj *.ln *.bb *.bbg *.da *.tcov *.gcov gmon.out *.bak *.d *.gcda *.gcno diff --git a/pkgs/development/libraries/science/math/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/default.nix new file mode 100644 index 00000000000..add4ca9a08f --- /dev/null +++ b/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -0,0 +1,58 @@ +{ stdenv, fetchurl, substituteAll +, atlasWithLapack, gfortran }: + +let + name = "suitesparse-4.4.1"; +in +stdenv.mkDerivation { + inherit name; + + src = fetchurl { + url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.4.1.tar.gz"; + sha256 = "0y8i6dizrr556xggpjyc7wijjv4jbizhssmjj4jv8n1s7zxy2z0n"; + }; + + patches = [ + ./0001-disable-metis.patch + ./0002-set-install-dir.patch + (substituteAll { + src = ./0003-blas-lapack-flags.patch; + blasFlags = "-lf77blas -latlas -lcblas -lgfortran"; + lapackFlags= "-llapack -latlas -lcblas"; + }) + ]; + + preConfigure = '' + substituteAllInPlace SuiteSparse_config/SuiteSparse_config.mk + mkdir -p $out/lib + mkdir -p $out/include + ''; + + postInstall = '' + # 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 = [ atlasWithLapack ]; + + meta = with stdenv.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 ]; + }; +} diff --git a/pkgs/development/libraries/suitesparse/disable-metis.patch b/pkgs/development/libraries/science/math/suitesparse/disable-metis.patch similarity index 100% rename from pkgs/development/libraries/suitesparse/disable-metis.patch rename to pkgs/development/libraries/science/math/suitesparse/disable-metis.patch diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bf0a029532a..71868190742 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3499,13 +3499,14 @@ let liblapack = liblapack.override {shared = true;}; llvm = llvm_33; openblas = openblas_0_2_2; + suitesparse = suitesparse_4_2; }; julia033 = let liblapack = liblapack_3_5_0.override {shared = true;}; in callPackage ../development/compilers/julia/0.3.3.nix { inherit liblapack; - suitesparse = suitesparse.override { + suitesparse = suitesparse_4_2.override { inherit liblapack; }; llvm = llvm_33; @@ -6981,8 +6982,6 @@ let suil = callPackage ../development/libraries/audio/suil { }; - suitesparse = callPackage ../development/libraries/suitesparse { }; - sutils = callPackage ../tools/misc/sutils { }; sword = callPackage ../development/libraries/sword { }; @@ -12211,6 +12210,9 @@ let sage = callPackage ../applications/science/math/sage { }; + suitesparse_4_2 = callPackage ../development/libraries/science/math/suitesparse/4.2.nix { }; + suitesparse_4_4_1 = callPackage ../development/libraries/science/math/suitesparse {}; + ipopt = callPackage ../development/libraries/science/math/ipopt { }; ### SCIENCE/MOLECULAR-DYNAMICS