From 6f721ce534d18730a29e3b632274ed11e20b42fd Mon Sep 17 00:00:00 2001 From: Matthew Daiter Date: Wed, 29 Mar 2017 15:47:51 +0200 Subject: [PATCH] suitesparse: add CUDA support --- .../science/math/suitesparse/default.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/science/math/suitesparse/default.nix b/pkgs/development/libraries/science/math/suitesparse/default.nix index 99f54cebddd1..10fc7bf10ac7 100644 --- a/pkgs/development/libraries/science/math/suitesparse/default.nix +++ b/pkgs/development/libraries/science/math/suitesparse/default.nix @@ -1,4 +1,6 @@ -{ stdenv, fetchurl, gfortran, openblas }: +{ stdenv, fetchurl, gfortran, openblas +, enableCuda ? false, cudatoolkit +}: let version = "4.4.4"; @@ -28,6 +30,21 @@ stdenv.mkDerivation { + 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:]]*\(NV_20 =\)|NV_20 = -arch=sm_20 -Xcompiler -fPIC|' \ + -e 's|^[[:space:]]*\(NV_30 =\)|NV_30 = -arch=sm_30 -Xcompiler -fPIC|' \ + -e 's|^[[:space:]]*\(NV_35 =\)|NV_35 = -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 = [