Skip to content

Commit b8fa48c

Browse files
authored
MAGMA: update to v2.9.0 (#11237)
* MAGMA: update to v2.9.0 * Add CUDA 12.9 redist * MAGMA: try to fix aarch64 build * MAGMA: new tentative fix for the aarch64 build * MAGMA: fix linking path and magma_devptr_t * MAGMA: more drastic approach for magma_devptr_t on aarch64 * MAGMA: cleanup cuda on x86_64 too * MAGMA: expand sm support * MAGMA: attempt at faster CI builds * MAGMA: try to fix large lib linking step
1 parent 46994f9 commit b8fa48c

File tree

2 files changed

+65
-19
lines changed

2 files changed

+65
-19
lines changed

M/MAGMA/build_tarballs.jl

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,73 @@ include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl"))
77
include(joinpath(YGGDRASIL_DIR, "platforms", "cuda.jl"))
88

99
name = "MAGMA"
10-
version = v"2.7.0"
10+
version = v"2.9.0"
11+
12+
# Note: Hopper should still build with CUDA v11.8
13+
# on x86_64, but aarch64 requires CUDA v12.0
14+
MIN_CUDA_VERSION = v"12"
1115

1216
# Collection of sources required to complete build
1317
sources = [
1418
ArchiveSource("http://icl.utk.edu/projectsfiles/magma/downloads/magma-$(version).tar.gz",
15-
"fda1cbc4607e77cacd8feb1c0f633c5826ba200a018f647f1c5436975b39fd18"),
19+
"ff77fd3726b3dfec3bfb55790b06480aa5cc384396c2db35c56fdae4a82c641c"),
1620
DirectorySource("./bundled")
1721
]
1822

1923
# Bash recipe for building across all platforms
2024
script = raw"""
21-
cd $WORKSPACE/srcdir/magma*
25+
cd $WORKSPACE/srcdir
26+
27+
export TMPDIR=${WORKSPACE}/tmpdir # we need a lot of tmp space
28+
mkdir -p ${TMPDIR}
29+
30+
PTROPT=""
31+
32+
# Necessary operations to cross compile CUDA from x86_64 to aarch64
33+
if [[ "${target}" == aarch64-linux-* ]]; then
34+
35+
# Add /usr/lib/csl-musl-x86_64 to LD_LIBRARY_PATH to be able to use host nvcc
36+
export LD_LIBRARY_PATH="/usr/lib/csl-musl-x86_64:/usr/lib/csl-glibc-x86_64:${LD_LIBRARY_PATH}"
37+
38+
# Make sure we use host CUDA executable by copying from the x86_64 CUDA redist
39+
NVCC_DIR=(/workspace/srcdir/cuda_nvcc-*-archive)
40+
rm -rf ${prefix}/cuda/bin
41+
cp -r ${NVCC_DIR}/bin ${prefix}/cuda/bin
42+
43+
rm -rf ${prefix}/cuda/nvvm/bin
44+
cp -r ${NVCC_DIR}/nvvm/bin ${prefix}/cuda/nvvm/bin
45+
46+
# Workaround failed execution of sizeptr in cross-compile builds
47+
PTROPT="PTRSIZE=8"
48+
fi
49+
50+
export CUDADIR=${prefix}/cuda
51+
export PATH=${PATH}:${CUDADIR}/bin
52+
export CUDACXX=${CUDADIR}/bin/nvcc
53+
54+
# This flag reduces the size of the compiled binaries; if
55+
# they become over 2GB (e.g. due to targeting too many
56+
# compute_XX), linking fails.
57+
# See: https://github.com/NixOS/nixpkgs/pull/220402
58+
export NVCC_PREPEND_FLAGS+=' -Xfatbin=-compress-all'
2259
23-
export CUDADIR=${WORKSPACE}/destdir/cuda
24-
export PATH=${PATH}:${CUDADIR}
60+
cd magma*
2561
cp ../make.inc .
62+
2663
# Patch to _64_ suffixes
2764
atomic_patch -p1 ../0001-mangle-to-ILP64.patch
28-
# reduce parallelism since otherwise the builder may OOM.
29-
(( nproc=1+nproc/3 ))
30-
make -j${nproc} sparse-shared
31-
make install prefix=${prefix}
65+
66+
make ${PTROPT} -j${nproc} sparse-shared
67+
make ${PTROPT} install prefix=${prefix}
68+
3269
install_license COPYRIGHT
33-
"""
3470
35-
augment_platform_block = CUDA.augment
71+
# ensure products directory is clean
72+
rm -rf ${CUDADIR}
73+
"""
3674

37-
platforms = CUDA.supported_platforms()
38-
filter!(p -> arch(p) == "x86_64", platforms)
75+
platforms = CUDA.supported_platforms(min_version = MIN_CUDA_VERSION)
76+
filter!(p -> arch(p) == "x86_64" || arch(p) == "aarch64", platforms)
3977
platforms = expand_cxxstring_abis(platforms)
4078

4179

@@ -56,10 +94,18 @@ for platform in platforms
5694

5795
cuda_deps = CUDA.required_dependencies(platform)
5896

59-
build_tarballs(ARGS, name, version, sources, script, [platform],
97+
cuda_ver = platform["cuda"]
98+
99+
platform_sources = BinaryBuilder.AbstractSource[sources...]
100+
101+
if arch(platform) == "aarch64"
102+
push!(platform_sources, CUDA.cuda_nvcc_redist_source(cuda_ver, "x86_64"))
103+
end
104+
105+
build_tarballs(ARGS, name, version, platform_sources, script, [platform],
60106
products, [dependencies; cuda_deps];
61107
preferred_gcc_version=v"8",
62108
julia_compat="1.8",
63-
augment_platform_block,
109+
augment_platform_block=CUDA.augment,
64110
skip_audit=true, dont_dlopen=true)
65111
end

M/MAGMA/bundled/make.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#//////////////////////////////////////////////////////////////////////////////
2-
# -- MAGMA (version 2.0) --
2+
# -- MAGMA (version 2.x) --
33
# Univ. of Tennessee, Knoxville
44
# Univ. of California, Berkeley
55
# Univ. of Colorado, Denver
@@ -52,9 +52,9 @@ RANLIB = ranlib
5252

5353
# set our GPU targets
5454
ifeq ($(BACKEND),cuda)
55-
GPU_TARGET = Pascal Volta Turing Ampere
55+
GPU_TARGET = Pascal sm_61 Volta Turing Ampere sm_86 Ada Hopper
5656
else ifeq ($(BACKEND),hip)
57-
GPU_TARGET = gfx900 gfx901
57+
GPU_TARGET = gfx900 gfx902 gfx904 gfx906 gfx908 gfx909 gfx90a gfx940 gfx941 gfx942 gfx90c gfx1010 gfx1011 gfx1012 gfx1030 gfx1031 gfx1032 gfx1033
5858
endif
5959

6060
# Use -fPIC to make shared (.so) and static (.a) library;
@@ -112,7 +112,7 @@ ifeq ($(BACKEND),cuda)
112112
DEVCCFLAGS += -Xcompiler "$(FPIC)" -std=c++11
113113

114114
# link with cuda specific libraries
115-
LIB += -L$(CUDADIR)/lib64 -lcublas -lcusparse -lcudart -lcudadevrt
115+
LIB += -L$(CUDADIR)/lib64 -L$(CUDADIR)/lib -lcublas -lcusparse -lcudart -lcudadevrt
116116
INC += -I$(CUDADIR)/include
117117

118118
endif

0 commit comments

Comments
 (0)