|
1 | | -#!/bin/bash |
2 | | -# Script used in CI and CD pipeline |
| 1 | +#!/usr/bin/env bash |
| 2 | +# Script used only in CD pipeline |
3 | 3 |
|
4 | | -set -ex |
| 4 | +set -eou pipefail |
5 | 5 |
|
6 | | -# Magma build scripts need `python` |
7 | | -ln -sf /usr/bin/python3 /usr/bin/python |
| 6 | +function do_install() { |
| 7 | + rocm_version=$1 |
| 8 | + rocm_version_nodot=${1//./} |
8 | 9 |
|
9 | | -ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"') |
10 | | -case "$ID" in |
11 | | - almalinux) |
12 | | - yum install -y gcc-gfortran |
13 | | - ;; |
14 | | - *) |
15 | | - echo "No preinstalls to build magma..." |
16 | | - ;; |
17 | | -esac |
| 10 | + # Version 2.7.2 + ROCm related updates |
| 11 | + MAGMA_VERSION=a1625ff4d9bc362906bd01f805dbbe12612953f6 |
| 12 | + magma_archive="magma-rocm${rocm_version_nodot}-${MAGMA_VERSION}-1.tar.bz2" |
18 | 13 |
|
19 | | -MKLROOT=${MKLROOT:-/opt/conda/envs/py_$ANACONDA_PYTHON_VERSION} |
| 14 | + rocm_dir="/opt/rocm" |
| 15 | + ( |
| 16 | + set -x |
| 17 | + tmp_dir=$(mktemp -d) |
| 18 | + pushd ${tmp_dir} |
| 19 | + curl -OLs https://ossci-linux.s3.us-east-1.amazonaws.com/${magma_archive} |
| 20 | + tar -xvf "${magma_archive}" |
| 21 | + mkdir -p "${rocm_dir}/magma" |
| 22 | + mv include "${rocm_dir}/magma/include" |
| 23 | + mv lib "${rocm_dir}/magma/lib" |
| 24 | + popd |
| 25 | + ) |
| 26 | +} |
20 | 27 |
|
21 | | -# "install" hipMAGMA into /opt/rocm/magma by copying after build |
22 | | -git clone https://bitbucket.org/icl/magma.git |
23 | | -pushd magma |
24 | | - |
25 | | -# Version 2.7.2 + ROCm related updates |
26 | | -git checkout a1625ff4d9bc362906bd01f805dbbe12612953f6 |
27 | | - |
28 | | -cp make.inc-examples/make.inc.hip-gcc-mkl make.inc |
29 | | -echo 'LIBDIR += -L$(MKLROOT)/lib' >> make.inc |
30 | | -if [[ -f "${MKLROOT}/lib/libmkl_core.a" ]]; then |
31 | | - echo 'LIB = -Wl,--start-group -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -Wl,--end-group -lpthread -lstdc++ -lm -lgomp -lhipblas -lhipsparse' >> make.inc |
32 | | -fi |
33 | | -echo 'LIB += -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib -Wl,--rpath,$(MKLROOT)/lib -Wl,--rpath,/opt/rocm/magma/lib -ldl' >> make.inc |
34 | | -echo 'DEVCCFLAGS += --gpu-max-threads-per-block=256' >> make.inc |
35 | | -export PATH="${PATH}:/opt/rocm/bin" |
36 | | -if [[ -n "$PYTORCH_ROCM_ARCH" ]]; then |
37 | | - amdgpu_targets=`echo $PYTORCH_ROCM_ARCH | sed 's/;/ /g'` |
38 | | -else |
39 | | - amdgpu_targets=`rocm_agent_enumerator | grep -v gfx000 | sort -u | xargs` |
40 | | -fi |
41 | | -for arch in $amdgpu_targets; do |
42 | | - echo "DEVCCFLAGS += --offload-arch=$arch" >> make.inc |
43 | | -done |
44 | | -# hipcc with openmp flag may cause isnan() on __device__ not to be found; depending on context, compiler may attempt to match with host definition |
45 | | -sed -i 's/^FOPENMP/#FOPENMP/g' make.inc |
46 | | -make -f make.gen.hipMAGMA -j $(nproc) |
47 | | -LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}" |
48 | | -make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}" |
49 | | -popd |
50 | | -mv magma /opt/rocm |
| 28 | +do_install $1 |
0 commit comments