blob: 820c2831af518393c1ec47246906365c7d172bf1 [file] [log] [blame]
# 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 building benchmark tools.
# It is designed to be called from a parent workflow.
# The concurrency of this workflow is controlled by the caller's job.
name: Build Benchmark Tools
on:
workflow_call:
inputs:
runner-group:
required: true
type: string
runner-env:
required: true
type: string
install-dir:
required: true
type: string
install-dir-archive:
required: true
type: string
install-dir-gcs-artifact:
required: true
type: string
outputs:
benchmark-tools-gcs-artifact-dir:
description: |
GCS path to benchmark tools archive.
value: ${{ jobs.build_benchmark_tools.outputs.benchmark-tools-gcs-artifact-dir }}
permissions:
contents: read
env:
# This duplicates the variable from benchmark.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:
build_benchmark_tools:
runs-on:
- self-hosted # must come first
- runner-group=${{ inputs.runner-group }}
- environment=${{ inputs.runner-env }}
- cpu
- os-family=Linux
outputs:
# We can't collect all outputs from the matrix jobs due to Github's
# limitation (https://github.com/orgs/community/discussions/17245).
# Therefore, the output is the GCS directory that stores all benchmark
# tools archives. The following jobs need to construct the archive names
# by themselves and combine with path of GCS directory here to fetch the
# archives.
benchmark-tools-gcs-artifact-dir: ${{ steps.upload.outputs.benchmark-tools-gcs-artifact-dir }}
strategy:
matrix:
target:
- platform: "linux"
arch: "x86_64"
docker_image: "gcr.io/iree-oss/base-bleeding-edge@sha256:cf2e78194e64fd0166f4141317366261d7a62432b72e9a324cb8c2ff4e1a515a"
# Builds tools on the host and assumes the builder is Linux x86_64.
build_script: "./build_tools/cmake/build_runtime.sh"
- platform: "linux"
arch: "riscv_64"
docker_image: "gcr.io/iree-oss/riscv@sha256:62e87bad3405d691ddba6f9be0ef44eeb60461a467c8d86f0842c81a1f97da79"
build_script: "./build_tools/cmake/build_riscv.sh"
- platform: "android"
arch: "armv8.2-a"
docker_image: "gcr.io/iree-oss/android@sha256:66b92a1c920588a73d03316f26025407ea754bab93e8f9bfe40dbf6ed5fe6c7e"
build_script: "./build_tools/cmake/build_android.sh"
env:
PLATFORM: ${{ matrix.target.platform }}
ARCH: ${{ matrix.target.arch }}
DOCKER_IMAGE: ${{ matrix.target.docker_image }}
BUILD_SCRIPT: ${{ matrix.target.build_script }}
BUILD_TOOLS_DIR: ${{ matrix.target.platform }}-${{ matrix.target.arch }}-benchmark-tools-dir
INSTALL_DIR: ${{ inputs.install-dir }}
INSTALL_DIR_ARCHIVE: ${{ inputs.install-dir-archive }}
INSTALL_DIR_GCS_ARTIFACT: ${{ inputs.install-dir-gcs-artifact }}
steps:
- name: "Checking out repository"
uses: actions/checkout@v4.1.7
- name: "Checking out runtime submodules"
run: ./build_tools/scripts/git/update_runtime_submodules.sh
- name: "Downloading install dir archive"
run: gcloud storage cp "${INSTALL_DIR_GCS_ARTIFACT}" "${INSTALL_DIR_ARCHIVE}"
- name: "Extracting install directory"
run: tar -xf "${INSTALL_DIR_ARCHIVE}"
- name: "Compiling the benchmark tools"
id: build
run: |
./build_tools/github_actions/docker_run.sh \
--env "IREE_TARGET_PLATFORM=${PLATFORM}" \
--env "IREE_TARGET_ARCH=${ARCH}" \
--env "BUILD_PRESET=benchmark" \
--env "IREE_HOST_BIN_DIR=${INSTALL_DIR}/bin" \
"${DOCKER_IMAGE}" "${BUILD_SCRIPT}" "${BUILD_TOOLS_DIR}/build"
- name: "Compiling the benchmark tools with tracing"
id: build-with-tracing
run: |
./build_tools/github_actions/docker_run.sh \
--env "IREE_TARGET_PLATFORM=${PLATFORM}" \
--env "IREE_TARGET_ARCH=${ARCH}" \
--env "BUILD_PRESET=benchmark-with-tracing" \
--env "IREE_HOST_BIN_DIR=${INSTALL_DIR}/bin" \
"${DOCKER_IMAGE}" "${BUILD_SCRIPT}" "${BUILD_TOOLS_DIR}/build-traced"
- name: "Creating the benchmark tools archive"
id: archive
env:
BENCHMARK_TOOLS_ARCHIVE: ${{ env.PLATFORM }}-${{ env.ARCH }}-benchmark-tools.tar
run: |
tar -cf "${BENCHMARK_TOOLS_ARCHIVE}" \
"${BUILD_TOOLS_DIR}"/*/tools/iree-benchmark-module \
"${BUILD_TOOLS_DIR}"/*/tools/build_config.txt
echo "benchmark-tools-archive=${BENCHMARK_TOOLS_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading the benchmark tools archive"
id: upload
env:
BENCHMARK_TOOLS_ARCHIVE: ${{ steps.archive.outputs.benchmark-tools-archive }}
BENCHMARK_TOOLS_GCS_ARTIFACT_DIR: ${{ env.GCS_DIR }}/benchmark-tools
run: |
gcloud storage cp "${BENCHMARK_TOOLS_ARCHIVE}" "${BENCHMARK_TOOLS_GCS_ARTIFACT_DIR}/"
echo "benchmark-tools-gcs-artifact-dir=${BENCHMARK_TOOLS_GCS_ARTIFACT_DIR}" >> "${GITHUB_OUTPUT}"