Skip to content

Commit 2cd73af

Browse files
[AUTOGENERATED] [release/2.8] [SWDEV-554101] Fix bad merge of install_rocm_magma.sh (#2687)
Cherry-pick of #2651 Wheel build job: http://rocm-ci.amd.com/job/mainline-pytorch2.8-manylinux-wheels/225/ --------- Co-authored-by: Prachi Gupta <[email protected]>
1 parent 245bf6e commit 2cd73af

File tree

1 file changed

+31
-54
lines changed

1 file changed

+31
-54
lines changed
Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,37 @@
1-
#!/bin/bash
2-
# Script used in CI and CD pipeline
1+
#!/usr/bin/env bash
2+
# Script used only in CD pipeline
33

4-
set -ex
4+
set -eou pipefail
55

6-
ver() {
7-
printf "%3d%03d%03d%03d" $(echo "$1" | tr '.' ' ');
8-
}
9-
10-
# Magma build scripts need `python`
11-
ln -sf /usr/bin/python3 /usr/bin/python
12-
13-
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
14-
case "$ID" in
15-
almalinux)
16-
yum install -y gcc-gfortran
17-
;;
18-
*)
19-
echo "No preinstalls to build magma..."
20-
;;
21-
esac
6+
function do_install() {
7+
rocm_version=$1
8+
if [[ ${rocm_version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
9+
# chop off any patch version
10+
rocm_version="${rocm_version%.*}"
11+
fi
2212

23-
MKLROOT=${MKLROOT:-/opt/conda/envs/py_$ANACONDA_PYTHON_VERSION}
13+
rocm_version_nodot=${rocm_version//./}
2414

25-
# "install" hipMAGMA into /opt/rocm/magma by copying after build
26-
if [[ $(ver $ROCM_VERSION) -ge $(ver 7.0) ]]; then
27-
git clone https://github.com/ROCm/utk-magma.git -b release/2.9.0_rocm70 magma
28-
pushd magma
29-
# version 2.9 + ROCm 7.0 related updates
30-
git checkout 91c4f720a17e842b364e9de41edeef76995eb9ad
31-
else
32-
git clone https://bitbucket.org/icl/magma.git
33-
pushd magma
3415
# Version 2.7.2 + ROCm related updates
35-
git checkout a1625ff4d9bc362906bd01f805dbbe12612953f6
36-
fi
16+
MAGMA_VERSION=a1625ff4d9bc362906bd01f805dbbe12612953f6
17+
magma_archive="magma-rocm${rocm_version_nodot}-${MAGMA_VERSION}-1.tar.bz2"
18+
19+
rocm_dir="/opt/rocm"
20+
(
21+
set -x
22+
tmp_dir=$(mktemp -d)
23+
pushd ${tmp_dir}
24+
curl -OLs https://ossci-linux.s3.us-east-1.amazonaws.com/${magma_archive}
25+
if tar -xvf "${magma_archive}"
26+
then
27+
mkdir -p "${rocm_dir}/magma"
28+
mv include "${rocm_dir}/magma/include"
29+
mv lib "${rocm_dir}/magma/lib"
30+
else
31+
echo "${magma_archive} not found, skipping magma install"
32+
fi
33+
popd
34+
)
35+
}
3736

38-
cp make.inc-examples/make.inc.hip-gcc-mkl make.inc
39-
echo 'LIBDIR += -L$(MKLROOT)/lib' >> make.inc
40-
if [[ -f "${MKLROOT}/lib/libmkl_core.a" ]]; then
41-
echo 'LIB = -Wl,--start-group -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -Wl,--end-group -lpthread -lstdc++ -lm -lgomp -lhipblas -lhipsparse' >> make.inc
42-
fi
43-
echo 'LIB += -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib -Wl,--rpath,$(MKLROOT)/lib -Wl,--rpath,/opt/rocm/magma/lib -ldl' >> make.inc
44-
echo 'DEVCCFLAGS += --gpu-max-threads-per-block=256' >> make.inc
45-
export PATH="${PATH}:/opt/rocm/bin"
46-
if [[ -n "$PYTORCH_ROCM_ARCH" ]]; then
47-
amdgpu_targets=`echo $PYTORCH_ROCM_ARCH | sed 's/;/ /g'`
48-
else
49-
amdgpu_targets=`rocm_agent_enumerator | grep -v gfx000 | sort -u | xargs`
50-
fi
51-
for arch in $amdgpu_targets; do
52-
echo "DEVCCFLAGS += --offload-arch=$arch" >> make.inc
53-
done
54-
# hipcc with openmp flag may cause isnan() on __device__ not to be found; depending on context, compiler may attempt to match with host definition
55-
sed -i 's/^FOPENMP/#FOPENMP/g' make.inc
56-
make -f make.gen.hipMAGMA -j $(nproc)
57-
LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}"
58-
make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}"
59-
popd
60-
mv magma /opt/rocm
37+
do_install $1

0 commit comments

Comments
 (0)