Compute Benchmarks #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compute Benchmarks | |
on: | |
# Can be triggered via manual "dispatch" (from workflow view in GitHub Actions tab) | |
workflow_dispatch: | |
# acceptable input for adapter-specific runs | |
inputs: | |
str_name: | |
description: Formatted adapter name | |
type: choice | |
required: true | |
default: 'level_zero' | |
options: | |
- level_zero | |
unit: | |
description: Test unit (cpu/gpu) | |
type: choice | |
required: true | |
default: 'gpu' | |
options: | |
- cpu | |
- gpu | |
pr_no: | |
description: PR number (if 0, it'll run on the main) | |
type: number | |
required: true | |
bench_script_params: | |
description: Parameters passed to script executing benchmark | |
type: string | |
required: false | |
default: '' | |
sycl_config_params: | |
description: Extra params for SYCL configuration | |
type: string | |
required: false | |
default: '' | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
e2e-build-hw: | |
# Run only on upstream; forks will not have the HW | |
if: github.repository == 'oneapi-src/unified-runtime' | |
name: Build SYCL, UR, run Compute Benchmarks | |
strategy: | |
matrix: | |
adapter: [ | |
{str_name: "${{inputs.str_name}}", | |
sycl_config: "${{inputs.sycl_config_params}}", | |
unit: "${{inputs.unit}}"} | |
] | |
build_type: [Release] | |
compiler: [{c: clang, cxx: clang++}] | |
runs-on: "${{inputs.str_name}}_PERF" | |
steps: | |
# Workspace on self-hosted runners is not cleaned automatically. | |
# We have to delete the files created outside of using actions. | |
- name: Cleanup self-hosted workspace | |
if: always() | |
run: | | |
ls -la ./ | |
rm -rf ./* || true | |
- name: Add comment to PR | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: ${{ always() && inputs.pr_no != 0 }} | |
with: | |
script: | | |
const pr_no = '${{ inputs.pr_no }}'; | |
const adapter = '${{ matrix.adapter.str_name }}'; | |
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; | |
const params = '${{ inputs.bench_script_params }}'; | |
const body = `Compute Benchmarks ${adapter} run (with params: ${params}):\n${url}`; | |
github.rest.issues.createComment({ | |
issue_number: pr_no, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}) | |
- name: Checkout UR | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
path: ur-repo | |
# We need to fetch special ref for proper PR's merge commit. Note, this ref may be absent if the PR is already merged. | |
- name: Fetch PR's merge commit | |
if: ${{ inputs.pr_no != 0 }} | |
working-directory: ${{github.workspace}}/ur-repo | |
env: | |
PR_NO: ${{ inputs.pr_no }} | |
run: | | |
git fetch -- https://github.com/${{github.repository}} +refs/pull/${PR_NO}/*:refs/remotes/origin/pr/${PR_NO}/* | |
git checkout origin/pr/${PR_NO}/merge | |
git rev-parse origin/pr/${PR_NO}/merge | |
- name: Checkout SYCL | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
repository: intel/llvm | |
ref: refs/heads/sycl | |
path: sycl-repo | |
fetch-depth: 1 | |
fetch-tags: false | |
- name: Set CUDA env vars | |
if: matrix.adapter.str_name == 'cuda' | |
run: | | |
echo "CUDA_LIB_PATH=/usr/local/cuda/lib64/stubs" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=/usr/local/cuda/compat/:/usr/local/cuda/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
- name: Configure SYCL | |
run: > | |
python3 sycl-repo/buildbot/configure.py | |
-t ${{matrix.build_type}} | |
-o ${{github.workspace}}/sycl_build | |
--cmake-gen "Ninja" | |
--ci-defaults ${{matrix.adapter.sycl_config}} | |
--cmake-opt="-DLLVM_INSTALL_UTILS=ON" | |
--cmake-opt="-DSYCL_PI_TESTS=OFF" | |
--cmake-opt="-DSYCL_PI_UR_USE_FETCH_CONTENT=OFF" | |
--cmake-opt="-DSYCL_PI_UR_SOURCE_DIR=${{github.workspace}}/ur-repo/" | |
--cmake-opt=-DCMAKE_C_COMPILER_LAUNCHER=ccache | |
--cmake-opt=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache | |
- name: Build SYCL | |
run: cmake --build ${{github.workspace}}/sycl_build -j | |
- name: Set additional env. vars | |
run: | | |
echo "${{github.workspace}}/sycl_build/bin" >> $GITHUB_PATH | |
echo "LD_LIBRARY_PATH=${{github.workspace}}/sycl_build/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
# Running (newly built) sycl-ls sets up some extra variables | |
- name: Setup SYCL variables | |
run: | | |
which clang++ sycl-ls | |
SYCL_PI_TRACE=-1 sycl-ls | |
- name: Checkout Compute Benchmarks | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
repository: intel/compute-benchmarks | |
path: compute-benchmarks-repo | |
submodules: recursive | |
- name: Configure Compute Benchmarks | |
run: > | |
cmake | |
-B ${{github.workspace}}/compute-benchmarks-build/ | |
-S ${{github.workspace}}/compute-benchmarks-repo/ | |
-DCMAKE_BUILD_TYPE=Release | |
-DBUILD_SYCL=ON | |
-DSYCL_COMPILER_ROOT=${{github.workspace}}/sycl_build | |
-DALLOW_WARNINGS=ON | |
- name: Build Compute Benchmarks | |
run: cmake --build ${{github.workspace}}/compute-benchmarks-build/ -j | |
- name: Set oneAPI Device Selector | |
run: | | |
echo "ONEAPI_DEVICE_SELECTOR=${{ matrix.adapter.str_name }}:${{ matrix.adapter.unit }}" >> $GITHUB_ENV | |
- name: Run SYCL API Overhead benchmark | |
id: benchmarks | |
run: ${{ github.workspace }}/ur-repo/.github/scripts/compute_benchmarks.py ${{ github.workspace }}/compute-benchmarks-build/bin/ ${{ inputs.bench_script_params }} | |
- name: Add comment to PR | |
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
if: ${{ always() && inputs.pr_no != 0 }} | |
with: | |
script: | | |
let markdown = "" | |
try { | |
const fs = require('fs'); | |
markdown = fs.readFileSync('benchmark_results.md', 'utf8'); | |
} catch(err) { | |
} | |
const pr_no = '${{ inputs.pr_no }}'; | |
const adapter = '${{ matrix.adapter.str_name }}'; | |
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'; | |
const test_status = '${{ steps.benchmarks.outcome }}'; | |
const job_status = '${{ job.status }}'; | |
const params = '${{ inputs.bench_script_params }}'; | |
const body = `Compute Benchmarks ${adapter} run (with params: ${params}):\n${url}\nJob status: ${job_status}. Test status: ${test_status}.\n ${markdown}`; | |
github.rest.issues.createComment({ | |
issue_number: pr_no, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: body | |
}) |