Merge pull request #220366 from ConnorBaker/feat/magma-split-out-cuda-nativeBuildInputs
magma: fix #220343 and separate CUDA build/run-time dependencies
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
|
||||
let
|
||||
inherit (lib) lists strings trivial;
|
||||
inherit (cudaPackages) cudatoolkit cudaFlags cudaVersion;
|
||||
inherit (cudaPackages) backendStdenv cudaFlags cudaVersion;
|
||||
inherit (magmaRelease) version hash supportedGpuTargets;
|
||||
|
||||
# NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements
|
||||
@@ -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
|
||||
|
||||
@@ -119,6 +126,8 @@ stdenv.mkDerivation {
|
||||
cmake
|
||||
ninja
|
||||
gfortran
|
||||
] ++ lists.optionals cudaSupport [
|
||||
cuda-native-redist
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
@@ -126,7 +135,7 @@ stdenv.mkDerivation {
|
||||
lapack
|
||||
blas
|
||||
] ++ lists.optionals cudaSupport [
|
||||
cuda_joined
|
||||
cuda-redist
|
||||
] ++ lists.optionals rocmSupport [
|
||||
hip
|
||||
hipblas
|
||||
@@ -139,8 +148,8 @@ stdenv.mkDerivation {
|
||||
] ++ lists.optionals cudaSupport [
|
||||
"-DCMAKE_CUDA_ARCHITECTURES=${cudaArchitecturesString}"
|
||||
"-DMIN_ARCH=${minArch}" # Disarms magma's asserts
|
||||
"-DCMAKE_C_COMPILER=${cudatoolkit.cc}/bin/cc"
|
||||
"-DCMAKE_CXX_COMPILER=${cudatoolkit.cc}/bin/c++"
|
||||
"-DCMAKE_C_COMPILER=${backendStdenv.cc}/bin/cc"
|
||||
"-DCMAKE_CXX_COMPILER=${backendStdenv.cc}/bin/c++"
|
||||
"-DMAGMA_ENABLE_CUDA=ON"
|
||||
] ++ lists.optionals rocmSupport [
|
||||
"-DCMAKE_C_COMPILER=${hip}/bin/hipcc"
|
||||
@@ -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"
|
||||
@@ -171,7 +173,7 @@ stdenv.mkDerivation {
|
||||
license = licenses.bsd3;
|
||||
homepage = "http://icl.cs.utk.edu/magma/index.html";
|
||||
platforms = platforms.unix;
|
||||
maintainers = with maintainers; [ tbenst ];
|
||||
maintainers = with maintainers; [ connorbaker ];
|
||||
# CUDA and ROCm are mutually exclusive
|
||||
broken = cudaSupport && rocmSupport || cudaSupport && strings.versionOlder cudaVersion "9";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user