Skip to content

Commit

Permalink
Add convperf
Browse files Browse the repository at this point in the history
  • Loading branch information
mariecwhite committed Sep 3, 2023
1 parent f6893e3 commit afad4da
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 23 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/run_comparative_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
run: |
mkdir -p "${XLA_TOOLS_DIR}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
./comparative_benchmark/xla_hlo/build_xla_tools.sh \
"${XLA_TOOLS_DIR}" \
"${CUDA_VERSION}"
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
RESULTS_PATH="${RESULTS_DIR}/${XLA_HLO_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env "OOBI_XLA_TOOLS_DIR=${XLA_TOOLS_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -147,8 +147,8 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_XLA_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./comparative_benchmark/jax_xla/benchmark_all.sh \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
./comparative_benchmark/jax/benchmark_xla.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
gcloud storage cp "${RESULTS_PATH}" "${RESULTS_GCS_DIR}/"
Expand All @@ -160,7 +160,7 @@ jobs:
# run: |
# RESULTS_PATH="${RESULTS_DIR}/${JAX_IREE_RESULTS_JSON}"
# docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
# "gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:3ddddec96e0c58b72b168d2e6d8c289cad6e47fa2e8d5869ffa107e1b65f7064" \
# "gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
# ./comparative_benchmark/jax/benchmark_iree.sh \
# "${TARGET_DEVICE}"\
# "${RESULTS_PATH}"
Expand All @@ -172,7 +172,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${TF_XLA_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
./comparative_benchmark/tf_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -184,7 +184,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${PT_INDUCTOR_RESULTS_JSON}"
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand Down Expand Up @@ -225,7 +225,7 @@ jobs:
RESULTS_PATH="${RESULTS_DIR}/${XLA_HLO_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
--env "OOBI_XLA_TOOLS_DIR=${XLA_TOOLS_DIR}" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -237,7 +237,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_XLA_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251" \
./comparative_benchmark/jax/benchmark_xla.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -249,7 +249,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${JAX_IREE_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251" \
./comparative_benchmark/jax/benchmark_iree.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -261,7 +261,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${TF_XLA_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251" \
./comparative_benchmark/tf_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -273,7 +273,7 @@ jobs:
run: |
RESULTS_PATH="${RESULTS_DIR}/${PT_INDUCTOR_RESULTS_JSON}"
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/run_convperf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2023 The OpenXLA 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
#
# Runs convperf.

name: convperf

on:
# Will only run when manually triggered.
workflow_dispatch:

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
cancel-in-progress: true

env:
GCS_DIR: gs://openxla-github-actions-${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}-artifacts/${{ github.run_id }}/${{ github.run_attempt }}

jobs:
setup:
runs-on: ubuntu-22.04
env:
REPO_SHA: ${{ github.sha }}
outputs:
runner-group: ${{ steps.configure.outputs.runner-group }}
artifact-upload-dir: ${{ steps.configure.outputs.artifact-upload-dir }}
steps:
- name: "Checking out PR repository"
uses: actions/checkout@e2f20e631ae6d7dd3b768f56a5d2af784dd54791 # v2.5.0
- name: "Configuring CI options"
id: configure
env:
RUNNER_GROUP: ${{ github.event_name == 'pull_request' && 'presubmit' || 'postsubmit' }}
run: |
# Just informative logging. There should only be two commits in the
# history here, but limiting the depth helps when copying from a local
# repo instead of using checkout, e.g. with
# https://github.com/nektos/act where there will be more.
git log --oneline --graph --max-count=3
# Workflow jobs can't access `env` in `runs-on`, so we need to make
# `runner-group` a job output variable.
echo "runner-group=${RUNNER_GROUP}" > "${GITHUB_OUTPUT}"
export GCS_ARTIFACT_DIR="$(date +'%Y-%m-%d').sha_${REPO_SHA}.timestamp_$(date +'%s')"
echo "artifact-upload-dir=${GCS_ARTIFACT_DIR}" >> $GITHUB_OUTPUT
build_and_benchmark_cpu:
needs: setup
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- cpu
- os-family=Linux
env:
BUILD_DIR: convperf-build-cpu
RESULTS_DIR: convperf-results-cpu
GCS_UPLOAD_PARENT_DIR: "gs://convperf-benchmark-artifacts/cpu"
GCS_UPLOAD_DIR_NAME: ${{ needs.setup.outputs.artifact-upload-dir }}
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: "Building and running convperf for CPU"
run: |
mkdir ${RESULTS_DIR}
# Run under privileged mode because system-level scheduling is used.
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" --privileged \
gcr.io/iree-oss/openxla-benchmark/convperf@sha256:0807d5e8144900752cfae72f3aa4d12530b408f73fc6f010a6cbad11cc09832c \
./experimental/microbenchmarks/convperf/build_and_run_convperf.sh "${BUILD_DIR}" "${RESULTS_DIR}"
- name: "Uploading results"
run: |
gcloud storage cp "${RESULTS_DIR}/**" "${GCS_UPLOAD_PARENT_DIR}/${GCS_UPLOAD_DIR_NAME}/"
gcloud storage cp "${RESULTS_DIR}/**" "${GCS_UPLOAD_PARENT_DIR}/latest/"
8 changes: 4 additions & 4 deletions .github/workflows/run_mmperf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: "Building mmperf for CPU"
run: |
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:c972ce5b2144de0786f103611fecbd88d93dd45ecd068f8c97d98c08677cee57 \
./experimental/microbenchmarks/mmperf/build_mmperf.sh "cpu" "${BUILD_DIR}"
- name: "Removing unused files"
run: |
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
- name: "Building mmperf for CUDA"
run: |
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:c972ce5b2144de0786f103611fecbd88d93dd45ecd068f8c97d98c08677cee57 \
./experimental/microbenchmarks/mmperf/build_mmperf.sh "cuda" "${BUILD_DIR}"
- name: "Removing unused files"
run: |
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:
run: |
mkdir ${RESULTS_DIR}
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:c972ce5b2144de0786f103611fecbd88d93dd45ecd068f8c97d98c08677cee57 \
./experimental/microbenchmarks/mmperf/run_mmperf.sh "${BUILD_DIR}" "${RESULTS_DIR}"
- name: "Uploading results"
run: |
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
run: |
mkdir ${RESULTS_DIR}
docker run --gpus all --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:c972ce5b2144de0786f103611fecbd88d93dd45ecd068f8c97d98c08677cee57 \
./experimental/microbenchmarks/mmperf/run_mmperf.sh "${BUILD_DIR}" "${RESULTS_DIR}"
- name: "Uploading results"
run: |
Expand Down
3 changes: 2 additions & 1 deletion devtools/docker/dockerfiles/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ RUN apt-get update \
cmake \
ninja-build \
clang \
lld
lld \
numactl

######## Python ########
WORKDIR /install-python
Expand Down
14 changes: 14 additions & 0 deletions devtools/docker/dockerfiles/convperf.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2023 The OpenXLA 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

# An image that can run https://github.com/nod-ai/convperf.

FROM gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251

######## OpenMP ########
RUN apt-get update \
&& apt-get install -y libomp-14-dev
##############
2 changes: 1 addition & 1 deletion devtools/docker/dockerfiles/cuda11.8-cudnn8.9.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# An image that supports CUDA.

FROM gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf
FROM gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251

######## NVIDIA ########
WORKDIR /install-cuda
Expand Down
2 changes: 1 addition & 1 deletion devtools/docker/dockerfiles/mmperf.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# mmperf repo. Later versions of Clang, LLVM, Python and Ubuntu are needed
# to satisfy the dependency requirements of the backends.

FROM gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf
FROM gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251

######## CUDA ########
RUN apt-get update \
Expand Down
3 changes: 2 additions & 1 deletion devtools/docker/image_deps.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"base": [],
"cuda11.8-cudnn8.9": ["base"],
"db_import": [],
"mmperf": ["base"]
"mmperf": ["base"],
"convperf": ["base"]
}
7 changes: 4 additions & 3 deletions devtools/docker/prod_digests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf
gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9
gcr.io/iree-oss/openxla-benchmark/base@sha256:1bf3e319465ec8fb465baae3f6ba9a5b09cb84a5349a675c671a552fc77f2251
gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:f43984cd6c16ad1faad4dfb6aac3f53e552dd728c9330c90752e78ae51e4276f
gcr.io/iree-oss/openxla-benchmark/db_import@sha256:3de8a702b51ca1906fc2ef5bab2415a79e46bc132f2ceba994215539dd0ecdd4
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:c972ce5b2144de0786f103611fecbd88d93dd45ecd068f8c97d98c08677cee57
gcr.io/iree-oss/openxla-benchmark/convperf@sha256:0807d5e8144900752cfae72f3aa4d12530b408f73fc6f010a6cbad11cc09832c
57 changes: 57 additions & 0 deletions experimental/microbenchmarks/convperf/build_and_run_convperf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
#
# Copyright 2023 The OpenXLA 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
#
# Environment variables:
# CC=clang
# CXX=clang++
#
# Example usage:
# ./build_convperf.sh <build-dir> <output-dir>

set -xeuo pipefail

BUILD_DIR=$1
OUTPUT_DIR=$2

git clone https://github.com/nod-ai/convperf.git
pushd convperf
git submodule update --init --recursive --jobs 8 --depth 1

# Create virtual environment.
python3 -m venv convperf.venv
source convperf.venv/bin/activate
pip install -r requirements.txt

popd # convperf.

# Build convperf.
cmake -GNinja \
-DCMAKE_C_COMPILER="${CC:-clang}" \
-DCMAKE_CXX_COMPILER="${CXX:-clang++}" \
-B "${BUILD_DIR}" convperf

cmake --build "${BUILD_DIR}"

# Run ConvPerf for several threading configurations.
# There is a non-deterministic bus in libxsmm that occurs when the number of threads > 1.
# We disable these threads for now.
# declare -a threads=( 1 2 4 8 16 )
declare -a threads=(1)

for i in "${threads[@]}"; do
export NUM_THREADS=$i
python3 "convperf/convperf.py" \
--benchmark_tool="${BUILD_DIR}/tools/benchmark_conv" \
--runners="iree,xsmm" \
--benchmark_sizes="convperf/benchmark_sizes/resnet50.json" \
--num_threads="$i"

python "convperf/convperf.py" --visualize --runtimes_file="runtimes.json"
mv runtimes.json "${OUTPUT_DIR}/resnet50_thread$i.json"
mv convs.png "${OUTPUT_DIR}/resnet50_thread$i.png"
done

0 comments on commit afad4da

Please sign in to comment.