Skip to content

Commit

Permalink
magma: fix #220343 and separate CUDA build/run-time dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnorBaker committed Mar 13, 2023
1 parent 9e91539 commit 0cf4ddd
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions pkgs/development/libraries/science/math/magma/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,33 @@ let
cudaArchitecturesString = strings.concatStringsSep ";" cudaArchitectures;
minArch =
let
minArch' = builtins.head (builtins.sort builtins.lessThan cudaArchitectures);
minArch' = builtins.head (builtins.sort strings.versionOlder cudaArchitectures);
in
# If this fails some day, something must've changed and we should re-validate our assumptions
assert builtins.stringLength minArch' == 2;
# "75" -> "750" Cf. https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-273
"${minArch'}0";

cuda-common-redist = with cudaPackages; [
libcublas # cublas_v2.h
libcusparse # cusparse.h
];

cuda_joined = symlinkJoin {
name = "cuda-redist-${cudaVersion}";
# Build-time dependencies
cuda-native-redist = symlinkJoin {
name = "cuda-native-redist-${cudaVersion}";
paths = with cudaPackages; [
cuda_nvcc
cuda_cudart # cuda_runtime.h
libcublas
libcusparse
cuda_nvcc
] ++ lists.optionals (strings.versionOlder cudaVersion "11.8") [
cuda_nvprof # <cuda_profiler_api.h>
] ++ lists.optionals (strings.versionAtLeast cudaVersion "11.8") [
cuda_profiler_api # <cuda_profiler_api.h>
];
] ++ cuda-common-redist;
};

# Run-time dependencies
cuda-redist = symlinkJoin {
name = "cuda-redist-${cudaVersion}";
paths = cuda-common-redist;
};
in

Expand All @@ -119,14 +126,16 @@ stdenv.mkDerivation {
cmake
ninja
gfortran
] ++ lists.optionals cudaSupport [
cuda-native-redist
];

buildInputs = [
libpthreadstubs
lapack
blas
] ++ lists.optionals cudaSupport [
cuda_joined
cuda-redist
] ++ lists.optionals rocmSupport [
hip
hipblas
Expand All @@ -148,13 +157,6 @@ stdenv.mkDerivation {
"-DMAGMA_ENABLE_HIP=ON"
];

# NOTE: The stdenv's CXX is used when compiling the CMake test to determine the version of
# CUDA available. This isn't necessarily the same as cudatoolkit.cc, so we must set
# CUDAHOSTCXX.
preConfigure = strings.optionalString cudaSupport ''
export CUDAHOSTCXX=${cudatoolkit.cc}/bin/c++
'';

buildFlags = [
"magma"
"magma_sparse"
Expand Down

0 comments on commit 0cf4ddd

Please sign in to comment.