magma: 2.7.2 -> 2.9.0 (#382904)

This commit is contained in:
Pavol Rusnak
2025-02-21 10:47:56 +01:00
committed by GitHub
2 changed files with 78 additions and 24 deletions
@@ -13,9 +13,11 @@
cudaPackages,
cudaSupport ? config.cudaSupport,
fetchurl,
fetchpatch,
gfortran,
gpuTargets ? [ ], # Non-CUDA targets, that is HIP
rocmPackages_5,
rocmPackages_5 ? null,
rocmPackages,
lapack,
lib,
libpthreadstubs,
@@ -46,8 +48,8 @@ let
inherit (effectiveCudaPackages) cudaAtLeast flags cudaOlder;
# move to newer ROCm version once supported
rocmPackages = rocmPackages_5;
effectiveRocmPackages =
if strings.versionOlder version "2.8.0" then rocmPackages_5 else rocmPackages;
# NOTE: The lists.subtractLists function is perhaps a bit unintuitive. It subtracts the elements
# of the first list *from* the second list. That means:
@@ -57,7 +59,7 @@ let
# NOTE: The hip.gpuTargets are prefixed with "gfx" instead of "sm" like flags.realArches.
# For some reason, Magma's CMakeLists.txt file does not handle the "gfx" prefix, so we must
# remove it.
rocmArches = lists.map (x: strings.removePrefix "gfx" x) rocmPackages.clr.gpuTargets;
rocmArches = lists.map (x: strings.removePrefix "gfx" x) effectiveRocmPackages.clr.gpuTargets;
supportedRocmArches = lists.intersectLists rocmArches supportedGpuTargets;
unsupportedRocmArches = lists.subtractLists supportedRocmArches rocmArches;
@@ -91,7 +93,7 @@ let
cudaArchitectures = (builtins.map flags.dropDot flags.cudaCapabilities);
minArch' = builtins.head (builtins.sort strings.versionOlder cudaArchitectures);
in
# "75" -> "750" Cf. https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-273
# "75" -> "750" Cf. https://github.com/icl-utk-edu/magma/blob/v2.9.0/CMakeLists.txt#L200-L201
"${minArch'}0";
in
@@ -115,14 +117,26 @@ stdenv.mkDerivation {
"test"
];
patches = lib.optionals (version == "2.9.0") [
# get ROCm version directly
# https://github.com/icl-utk-edu/magma/pull/27
(fetchpatch {
url = "https://github.com/icl-utk-edu/magma/commit/10fe816b763c41099fa1c978a79d6869246671cf.patch";
hash = "sha256-qSY5ACMHyHofJdQKyPqx8sI8GbPD6IZezmCd8qOS5OM=";
})
];
# Fixup for the python test runners
postPatch = ''
patchShebangs ./testing/run_{tests,summarize}.py
substituteInPlace ./testing/run_tests.py \
--replace-fail \
"print >>sys.stderr, cmdp, \"doesn't exist (original name: \" + cmd + \", precision: \" + precision + \")\"" \
"print(f\"{cmdp} doesn't exist (original name: {cmd}, precision: {precision})\", file=sys.stderr)"
'';
postPatch =
''
patchShebangs ./testing/run_{tests,summarize}.py
''
+ lib.optionalString (strings.versionOlder version "2.9.0") ''
substituteInPlace ./testing/run_tests.py \
--replace-fail \
"print >>sys.stderr, cmdp, \"doesn't exist (original name: \" + cmd + \", precision: \" + precision + \")\"" \
"print(f\"{cmdp} doesn't exist (original name: {cmd}, precision: {precision})\", file=sys.stderr)"
'';
nativeBuildInputs =
[
@@ -160,12 +174,15 @@ stdenv.mkDerivation {
cuda_cccl # <nv/target>
]
)
++ lists.optionals rocmSupport [
rocmPackages.clr
rocmPackages.hipblas
rocmPackages.hipsparse
rocmPackages.llvm.openmp
];
++ lists.optionals rocmSupport (
with effectiveRocmPackages;
[
clr
hipblas
hipsparse
llvm.openmp
]
);
cmakeFlags =
[
@@ -186,8 +203,8 @@ stdenv.mkDerivation {
(strings.cmakeFeature "MIN_ARCH" minArch) # Disarms magma's asserts
]
++ lists.optionals rocmSupport [
(strings.cmakeFeature "CMAKE_C_COMPILER" "${rocmPackages.clr}/bin/hipcc")
(strings.cmakeFeature "CMAKE_CXX_COMPILER" "${rocmPackages.clr}/bin/hipcc")
(strings.cmakeFeature "CMAKE_C_COMPILER" "${effectiveRocmPackages.clr}/bin/hipcc")
(strings.cmakeFeature "CMAKE_CXX_COMPILER" "${effectiveRocmPackages.clr}/bin/hipcc")
];
# Magma doesn't have a test suite we can easily run, just loose executables, all of which require a GPU.
@@ -230,7 +247,8 @@ stdenv.mkDerivation {
meta = with lib; {
description = "Matrix Algebra on GPU and Multicore Architectures";
license = licenses.bsd3;
homepage = "http://icl.cs.utk.edu/magma/index.html";
homepage = "https://icl.utk.edu/magma/";
changelog = "https://github.com/icl-utk-edu/magma/blob/v${version}/ReleaseNotes";
platforms = platforms.linux;
maintainers = with maintainers; [ connorbaker ];
@@ -240,7 +258,12 @@ stdenv.mkDerivation {
(cudaSupport && !static)
|| !(cudaSupport || rocmSupport) # At least one back-end enabled
|| (cudaSupport && rocmSupport) # Mutually exclusive
|| (cudaSupport && cudaOlder "9.0")
|| (cudaSupport && strings.versionOlder version "2.7.1" && cudaPackages_11 == null);
|| (cudaSupport && strings.versionOlder version "2.7.1" && cudaPackages_11 == null)
|| (rocmSupport && strings.versionOlder version "2.8.0" && rocmPackages_5 == null)
|| (
rocmSupport
&& strings.versionAtLeast version "2.8.0"
&& strings.versionOlder rocmPackages.clr.version "6.3"
);
};
}
@@ -1,7 +1,7 @@
# NOTE: Order matters! Put the oldest version first, and the newest version last.
# NOTE: Make sure the supportedGpuTargets are in order of oldest to newest.
# You can update the supportedGpuTargets by looking at the CMakeLists.txt file.
# HIP is here: https://bitbucket.org/icl/magma/src/f4ec79e2c13a2347eff8a77a3be6f83bc2daec20/CMakeLists.txt#lines-386
# HIP is here: https://github.com/icl-utk-edu/magma/blob/v2.9.0/CMakeLists.txt#L290
# CUDA works around magma's wrappers and uses FindCUDAToolkit directly
[
{
@@ -66,4 +66,35 @@
"1033"
];
}
{
version = "2.9.0";
hash = "sha256-/3f9Nyaz3+w7+1V5CwZICqXMOEOWwts1xW/a5KgsZBw=";
supportedGpuTargets = [
"700"
"701"
"702"
"703"
"704"
"705"
"801"
"802"
"803"
"805"
"810"
"900"
"902"
"904"
"906"
"908"
"909"
"90c"
"1010"
"1011"
"1012"
"1030"
"1031"
"1032"
"1033"
];
}
]