From 6bf2e489fcf89bc50ae6bddccd7b3e5449c4d2c5 Mon Sep 17 00:00:00 2001 From: "Sarnie, Nick" Date: Fri, 21 Mar 2025 08:29:52 -0700 Subject: [PATCH] [CI] Use ccache when prebuilding tests Signed-off-by: Sarnie, Nick --- .github/workflows/sycl-linux-build.yml | 4 +++ devops/actions/run-tests/e2e/action.yml | 33 ++++++++++++++++++++++--- sycl/test-e2e/lit.cfg.py | 2 ++ sycl/test-e2e/lit.site.cfg.py.in | 6 ++--- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sycl-linux-build.yml b/.github/workflows/sycl-linux-build.yml index b76609f9d66bd..4a564268ca026 100644 --- a/.github/workflows/sycl-linux-build.yml +++ b/.github/workflows/sycl-linux-build.yml @@ -280,6 +280,8 @@ jobs: binaries_artifact: ${{ inputs.e2e_binaries_artifact }} cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ extra_lit_opts: --param sycl_build_targets="spir;nvidia;amd" + build_cache_root: ${{ inputs.build_cache_root }} + build_cache_suffix: "${{ inputs.build_cache_suffix }}_e2e" - name: Remove E2E tests before spirv-backend run if: ${{ inputs.e2e_binaries_artifact && always() && !cancelled() && steps.build.conclusion == 'success' }} @@ -295,3 +297,5 @@ jobs: binaries_artifact: ${{ inputs.e2e_binaries_artifact }}_spirv_backend cxx_compiler: $GITHUB_WORKSPACE/toolchain/bin/clang++ extra_lit_opts: --param spirv-backend=True + build_cache_root: ${{ inputs.build_cache_root }} + build_cache_suffix: "${{ inputs.build_cache_suffix }}_e2e_spv" diff --git a/devops/actions/run-tests/e2e/action.yml b/devops/actions/run-tests/e2e/action.yml index 47fc75599ccdb..f79f4bd2ef94b 100644 --- a/devops/actions/run-tests/e2e/action.yml +++ b/devops/actions/run-tests/e2e/action.yml @@ -17,7 +17,12 @@ inputs: required: false cxx_compiler: required: false - + build_cache_root: + required: false + build_cache_suffix: + type: string + required: false + default: "default" runs: using: "composite" @@ -48,18 +53,38 @@ runs: env: CMAKE_EXTRA_ARGS: ${{ inputs.extra_cmake_args }} run: | + CMPLR="${{ inputs.cxx_compiler || '$(which clang++)'}}" if [ -n "$CMAKE_EXTRA_ARGS" ]; then echo "opts=$CMAKE_EXTRA_ARGS" >> $GITHUB_OUTPUT fi + if [ -n "${{ inputs.build_cache_root }}" ]; then + CCACHE_PATH="$(dirname $CMPLR)" + echo "CCACHE_COMPILER=clang++" >> $GITHUB_ENV + echo "CCACHE_PATH=$CCACHE_PATH/real" >> $GITHUB_ENV + echo "CCACHE_DIR=${{ inputs.build_cache_root }}/build_cache_${{ inputs.build_cache_suffix }}" >> $GITHUB_ENV + echo "CCACHE_MAXSIZE=5G" >> $GITHUB_ENV + if [ ! -f "$CCACHE_PATH/real/clang++" ]; then + # sudo ln -s "$(which ccache)" "$CMPLR" + mkdir -p "$CCACHE_PATH/real" + ln -s "$CCACHE_PATH/clang" "$CCACHE_PATH/real/clang++" + rm "$CMPLR" + ln -s "$(which ccache)" "$CMPLR" + fi + DPCPP_PATH="$(dirname $CCACHE_PATH)" + echo "dpcpp_path=$DPCPP_PATH" >> $GITHUB_OUTPUT + mkdir -p $CCACHE_DIR + fi + #todo fix dpcpp_path when not using ccache + echo "CMPLR=$CMPLR" >> $GITHUB_ENV - name: Configure E2E tests if: inputs.testing_mode != 'run-only' shell: bash run: | - cmake -GNinja -B./build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="${{ inputs.cxx_compiler || '$(which clang++)'}}" -DLLVM_LIT="$PWD/llvm/llvm/utils/lit/lit.py" ${{ steps.cmake_opts.outputs.opts }} + ls -la /__w/llvm/llvm/toolchain/bin/real + cmake -GNinja -B./build-e2e -S./llvm/sycl/test-e2e -DCMAKE_CXX_COMPILER="$CMPLR" -DLLVM_LIT="$PWD/llvm/llvm/utils/lit/lit.py" ${{ steps.cmake_opts.outputs.opts }} + echo "LIT_OPTS=-v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests --param print_features=True --param test-mode=${{ inputs.testing_mode }} --param sycl_devices=${{ inputs.target_devices }} --param dpcpp_path=${{ steps.cmake_opts.outputs.dpcpp_path }}" >> $GITHUB_ENV - name: SYCL End-to-end tests shell: bash {0} - env: - LIT_OPTS: -v --no-progress-bar --show-unsupported --show-pass --show-xfail --max-time 3600 --time-tests --param print_features=True --param test-mode=${{ inputs.testing_mode }} --param sycl_devices=${{ inputs.target_devices }} ${{ inputs.extra_lit_opts }} run: | ninja -C build-e2e check-sycl-e2e > e2e.log 2>&1 exit_code=$? diff --git a/sycl/test-e2e/lit.cfg.py b/sycl/test-e2e/lit.cfg.py index c53aaadebb430..62a6b0f609ae0 100644 --- a/sycl/test-e2e/lit.cfg.py +++ b/sycl/test-e2e/lit.cfg.py @@ -536,6 +536,8 @@ def open_check_file(file_name): lit_config.note("Targeted devices: {}".format(", ".join(config.sycl_devices))) sycl_ls = FindTool("sycl-ls").resolve(llvm_config, config.llvm_tools_dir) +print(llvm_config.__dict__) +print(config.__dict__) if not sycl_ls: lit_config.fatal("can't find `sycl-ls`") diff --git a/sycl/test-e2e/lit.site.cfg.py.in b/sycl/test-e2e/lit.site.cfg.py.in index 75d8e24af3183..8a13b35be1c83 100644 --- a/sycl/test-e2e/lit.site.cfg.py.in +++ b/sycl/test-e2e/lit.site.cfg.py.in @@ -6,10 +6,10 @@ import platform import site site.addsitedir("@CMAKE_CURRENT_SOURCE_DIR@") - +print(lit_config.params) config.dpcpp_compiler = lit_config.params.get("dpcpp_compiler", "@SYCL_CXX_COMPILER@") -config.dpcpp_root_dir= os.path.dirname(os.path.dirname(config.dpcpp_compiler)) - +config.dpcpp_root_dir = lit_config.params.get("dpcpp_path", os.path.dirname(os.path.dirname(config.dpcpp_compiler))) +print(config.dpcpp_root_dir) config.llvm_tools_dir = os.path.join(config.dpcpp_root_dir, 'bin') config.lit_tools_dir = os.path.dirname("@TEST_SUITE_LIT@") config.dump_ir_supported = lit_config.params.get("dump_ir", ("@DUMP_IR_SUPPORTED@" if "@DUMP_IR_SUPPORTED@" else False))