diff options
author | Edward Z. Yang <ezyang@mit.edu> | 2018-02-13 09:54:49 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-13 09:54:49 -0800 |
commit | 7c3a8eaa15a829cc1d4f1abe075468ca0f95a906 (patch) | |
tree | e597768a88cf0e6d6b04a2e46db970bb1586a93b /.jenkins | |
parent | e9587278740795fc654b82c7f6554a9a3d7abc2d (diff) | |
download | pytorch-7c3a8eaa15a829cc1d4f1abe075468ca0f95a906.tar.gz pytorch-7c3a8eaa15a829cc1d4f1abe075468ca0f95a906.tar.bz2 pytorch-7c3a8eaa15a829cc1d4f1abe075468ca0f95a906.zip |
Use sccache for CPU builds. (#5208)
Signed-off-by: Edward Z. Yang <ezyang@fb.com>
Diffstat (limited to '.jenkins')
-rwxr-xr-x | .jenkins/build.sh | 12 | ||||
-rw-r--r-- | .jenkins/common.sh | 36 |
2 files changed, 45 insertions, 3 deletions
diff --git a/.jenkins/build.sh b/.jenkins/build.sh index c73f4c2564..5d2a3b870e 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -16,8 +16,16 @@ export PATH=/opt/conda/bin:$PATH if [[ "$JOB_NAME" != *cuda* ]]; then export PATH=/opt/python/${PYTHON_VERSION}/bin:$PATH export LD_LIBRARY_PATH=/opt/python/${PYTHON_VERSION}/lib:$LD_LIBRARY_PATH - export CC="ccache /usr/bin/gcc-${GCC_VERSION}" - export CXX="ccache /usr/bin/g++-${GCC_VERSION}" + export CC="sccache /usr/bin/gcc-${GCC_VERSION}" + export CXX="sccache /usr/bin/g++-${GCC_VERSION}" + + sccache --show-stats + + function sccache_epilogue() { + sccache --show-stats + } + trap_add sccache_epilogue EXIT + else # CMake should use ccache symlink for nvcc export CUDA_NVCC_EXECUTABLE=/usr/local/bin/nvcc diff --git a/.jenkins/common.sh b/.jenkins/common.sh index 25ca0ccbdb..5a3c891ae6 100644 --- a/.jenkins/common.sh +++ b/.jenkins/common.sh @@ -25,7 +25,41 @@ set -ex # system; to find out more, grep for this string in ossci-job-dsl. echo "ENTERED_USER_LAND" -trap cleanup EXIT +# compositional trap taken from https://stackoverflow.com/a/7287873/23845 + +# note: printf is used instead of echo to avoid backslash +# processing and to properly handle values that begin with a '-'. + +log() { printf '%s\n' "$*"; } +error() { log "ERROR: $*" >&2; } +fatal() { error "$@"; exit 1; } + +# appends a command to a trap +# +# - 1st arg: code to add +# - remaining args: names of traps to modify +# +trap_add() { + trap_add_cmd=$1; shift || fatal "${FUNCNAME} usage error" + for trap_add_name in "$@"; do + trap -- "$( + # helper fn to get existing trap command from output + # of trap -p + extract_trap_cmd() { printf '%s\n' "$3"; } + # print existing trap command with newline + eval "extract_trap_cmd $(trap -p "${trap_add_name}")" + # print the new trap command + printf '%s\n' "${trap_add_cmd}" + )" "${trap_add_name}" \ + || fatal "unable to add to trap ${trap_add_name}" + done +} +# set the trace attribute for the above function. this is +# required to modify DEBUG or RETURN traps because functions don't +# inherit them unless the trace attribute is set +declare -f -t trap_add + +trap_add cleanup EXIT # Converts: # pytorch-builds/pytorch-macos-10.13-py3-build-test ==> pytorch-macos-10.13-py3-build-test |