Skip to content

Commit

Permalink
Add mmperf
Browse files Browse the repository at this point in the history
  • Loading branch information
mariecwhite committed Aug 25, 2023
1 parent af6915f commit 737b15b
Show file tree
Hide file tree
Showing 9 changed files with 375 additions and 15 deletions.
18 changes: 9 additions & 9 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:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./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:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -147,7 +147,7 @@ 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:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./comparative_benchmark/jax_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -159,7 +159,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:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./comparative_benchmark/tf_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -171,7 +171,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:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b" \
"gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:b86b9274e2a7e3d57580132b5b42d1de184af83b84c1ae03f8e2d5e851ca47b9" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand Down Expand Up @@ -212,7 +212,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:692bb3ca648c474e89bad21ef89f4b33a9741e3d1cc477fa61844caddd798ba0" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
./comparative_benchmark/xla_hlo/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -224,7 +224,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:692bb3ca648c474e89bad21ef89f4b33a9741e3d1cc477fa61844caddd798ba0" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
./comparative_benchmark/jax_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -236,7 +236,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:692bb3ca648c474e89bad21ef89f4b33a9741e3d1cc477fa61844caddd798ba0" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
./comparative_benchmark/tf_xla/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand All @@ -248,7 +248,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:692bb3ca648c474e89bad21ef89f4b33a9741e3d1cc477fa61844caddd798ba0" \
"gcr.io/iree-oss/openxla-benchmark/base@sha256:8f47e2a0970dfb883d21e68637a57bed4fa96d814f84826f2ac133d4b7924bbf" \
./comparative_benchmark/pt_inductor/benchmark_all.sh \
"${TARGET_DEVICE}"\
"${RESULTS_PATH}"
Expand Down
204 changes: 204 additions & 0 deletions .github/workflows/run_mmperf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# 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 mmperf.

name: mmperf

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

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_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: mmperf-build-cpu
outputs:
build-dir: ${{ env.BUILD_DIR }}
build-dir-archive: ${{ steps.archive.outputs.build-dir-archive }}
build-dir-gcs-artifact: ${{ steps.upload.outputs.build-dir-gcs-artifact }}
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- 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 \
./microbenchmarks/mmperf/build_mmperf.sh "cpu" "${BUILD_DIR}"
- name: "Removing unused files"
run: |
find "${BUILD_DIR}" -type f -name "*.a" -o -type f -name "*.o" \
-print \
-delete
- name: "Creating build dir archive"
id: archive
env:
BUILD_DIR_ARCHIVE: ${{ env.BUILD_DIR }}.tar.zst
run: |
tar -I 'zstd -T0' \
-cf ${BUILD_DIR_ARCHIVE} ${BUILD_DIR}
echo "build-dir-archive=${BUILD_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading build dir archive"
id: upload
env:
BUILD_DIR_ARCHIVE: ${{ steps.archive.outputs.build-dir-archive }}
BUILD_DIR_GCS_ARTIFACT: ${{ env.GCS_DIR }}/${{ steps.archive.outputs.build-dir-archive }}
run: |
gcloud storage cp "${BUILD_DIR_ARCHIVE}" "${BUILD_DIR_GCS_ARTIFACT}"
echo "build-dir-gcs-artifact=${BUILD_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
build_cuda:
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: mmperf-build-cuda
outputs:
build-dir: ${{ env.BUILD_DIR }}
build-dir-archive: ${{ steps.archive.outputs.build-dir-archive }}
build-dir-gcs-artifact: ${{ steps.upload.outputs.build-dir-gcs-artifact }}
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- 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 \
./microbenchmarks/mmperf/build_mmperf.sh "cuda" "${BUILD_DIR}"
- name: "Removing unused files"
run: |
find "${BUILD_DIR}" -type f -name "*.a" -o -type f -name "*.o" \
-print \
-delete
- name: "Creating build dir archive"
id: archive
env:
BUILD_DIR_ARCHIVE: ${{ env.BUILD_DIR }}.tar.zst
run: |
tar -I 'zstd -T0' \
-cf ${BUILD_DIR_ARCHIVE} ${BUILD_DIR}
echo "build-dir-archive=${BUILD_DIR_ARCHIVE}" >> "${GITHUB_OUTPUT}"
- name: "Uploading build dir archive"
id: upload
env:
BUILD_DIR_ARCHIVE: ${{ steps.archive.outputs.build-dir-archive }}
BUILD_DIR_GCS_ARTIFACT: ${{ env.GCS_DIR }}/${{ steps.archive.outputs.build-dir-archive }}
run: |
gcloud storage cp "${BUILD_DIR_ARCHIVE}" "${BUILD_DIR_GCS_ARTIFACT}"
echo "build-dir-gcs-artifact=${BUILD_DIR_GCS_ARTIFACT}" >> "${GITHUB_OUTPUT}"
benchmark_on_c2-standard-16:
needs: [setup, build_cpu]
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=c2-standard-16
env:
BUILD_DIR: mmperf-build-cpu
RESULTS_DIR: mmperf-results-cpu
GCS_UPLOAD_PARENT_DIR: "gs://mmperf-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 mmperf for CPU"
run: |
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
./microbenchmarks/mmperf/build_mmperf.sh "cpu" "${BUILD_DIR}"
- name: "Running mmperf on CPU"
run: |
mkdir ${RESULTS_DIR}
docker run --mount="type=bind,src="${PWD}",target=/work" --workdir="/work" \
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3 \
./microbenchmarks/mmperf/run_mmperf.sh "${BUILD_DIR}" "${RESULTS_DIR}"
- name: "Uploading results"
run: |
gcloud storage cp "${RESULTS_DIR}/latest/**" "${GCS_UPLOAD_PARENT_DIR}/${GCS_UPLOAD_DIR_NAME}/"
gcloud storage cp "${RESULTS_DIR}/latest/matmul.png" "${GCS_UPLOAD_PARENT_DIR}/matmul.png"
benchmark_on_a2-highgpu-1g:
needs: [setup, build_cuda]
runs-on:
- self-hosted # must come first
- runner-group=${{ needs.setup.outputs.runner-group }}
- environment=prod
- machine-type=a2-highgpu-1g
env:
RESULTS_DIR: mmperf-results-cuda
GCS_UPLOAD_PARENT_DIR: "gs://mmperf-benchmark-artifacts/cuda"
GCS_UPLOAD_DIR_NAME: ${{ needs.setup.outputs.artifact-upload-dir }}
BUILD_DIR: ${{ needs.build_cuda.outputs.build-dir }}
BUILD_DIR_ARCHIVE: ${{ needs.build_cuda.outputs.build-dir-archive }}
BUILD_DIR_GCS_ARTIFACT: ${{ needs.build_cuda.outputs.build-dir-gcs-artifact }}
steps:
- name: "Checking out repository"
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # v3.5.0
- name: "Downloading build dir archive"
run: gcloud storage cp "${BUILD_DIR_GCS_ARTIFACT}" "${BUILD_DIR_ARCHIVE}"
- name: "Extracting build dir archive"
run: tar -xf "${BUILD_DIR_ARCHIVE}"
- name: "Running mmperf on CUDA"
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 \
./microbenchmarks/mmperf/run_mmperf.sh "${BUILD_DIR}" "${RESULTS_DIR}"
- name: "Uploading results"
run: |
export GCS_DIR_NAME="$(date +'%Y-%m-%d').$(date +'%s')"
gcloud storage cp "${RESULTS_DIR}/latest/**" "${GCS_UPLOAD_PARENT_DIR}/${GCS_UPLOAD_DIR_NAME}/"
gcloud storage cp "${RESULTS_DIR}/latest/matmul.png" "${GCS_UPLOAD_PARENT_DIR}/matmul.png"
6 changes: 5 additions & 1 deletion devtools/docker/dockerfiles/base.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ RUN apt-get update \
wget \
curl \
gnupg2 \
python3-numpy
python3-numpy \
cmake \
ninja-build \
clang \
lld

######## Python ########
WORKDIR /install-python
Expand Down
4 changes: 2 additions & 2 deletions devtools/docker/dockerfiles/cuda11.8-cudnn8.9.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# An image that includes Tensorflow 2.12.0 with GPU support.
# An image that supports CUDA.

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

######## NVIDIA ########
WORKDIR /install-cuda
Expand Down
59 changes: 59 additions & 0 deletions devtools/docker/dockerfiles/mmperf.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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 for running mmperf: https://github.com/mmperf/mmperf.
#
# mmperf benchmarks matrix-multiplication workloads on IREE and various backends
# such as OpenBLAS, MKL, TVM, Halide, CuBLAS, etc.
#
# These backends are included either in this image or as a submodule in the
# 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

######## CUDA ########
RUN apt-get update \
&& apt-get install -y \
nvidia-cuda-toolkit \
&& mkdir -p "/usr/nvvm/libdevice" \
&& ln -s "/usr/lib/nvidia-cuda-toolkit/libdevice/libdevice.10.bc" "/usr/nvvm/libdevice/libdevice.10.bc"
##############

######## MKL ########
WORKDIR /install-mkl

RUN wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB \
&& apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB \
&& sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' \
&& apt-get update \
&& apt-get install -y intel-mkl-64bit-2018.2-046 \
&& rm -rf /install-mkl

WORKDIR /

ENV MKL_DIR="/opt/intel/mkl"
##############

######## OPENBLAS ########
RUN apt-get update \
&& apt-get install -y libopenblas-dev
##############

######## BLIS ########
WORKDIR /install-blis

RUN git clone --recurse-submodules https://github.com/flame/blis \
&& cd blis \
&& ./configure --prefix=/opt/blis --enable-cblas -c amd64 \
&& make -j 32 \
&& make install \
&& rm -rf /install-blis

WORKDIR /

ENV BLIS_DIR="/opt/blis"
##############
3 changes: 2 additions & 1 deletion devtools/docker/image_deps.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"base": [],
"cuda11.8-cudnn8.9": ["base"],
"db_import": []
"db_import": [],
"mmperf": ["base"]
}
5 changes: 3 additions & 2 deletions devtools/docker/prod_digests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
gcr.io/iree-oss/openxla-benchmark/base@sha256:692bb3ca648c474e89bad21ef89f4b33a9741e3d1cc477fa61844caddd798ba0
gcr.io/iree-oss/openxla-benchmark/cuda11.8-cudnn8.9@sha256:c39107c4160e749b7c4bac18862c6c1b6d56e1aa60644a4fe323e315ffba0a0b
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/db_import@sha256:3de8a702b51ca1906fc2ef5bab2415a79e46bc132f2ceba994215539dd0ecdd4
gcr.io/iree-oss/openxla-benchmark/mmperf@sha256:ccec4f9a104686f7e374b696791acb90ebe915d3d1e8bc56f1614e25997327c3
Loading

0 comments on commit 737b15b

Please sign in to comment.