| # Copyright 2022 The IREE Authors |
| # |
| # Licensed under the Apache License v2.0 with LLVM Exceptions. |
| # See https://llvm.org/LICENSE.txt for license information. |
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| # |
| # Workflow for running compilation benchmarks. |
| # It is designed to be called from a parent workflow. |
| # The concurrency of this workflow is controlled by the caller's job. |
| |
| name: Benchmark Compilation |
| |
| on: |
| workflow_call: |
| inputs: |
| runner-group: |
| required: true |
| type: string |
| runner-env: |
| required: true |
| type: string |
| e2e-test-artifacts-dir: |
| required: true |
| type: string |
| e2e-test-artifacts-gcs-artifact-dir: |
| required: true |
| type: string |
| e2e-test-artifacts-build-log: |
| required: true |
| type: string |
| e2e-test-artifacts-build-log-gcs-artifact: |
| required: true |
| type: string |
| outputs: |
| compile-stats-results: |
| description: | |
| Local path to the compilation benchmark results. |
| value: ${{ jobs.compilation_benchmarks.outputs.compile-stats-results }} |
| compile-stats-results-gcs-artifact: |
| description: | |
| GCS path to the uploaded compilation benchmark results. |
| value: ${{ jobs.compilation_benchmarks.outputs.compile-stats-results-gcs-artifact }} |
| |
| env: |
| # This duplicates the variable from ci.yml. The variable needs to be in env |
| # instead of the outputs of setup because it contains the run attempt and we |
| # want that to be the current attempt, not whatever attempt the setup step |
| # last ran in. It therefore can't be passed in via inputs because the env |
| # context isn't available there. |
| GCS_DIR: gs://iree-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts/${{ github.run_id }}/${{ github.run_attempt }} |
| |
| jobs: |
| compilation_benchmarks: |
| runs-on: |
| - self-hosted # must come first |
| - runner-group=${{ inputs.runner-group }} |
| - environment=${{ inputs.runner-env }} |
| - cpu |
| - os-family=Linux |
| env: |
| E2E_TEST_ARTIFACTS_DIR: ${{ inputs.e2e-test-artifacts-dir }} |
| E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR: ${{ inputs.e2e-test-artifacts-gcs-artifact-dir }} |
| E2E_TEST_ARTIFACTS_BUILD_LOG: ${{ inputs.e2e-test-artifacts-build-log }} |
| E2E_TEST_ARTIFACTS_BUILD_LOG_GCS_ARTIFACT: ${{ inputs.e2e-test-artifacts-build-log-gcs-artifact }} |
| outputs: |
| compile-stats-results: ${{ steps.collect.outputs.compile-stats-results }} |
| compile-stats-results-gcs-artifact: ${{ steps.upload.outputs.compile-stats-results-gcs-artifact }} |
| steps: |
| - name: "Checking out repository" |
| uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 |
| - name: "Downloading assets" |
| id: "download-assets" |
| env: |
| BENCHMARK_CONFIG: ${{ env.E2E_TEST_ARTIFACTS_DIR }}/compilation-benchmark-config.json |
| BENCHMARK_CONFIG_GCS_ARTIFACT: ${{ env.E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR }}/compilation-benchmark-config.json |
| run: | |
| mkdir -p "${E2E_TEST_ARTIFACTS_DIR}" |
| gcloud storage cp "${BENCHMARK_CONFIG_GCS_ARTIFACT}" "${BENCHMARK_CONFIG}" |
| gcloud storage cp \ |
| "${E2E_TEST_ARTIFACTS_BUILD_LOG_GCS_ARTIFACT}" \ |
| "${E2E_TEST_ARTIFACTS_BUILD_LOG}" |
| jq -r \ |
| --arg GCS_ARTIFACT_DIR "${E2E_TEST_ARTIFACTS_GCS_ARTIFACT_DIR}" \ |
| '.module_dir_paths | map("\($GCS_ARTIFACT_DIR)/\(.)") | join("\n")' \ |
| "${BENCHMARK_CONFIG}" | \ |
| gcloud storage cp -r --read-paths-from-stdin \ |
| "${E2E_TEST_ARTIFACTS_DIR}" |
| echo "benchmark-config=${BENCHMARK_CONFIG}" >> "${GITHUB_OUTPUT}" |
| - name: "Collecting compilation statistics" |
| id: collect |
| env: |
| BENCHMARK_CONFIG: ${{ steps.download-assets.outputs.benchmark-config }} |
| COMPILE_STATS_RESULTS: benchmark-results/compile-stats-results.json |
| run: | |
| mkdir -p benchmark-results |
| ./build_tools/benchmarks/collect_compilation_statistics.py alpha \ |
| --e2e_test_artifacts_dir="${E2E_TEST_ARTIFACTS_DIR}" \ |
| --build_log="${E2E_TEST_ARTIFACTS_BUILD_LOG}" \ |
| --compilation_benchmark_config="${BENCHMARK_CONFIG}" \ |
| --output="${COMPILE_STATS_RESULTS}" |
| echo "compile-stats-results=${COMPILE_STATS_RESULTS}" >> "${GITHUB_OUTPUT}" |
| - name: "Uploading benchmark results" |
| id: upload |
| env: |
| COMPILE_STATS_RESULTS: ${{ steps.collect.outputs.compile-stats-results }} |
| COMPILE_STATS_RESULTS_GCS_ARTIFACT: ${{ env.GCS_DIR }}/${{ steps.collect.outputs.compile-stats-results }} |
| run: | |
| gcloud storage cp \ |
| "${COMPILE_STATS_RESULTS}" \ |
| "${COMPILE_STATS_RESULTS_GCS_ARTIFACT}" |
| echo "compile-stats-results-gcs-artifact=${COMPILE_STATS_RESULTS_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}" |