forked from iree-org/iree
-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (154 loc) · 7.53 KB
/
build_benchmark_tools.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# 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 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:
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:c5f28883e6c570c20128fb37d7af3a00a25df3ce4e2b3a24c3a8dcd183182a27"
# Builds tools on the host and assumes the builder is Linux x86_64.
build_script: "./build_tools/cmake/build_runtime.sh"
tracy_capture: "gs://iree-shared-files/tracy-capture-linux-x86_64-af73dba7"
- platform: "linux"
arch: "riscv_64"
docker_image: "gcr.io/iree-oss/riscv@sha256:62e87bad3405d691ddba6f9be0ef44eeb60461a467c8d86f0842c81a1f97da79"
build_script: "./build_tools/cmake/build_riscv.sh"
tracy_capture: "gs://iree-shared-files/tracy-capture-linux-x86_64-af73dba7"
- platform: "android"
arch: "armv8.2-a"
docker_image: "gcr.io/iree-oss/android@sha256:66b92a1c920588a73d03316f26025407ea754bab93e8f9bfe40dbf6ed5fe6c7e"
build_script: "./build_tools/cmake/build_android.sh"
tracy_capture: "gs://iree-shared-files/tracy-capture-linux-arm_64-af73dba7"
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@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- 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: "Downloading pre-built tracy capture tool"
id: download-tracy-capture
env:
TRACY_CAPTURE_GCS_ARTIFACT: ${{ matrix.target.tracy_capture }}
TRACY_CAPTURE: ${{ env.BUILD_TOOLS_DIR }}/build-traced/tracy-capture
run: |
gcloud storage cp "${TRACY_CAPTURE_GCS_ARTIFACT}" "${TRACY_CAPTURE}"
chmod +x "${TRACY_CAPTURE}"
echo "tracy-capture=${TRACY_CAPTURE}" >> "${GITHUB_OUTPUT}"
- name: "Creating the benchmark tools archive"
# Here we pack a tracy-capture binary (~7MB) into each benchmark tools
# archive. This could be wasteful because multiple benchmark tools
# archives might pack the same tracy-capture binary. But it simplifies
# the process to fetch required tools to run benchmarks and we only have
# a few versions of the benchmark tools archives.
# Detailed reason: The generated benchmark matrix fetches the benchmark
# tools archive based on the target device. However, there is a scenario
# that the tracy-capture is running on a different host. E.g. Mobile
# benchmarks have the benchmark tool forwarding the data from the phones
# to the tracy-capture running on Linux host. Embedding the host of
# tracy-capture will overloads the benchmark matrix and puts too much
# unrelated machine setup in it. So we simply pack everything needed
# into each benchmark tools archive.
id: archive
env:
TRACY_CAPTURE: ${{ steps.download-tracy-capture.outputs.tracy-capture }}
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 \
"${TRACY_CAPTURE}"
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}"