Skip to content

Commit

Permalink
Add sccache support for hcc and hip-clang in ROCm (#38451)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: pytorch/pytorch#38451

Differential Revision: D21589126

Pulled By: ezyang

fbshipit-source-id: dc4d08e7f393dbe369e501334c776071b2c176e0
  • Loading branch information
mpruthvikumar authored and facebook-github-bot committed May 15, 2020
1 parent fac9f36 commit 8df14c5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docker/caffe2/jenkins/common/install_ccache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ if [ -z "${SCCACHE}" ]; then
exit 1
fi

# If rocm build, add hcc to sccache.
# If rocm build, if hcc file exists then use hcc else clang(hip-clang) for sccache
if [[ "${BUILD_ENVIRONMENT}" == *-rocm* ]]; then
# HCC's symlink path: /opt/rocm/hcc/bin/hcc -> /opt/rocm/hcc/bin/clang -> /opt/rocm/hcc/bin/clang-7.0
HCC_DEST_PATH="$(readlink -f $(which hcc))"
HCC_REAL_BINARY="$(dirname $HCC_DEST_PATH)/clang-7.0_original"
mv "$HCC_DEST_PATH" "$HCC_REAL_BINARY"
if [[ -e "/opt/rocm/hcc/bin/hcc" ]]; then
HIPCOM_DEST_PATH="$(readlink -f /opt/rocm/hcc/bin/hcc )"
else
HIPCOM_DEST_PATH="$(readlink -f /opt/rocm/llvm/bin/clang )"
fi
HIPCOM_REAL_BINARY="$(dirname $HIPCOM_DEST_PATH)/hipcompiler_original"
mv "$HIPCOM_DEST_PATH" "$HIPCOM_REAL_BINARY"

# Create sccache wrapper.
(
echo "#!/bin/sh"
echo "exec $SCCACHE $HCC_REAL_BINARY \"\$@\""
) > "$HCC_DEST_PATH"
chmod +x "$HCC_DEST_PATH"
echo "exec $SCCACHE $HIPCOM_REAL_BINARY \"\$@\""
) > "$HIPCOM_DEST_PATH"
chmod +x "$HIPCOM_DEST_PATH"
fi

0 comments on commit 8df14c5

Please sign in to comment.