magma: only 2.7.1+ support CUDA 12

This commit is contained in:
Connor Baker 2024-03-16 00:18:24 +00:00
parent 2ea3d6fc9b
commit bdfe55c4a8

View file

@ -8,11 +8,11 @@
{ autoPatchelfHook { autoPatchelfHook
, blas , blas
, cmake , cmake
, cudaPackages_11 ? null
, cudaPackages , cudaPackages
, cudaSupport ? config.cudaSupport , cudaSupport ? config.cudaSupport
, fetchurl , fetchurl
, gfortran , gfortran
, cudaCapabilities ? cudaPackages.cudaFlags.cudaCapabilities
, gpuTargets ? [ ] # Non-CUDA targets, that is HIP , gpuTargets ? [ ] # Non-CUDA targets, that is HIP
, rocmPackages , rocmPackages
, lapack , lapack
@ -32,9 +32,18 @@
let let
inherit (lib) lists strings trivial; inherit (lib) lists strings trivial;
inherit (cudaPackages) cudaAtLeast cudaFlags cudaOlder;
inherit (magmaRelease) version hash supportedGpuTargets; inherit (magmaRelease) version hash supportedGpuTargets;
# Per https://icl.utk.edu/magma/downloads, support for CUDA 12 wasn't added until 2.7.1.
# If we're building a version prior to that, use the latest release of the 11.x series.
effectiveCudaPackages =
if strings.versionOlder version "2.7.1"
then cudaPackages_11
else cudaPackages;
inherit (effectiveCudaPackages) cudaAtLeast cudaFlags cudaOlder;
inherit (cudaFlags) cudaCapabilities;
# NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements # NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements
# of the first list *from* the second list. That means: # of the first list *from* the second list. That means:
# lists.subtractLists a b = b - a # lists.subtractLists a b = b - a
@ -115,7 +124,7 @@ stdenv.mkDerivation {
ninja ninja
gfortran gfortran
] ++ lists.optionals cudaSupport [ ] ++ lists.optionals cudaSupport [
cudaPackages.cuda_nvcc effectiveCudaPackages.cuda_nvcc
]; ];
buildInputs = [ buildInputs = [
@ -123,7 +132,7 @@ stdenv.mkDerivation {
lapack lapack
blas blas
python3 python3
] ++ lists.optionals cudaSupport (with cudaPackages; [ ] ++ lists.optionals cudaSupport (with effectiveCudaPackages; [
cuda_cudart.dev # cuda_runtime.h cuda_cudart.dev # cuda_runtime.h
cuda_cudart.lib # cudart cuda_cudart.lib # cudart
cuda_cudart.static # cudart_static cuda_cudart.static # cudart_static
@ -173,6 +182,7 @@ stdenv.mkDerivation {
# TODO(@connorbaker): This should be handled by having CMakeLists.txt install them, but such a patch is # TODO(@connorbaker): This should be handled by having CMakeLists.txt install them, but such a patch is
# out of the scope of the PR which introduces the `test` output: https://github.com/NixOS/nixpkgs/pull/283777. # out of the scope of the PR which introduces the `test` output: https://github.com/NixOS/nixpkgs/pull/283777.
# See https://github.com/NixOS/nixpkgs/pull/283777#discussion_r1482125034 for more information. # See https://github.com/NixOS/nixpkgs/pull/283777#discussion_r1482125034 for more information.
# Such work is tracked by https://github.com/NixOS/nixpkgs/issues/296286.
'' ''
install -Dm755 ../testing/run_{tests,summarize}.py -t "$test/bin/" install -Dm755 ../testing/run_{tests,summarize}.py -t "$test/bin/"
'' ''
@ -196,7 +206,8 @@ stdenv.mkDerivation {
''; '';
passthru = { passthru = {
inherit cudaPackages cudaSupport rocmSupport gpuTargets; inherit cudaSupport rocmSupport gpuTargets;
cudaPackages = effectiveCudaPackages;
}; };
meta = with lib; { meta = with lib; {
@ -210,6 +221,7 @@ stdenv.mkDerivation {
broken = broken =
!(cudaSupport || rocmSupport) # At least one back-end enabled !(cudaSupport || rocmSupport) # At least one back-end enabled
|| (cudaSupport && rocmSupport) # Mutually exclusive || (cudaSupport && rocmSupport) # Mutually exclusive
|| (cudaSupport && cudaOlder "9.0"); || (cudaSupport && cudaOlder "9.0")
|| (cudaSupport && strings.versionOlder version "2.7.1" && cudaPackages_11 == null);
}; };
} }