Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suitesparse: 5.4.0 → 5.7.1 + clean up #82274

Merged
merged 7 commits into from
Mar 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkgs/development/libraries/science/math/mongoose/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{ 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 stdenv.lib; {
description = "Graph Coarsening and Partitioning Library";
homepage = "https://github.com/ScottKolo/Mongoose";
license = licenses.gpl3;
maintainers = with maintainers; [];
platforms = with platforms; unix;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ stdenv
, fetchFromGitHub
, cmake
, gnum4
}:

stdenv.mkDerivation rec {
pname = "suitesparse-graphblas";
version = "3.2.1";

outputs = [ "out" "dev" ];

src = fetchFromGitHub {
owner = "DrTimothyAldenDavis";
repo = "GraphBLAS";
rev = "v${version}";
sha256 = "AAwwzrpKFHy40Ldm6hTO6L0FWPYwi3kJj3zrshFwYas=";
};

nativeBuildInputs = [
cmake
gnum4
];

meta = with stdenv.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;
};
}
155 changes: 53 additions & 102 deletions pkgs/development/libraries/science/math/suitesparse/default.nix
Original file line number Diff line number Diff line change
@@ -1,96 +1,65 @@
{ stdenv, fetchurl, gfortran, openblas, cmake, fixDarwinDylibNames
{ stdenv
, fetchFromGitHub
, gfortran
, openblas
, metis
, fixDarwinDylibNames
, gnum4
, enableCuda ? false, cudatoolkit
, enableCuda ? false
, cudatoolkit
}:

let
version = "5.4.0";
name = "suitesparse-${version}";

SHLIB_EXT = stdenv.hostPlatform.extensions.sharedLibrary;
in
stdenv.mkDerivation rec {
inherit name;

src = fetchurl {
url = "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-${version}.tar.gz";
sha256 = "1lfvjj787yqyhk25w7brlrkrl7dnnn5dq4ijxws3wrbcd4vd2k9p";
};
pname = "suitesparse";
version = "5.7.1";

dontUseCmakeConfigure = true;
outputs = [ "out" "dev" "doc" ];

preConfigure = ''
mkdir -p $out/lib
mkdir -p $out/include
mkdir -p $out/share/doc/${name}

sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
-e 's/METIS .*$/METIS =/' \
-e 's/METIS_PATH .*$/METIS_PATH =/' \
-e '/CHOLMOD_CONFIG/ s/$/-DNPARTITION/'
''
+ stdenv.lib.optionalString stdenv.isDarwin ''
sed -i "SuiteSparse_config/SuiteSparse_config.mk" \
-e 's/^[[:space:]]*\(LIB = -lm\) -lrt/\1/'
''
+ stdenv.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|'
'';

NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin " -DNTIMER";

buildPhase = ''
runHook preBuild
src = fetchFromGitHub {
owner = "DrTimothyAldenDavis";
repo = "SuiteSparse";
rev = "v${version}";
sha256 = "SA9SQKRDKUI1GilNMuCXljcvovLUwRKBUi/tiQ4dl5w=";
};

# Build individual shared libraries
make library \
JOBS=$NIX_BUILD_CORES \
BLAS=-lopenblas \
LAPACK="" \
${stdenv.lib.optionalString openblas.blas64 "CFLAGS=-DBLAS64"}
nativeBuildInputs = [
gnum4
] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

# Build libsuitesparse.so which bundles all the individual libraries.
# Bundling is done by building the static libraries, extracting objects from
# them and combining the objects into one shared library.
mkdir -p static
make static JOBS=$NIX_BUILD_CORES AR_TARGET=$(pwd)/static/'$(LIBRARY).a'
(
cd static
for i in lib*.a; do
ar -x $i
done
)
${if enableCuda then "${cudatoolkit}/bin/nvcc" else "${stdenv.cc.outPath}/bin/cc"} \
static/*.o \
${if stdenv.isDarwin then "-dynamiclib" else "--shared"} \
-o "lib/libsuitesparse${SHLIB_EXT}" \
-lopenblas \
${stdenv.lib.optionalString enableCuda "-lcublas"}
buildInputs = [
openblas
metis
gfortran.cc.lib
] ++ stdenv.lib.optional enableCuda cudatoolkit;

runHook postBuild
preConfigure = ''
# Mongoose and GraphBLAS are packaged separately
sed -i "Makefile" -e '/GraphBLAS\|Mongoose/d'
'';

installPhase = ''
runHook preInstall

mkdir -p $out
cp -r lib $out/
cp -r include $out/
cp -r share $out/
''
+ stdenv.lib.optionalString stdenv.isDarwin ''
makeFlags = [
"INSTALL=${placeholder "out"}"
"INSTALL_INCLUDE=${placeholder "dev"}/include"
"JOBS=$(NIX_BUILD_CORES)"
"BLAS=-lopenblas"
"MY_METIS_LIB=-lmetis"
"LAPACK="
] ++ stdenv.lib.optionals openblas.blas64 [
"CFLAGS=-DBLAS64"
] ++ stdenv.lib.optionals enableCuda [
"CUDA_PATH=${cudatoolkit}"
"CUDART_LIB=${cudatoolkit.lib}/lib/libcudart.so"
"CUBLAS_LIB=${cudatoolkit}/lib/libcublas.so"
];

buildFlags = [
# Build individual shared libraries, not demos
"library"
];

# Likely fixed after 5.7.1
# https://github.com/DrTimothyAldenDavis/SuiteSparse/commit/f6daae26ee391e475e2295e77c839aa7c1a8b784
postInstall = stdenv.lib.optionalString stdenv.isDarwin ''
# The fixDarwinDylibNames in nixpkgs can't seem to fix all the libraries.
# We manually fix them up here.
fixDarwinDylibNames() {
Expand All @@ -109,28 +78,10 @@ stdenv.mkDerivation rec {
}

fixDarwinDylibNames $(find "$out" -name "*.dylib")
''
+ stdenv.lib.optionalString (!stdenv.isDarwin) ''
# Fix rpaths
cd $out
find -name \*.so\* -type f -exec \
patchelf --set-rpath "$out/lib:${stdenv.lib.makeLibraryPath buildInputs}" {} \;
''
+
''
runHook postInstall
'';

nativeBuildInputs = [
cmake
gnum4
] ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames;

buildInputs = [ openblas gfortran.cc.lib ]
++ stdenv.lib.optional enableCuda cudatoolkit;
'';

meta = with stdenv.lib; {
homepage = http://faculty.cse.tamu.edu/davis/suitesparse.html;
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 ];
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/python-modules/cvxopt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ buildPythonPackage rec {
export CVXOPT_BLAS_LIB_DIR=${openblasCompat}/lib
export CVXOPT_BLAS_LIB=openblas
export CVXOPT_LAPACK_LIB=openblas
export CVXOPT_SUITESPARSE_LIB_DIR=${suitesparse}/lib
export CVXOPT_SUITESPARSE_INC_DIR=${suitesparse}/include
export CVXOPT_SUITESPARSE_LIB_DIR=${lib.getLib suitesparse}/lib
export CVXOPT_SUITESPARSE_INC_DIR=${lib.getDev suitesparse}/include
'' + lib.optionalString withGsl ''
export CVXOPT_BUILD_GSL=1
export CVXOPT_GSL_LIB_DIR=${gsl}/lib
Expand Down
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24308,6 +24308,8 @@ in
suitesparse_5_3 = callPackage ../development/libraries/science/math/suitesparse {};
suitesparse = suitesparse_5_3;

suitesparse-graphblas = callPackage ../development/libraries/science/math/suitesparse-graphblas {};

superlu = callPackage ../development/libraries/science/math/superlu {};

symmetrica = callPackage ../applications/science/math/symmetrica {};
Expand Down Expand Up @@ -25152,6 +25154,8 @@ in

mongoc = callPackage ../development/libraries/mongoc { };

mongoose = callPackage ../development/libraries/science/math/mongoose {};

morph = callPackage ../tools/package-management/morph { };

mupen64plus = callPackage ../misc/emulators/mupen64plus { };
Expand Down