39 lines
1.5 KiB
Bash
Executable File
39 lines
1.5 KiB
Bash
Executable File
# Magma build scripts need `python`
|
|
ln -sf /usr/bin/python3 /usr/bin/python
|
|
|
|
ID=$(grep -oP '(?<=^ID=).+' /etc/os-release | tr -d '"')
|
|
case "$ID" in
|
|
almalinux)
|
|
yum install -y gcc-gfortran
|
|
;;
|
|
*)
|
|
echo "No preinstalls to build magma..."
|
|
;;
|
|
esac
|
|
|
|
MKLROOT=${MKLROOT:-/opt/conda/envs/py_$ANACONDA_PYTHON_VERSION}
|
|
|
|
cp make.inc-examples/make.inc.hip-gcc-mkl make.inc
|
|
echo 'LIBDIR += -L$(MKLROOT)/lib' >> make.inc
|
|
if [[ -f "${MKLROOT}/lib/libmkl_core.a" ]]; then
|
|
echo 'LIB = -Wl,--start-group -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -Wl,--end-group -lpthread -lstdc++ -lm -lgomp -lhipblas -lhipsparse' >> make.inc
|
|
fi
|
|
echo 'LIB += -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib -Wl,--rpath,$(MKLROOT)/lib -Wl,--rpath,/opt/rocm/magma/lib -ldl' >> make.inc
|
|
echo 'DEVCCFLAGS += --gpu-max-threads-per-block=256' >> make.inc
|
|
export PATH="${PATH}:/opt/rocm/bin"
|
|
if [[ -n "$PYTORCH_ROCM_ARCH" ]]; then
|
|
amdgpu_targets=`echo $PYTORCH_ROCM_ARCH | sed 's/;/ /g'`
|
|
else
|
|
amdgpu_targets=`rocm_agent_enumerator | grep -v gfx000 | sort -u | xargs`
|
|
fi
|
|
for arch in $amdgpu_targets; do
|
|
echo "DEVCCFLAGS += --offload-arch=$arch" >> make.inc
|
|
done
|
|
# hipcc with openmp flag may cause isnan() on __device__ not to be found; depending on context, compiler may attempt to match with host definition
|
|
sed -i 's/^FOPENMP/#FOPENMP/g' make.inc
|
|
make -f make.gen.hipMAGMA -j $(nproc)
|
|
LANG=C.UTF-8 make lib/libmagma.so -j $(nproc) MKLROOT="${MKLROOT}"
|
|
make testing/testing_dgemm -j $(nproc) MKLROOT="${MKLROOT}"
|
|
cp -R lib ${INSTALL_DIR}
|
|
cp -R include ${INSTALL_DIR}
|