Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add job to build benchmarks #10028

Merged
merged 7 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ env:

jobs:
build_runtime:
if: false
GMNGeoffrey marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-20.04
env:
BUILD_DIR: build-runtime
Expand Down Expand Up @@ -76,6 +77,7 @@ jobs:

test_runtime:
needs: build_runtime
if: false
runs-on: ubuntu-20.04
env:
BUILD_DIR: ${{ needs.build_runtime.outputs.build-dir }}
Expand Down Expand Up @@ -150,6 +152,7 @@ jobs:
echo "::set-output name=gcs-artifact::${GCS_ARTIFACT}"

build_test_all_bazel:
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand All @@ -176,6 +179,7 @@ jobs:


host_tools_assertions:
if: false
uses: ./.github/workflows/host_tools.yml
with:
host-binary-root: host-tools-assertions
Expand Down Expand Up @@ -228,6 +232,7 @@ jobs:

test_all:
needs: build_all
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand Down Expand Up @@ -297,6 +302,7 @@ jobs:

test_tf_integrations:
needs: [build_tf_integrations, build_all]
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand Down Expand Up @@ -378,6 +384,7 @@ jobs:
build_tools/cmake/run_tf_tests.sh ${BUILD_DIR}"

asan:
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand All @@ -396,6 +403,7 @@ jobs:
./build_tools/cmake/build_and_test_asan.sh

tsan:
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand All @@ -415,6 +423,7 @@ jobs:

riscv32:
needs: host_tools_assertions
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand Down Expand Up @@ -450,6 +459,7 @@ jobs:

riscv64:
needs: [build_all, host_tools_assertions, build_tf_integrations]
if: false
runs-on:
# Pseudo-ternary hack and order matters. See comment at top of file.
- self-hosted
Expand Down Expand Up @@ -502,6 +512,78 @@ jobs:
bash -euo pipefail -c \
"./build_tools/cmake/build_riscv.sh && ./tests/riscv64/smoke.sh"

android_arm64:
needs: [host_tools_assertions]
if: false
runs-on:
# Hacks, and order matters. See the comment at the top of the file.
- self-hosted
- runner-group=${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}
- cpu
- os-family=Linux
env:
BUILD_DIR: "build-android-arm64"
ANDROID_ABI: "arm64-v8a"
HOST_BINARY_ROOT: ${{ needs.host_tools_assertions.outputs.host-binary-root }}
HOST_BINARY_ARCHIVE: ${{ needs.host_tools_assertions.outputs.host-binary-root }}.tar
steps:
- name: "Checking out repository"
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
with:
submodules: true
- name: "Downloading host tools"
uses: actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v3.0.0
with:
name: "${{ env.HOST_BINARY_ARCHIVE }}"
- name: "Extracting host tools archive"
run: |
tar -xvf ${HOST_BINARY_ARCHIVE}
- name: "Building for Android"
run: |
build_tools/github_actions/docker_run.sh \
--env "ANDROID_ABI=${ANDROID_ABI}" \
--env "IREE_HOST_BINARY_ROOT=${HOST_BINARY_ROOT}" \
gcr.io/iree-oss/android@sha256:9bc723fc707a18bd0c1be9c12e01ea5bb7c7d77f607427879e10ffcffd7d2bb5 \
build_tools/build_android.sh

build_benchmarks:
needs: [build_all, build_tf_integrations]
runs-on:
# Hacks, and order matters. See the comment at the top of the file.
- self-hosted
- runner-group=${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}
- cpu
- os-family=Linux
env:
BUILD_DIR: ${{ needs.build_all.outputs.build-dir }}
BUILD_DIR_ARCHIVE: ${{ needs.build_all.outputs.build-dir-archive }}
BUILD_DIR_GCS_ARTIFACT: ${{ needs.build_all.outputs.gcs-artifact }}
TF_BINARIES_DIR: ${{ needs.build_tf_integrations.outputs.binaries-dir }}
TF_BINARIES_ARCHIVE: ${{ needs.build_tf_integrations.outputs.binaries-archive }}
TF_BINARIES_GCS_ARTIFACT: ${{ needs.build_tf_integrations.outputs.gcs-artifact }}
steps:
- name: "Checking out repository"
uses: actions/checkout@7884fcad6b5d53d10323aee724dc68d8b9096a2e # v2
with:
submodules: true
- name: "Downloading TF binaries archive"
run: gcloud alpha storage cp "${TF_BINARIES_GCS_ARTIFACT}" "${TF_BINARIES_ARCHIVE}"
- name: "Extracting TF binaries archive"
run: tar -xf "${TF_BINARIES_ARCHIVE}"
# TODO(#4662): building the benchmarks currently needs the entire build
# dir archive just to get the host tools. This is silly and we should
# make prebuilt host tools work even when not cross-compiling.
- name: "Downloading build dir archive"
run: gcloud alpha storage cp "${BUILD_DIR_GCS_ARTIFACT}" "${BUILD_DIR_ARCHIVE}"
- name: "Extracting archive"
run: tar -xf "${BUILD_DIR_ARCHIVE}"
- name: "Re-configuring"
run: |
build_tools/github_actions/docker_run.sh \
--env "IREE_TF_BINARIES_DIR=${TF_BINARIES_DIR}" \
gcr.io/iree-oss/base@sha256:5d43683c6b50aebe1fca6c85f2012f3b0fa153bf4dd268e8767b619b1891423a \
build_tools/cmake/build_benchmarks.sh \
"${BUILD_DIR}"

summary:
runs-on: ubuntu-20.04
Expand All @@ -519,6 +601,8 @@ jobs:
- tsan
- riscv32
- riscv64
- android_arm64
- build_benchmarks
if: always()
steps:
- name: Getting combined job status
Expand Down
55 changes: 55 additions & 0 deletions build_tools/build_android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

# 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

# Cross-compile the IREE project towards Android with CMake. Designed for CI,
# but can be run manually.
#
# Requires pre-compiled IREE and TF integrations host tools. Also requires that
# ANDROID_ABI and ANDROID_NDK variables be set

set -xeuo pipefail

ROOT_DIR="${ROOT_DIR:-$(git rev-parse --show-toplevel)}"
cd "${ROOT_DIR}"

CMAKE_BIN="${CMAKE_BIN:-$(which cmake)}"
IREE_HOST_BINARY_ROOT="$(realpath ${IREE_HOST_BINARY_ROOT})"
BUILD_ANDROID_DIR="${BUILD_ANDROID_DIR:-$ROOT_DIR/build-android}"


if [[ -d "${BUILD_ANDROID_DIR}" ]]; then
echo "${BUILD_ANDROID_DIR} directory already exists. Will use cached results there."
else
echo "${BUILD_ANDROID_DIR} directory does not already exist. Creating a new one."
mkdir "${BUILD_ANDROID_DIR}"
fi

declare -a args=(
-G Ninja
-B "${BUILD_ANDROID_DIR}"
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake"
-DANDROID_ABI="${ANDROID_ABI}"
-DANDROID_PLATFORM=android-29
-DIREE_HOST_BINARY_ROOT="${IREE_HOST_BINARY_ROOT}"
-DIREE_ENABLE_ASSERTIONS=ON
-DIREE_BUILD_COMPILER=OFF
-DIREE_BUILD_TESTS=ON
-DIREE_BUILD_SAMPLES=OFF
)

# Configure towards 64-bit Android 10, then build.
"${CMAKE_BIN}" "${args[@]}"


echo "Building all for device"
echo "------------"
"${CMAKE_BIN}" --build "${BUILD_ANDROID_DIR}" -- -k 0

echo "Building test deps for device"
echo "------------------"
"${CMAKE_BIN}" --build "${BUILD_ANDROID_DIR}" --target iree-test-deps -- -k 0
2 changes: 1 addition & 1 deletion build_tools/buildkite/cmake/android/arm64-v8a/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ steps:
- label: "build"
commands:
- "git submodule sync && git submodule update --init --jobs 8 --depth 1"
- "docker run --user=$(id -u):$(id -g) --volume=\\$PWD:\\$IREE_DOCKER_WORKDIR --workdir=\\$IREE_DOCKER_WORKDIR --rm gcr.io/iree-oss/android@sha256:9bc723fc707a18bd0c1be9c12e01ea5bb7c7d77f607427879e10ffcffd7d2bb5 build_tools/cmake/build_android.sh arm64-v8a"
- "docker run --user=$(id -u):$(id -g) --volume=\\$PWD:\\$IREE_DOCKER_WORKDIR --workdir=\\$IREE_DOCKER_WORKDIR --rm gcr.io/iree-oss/android@sha256:9bc723fc707a18bd0c1be9c12e01ea5bb7c7d77f607427879e10ffcffd7d2bb5 build_host_and_android.sh arm64-v8a"
- "tar --exclude='*.o' --exclude='*.a' -czvf build-artifacts.tgz build-android"
agents:
- "queue=build"
Expand Down
42 changes: 42 additions & 0 deletions build_tools/cmake/build_benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# Copyright 2019 The IREE Authors
GMNGeoffrey marked this conversation as resolved.
Show resolved Hide resolved
#
# 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

# Build benchmark suites for IREE using an *already built* build directory.
# Designed for CI, but can be run locally.
# TODO(#4662): this should just allow passing in host tools.

set -xeuo pipefail

ROOT_DIR="${ROOT_DIR:-$(git rev-parse --show-toplevel)}"
cd "${ROOT_DIR}"

BUILD_DIR="${1:-${IREE_BUILD_DIR:-build}}"
CMAKE_BIN=${CMAKE_BIN:-$(which cmake)}
IREE_TF_BINARIES_DIR="${IREE_TF_BINARIES_DIR:-integrations/tensorflow/bazel-bin/iree_tf_compiler}"

"$CMAKE_BIN" --version
ninja --version

if ! [[ -d "${BUILD_DIR}" ]]; then
echo "Build directory '${BUILD_DIR}' does not exist. Aborting"
exit 1
fi

echo "Reconfiguring to enable benchmarks"
# Note that we're relying on CMake caching here
"${CMAKE_BIN}" -B "${BUILD_DIR}" \
-DIREE_BUILD_BENCHMARKS=ON \
-DIREE_BUILD_MICROBENCHMARKS=ON \
-DIREE_IMPORT_TFLITE_PATH="${IREE_TF_BINARIES_DIR}/iree-import-tflite" \
-DIREE_IMPORT_TF_PATH="${IREE_TF_BINARIES_DIR}/iree-import-tf"

echo "Building benchmark artifacts"
"${CMAKE_BIN}" \
--build "${BUILD_DIR}" \
--target iree-benchmark-suites iree-microbenchmark-suites \
-- -k 0