From 9b4aa78fe5657fe9254bf56f6e77dca11e45d6bb Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 10 Sep 2024 17:18:08 +0100 Subject: [PATCH] Hoist benchmarking into reusable job Signed-off-by: Hanno Becker --- .github/workflows/bench.yml | 48 ++++------------ .github/workflows/bench_core_reusable.yml | 69 +++++++++++++++++++++++ .github/workflows/bench_ec2_reusable.yml | 41 ++++---------- 3 files changed, 90 insertions(+), 68 deletions(-) create mode 100644 .github/workflows/bench_core_reusable.yml diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index dfc9362a6..7ea643324 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -32,40 +32,14 @@ jobs: archflags: "-mcpu=cortex-a55 -march=armv8.2-a" cflags: "-static -DFORCE_AARCH64" bench_extra_args: -w exec-on-a55 - runs-on: self-hosted-${{ matrix.target.system }} - defaults: - run: - shell: nix develop .#ci -c bash -e {0} - permissions: - contents: write - if: github.repository_owner == 'pq-code-package' && (github.event.label.name == 'benchmark' || github.ref == 'refs/heads/main') - steps: - - uses: actions/checkout@v4 - - name: Setup nix - uses: ./.github/actions/setup-nix - with: - devShell: ci - script: | - ARCH=$(uname -m) - cat >> $GITHUB_STEP_SUMMARY <<-EOF - ## Setup - Architecture: $ARCH - - $(uname -a) - - $(nix --version) - - $(astyle --version) - - $(${{ matrix.target.cross_prefix }}gcc --version | grep -m1 "") - - $(bash --version | grep -m1 "") - - ## CPU Info - $(cat /proc/cpuinfo) - EOF - - name: Run benchmark - uses: ./.github/actions/bench - with: - name: ${{ matrix.target.name }} - cflags: ${{ matrix.target.cflags }} - archflags: ${{ matrix.target.archflags }} - perf: ${{ matrix.target.bench_pmu }} - store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }} - bench_extra_args: ${{ matrix.target.bench_extra_args }} - gh_token: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/bench_core_reusable.yml + with: + runner: self-hosted-${{ matrix.target.system }} + name: ${{ matrix.target.name }} + cflags: ${{ matrix.target.cflags }} + archflags: ${{ matrix.target.archflags }} + perf: ${{ matrix.target.bench_pmu }} + store_results: ${{ github.repository_owner == 'pq-code-package' && github.ref == 'refs/heads/main' }} + bench_extra_args: ${{ matrix.target.bench_extra_args }} + secrets: + inherit diff --git a/.github/workflows/bench_core_reusable.yml b/.github/workflows/bench_core_reusable.yml new file mode 100644 index 000000000..1b29f1d1c --- /dev/null +++ b/.github/workflows/bench_core_reusable.yml @@ -0,0 +1,69 @@ +name: bench-core-reusable +on: + workflow_call: + inputs: + runner: + type: string + description: Name of the runner to use + name: + type: string + description: Name for the benchmarking run + required: true + perf: + description: Method of obtaining PMU metrics (NO, PERF, PMU, M1) + required: true + default: 'PERF' + type: string + cflags: + type: string + description: CFLAGS to pass to compilation + default: '' + archflags: + type: string + description: ARCHFLAGS to pass to compilation + default: '' + bench_extra_args: + type: string + description: Further arguments to be appended to command line for `bench` script + default: '' + store_results: + type: string + description: Whether to push results to GH pages + default: 'false' +jobs: + bench: + name: Bench ${{ inputs.name }} + runs-on: ${{ inputs.runner }} + defaults: + run: + shell: nix develop .#ci -c bash -e {0} + steps: + - uses: actions/checkout@v4 + - name: Setup nix + uses: ./.github/actions/setup-nix + with: + devShell: ci + script: | + ARCH=$(uname -m) + cat >> $GITHUB_STEP_SUMMARY <<-EOF + ## Setup + Architecture: $ARCH + - $(uname -a) + - $(nix --version) + - $(astyle --version) + - $(${{ matrix.target.cross_prefix }}gcc --version | grep -m1 "") + - $(bash --version | grep -m1 "") + + ## CPU Info + $(cat /proc/cpuinfo) + EOF + - name: Run benchmark + uses: ./.github/actions/bench + with: + name: ${{ inputs.name }} + cflags: ${{ inputs.cflags }} + archflags: ${{ inputs.archflags }} + perf: ${{ inputs.perf }} + store_results: ${{ inputs.store_results }} + bench_extra_args: ${{ inputs.bench_extra_args }} + gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} diff --git a/.github/workflows/bench_ec2_reusable.yml b/.github/workflows/bench_ec2_reusable.yml index 1be2955a2..277bc1878 100644 --- a/.github/workflows/bench_ec2_reusable.yml +++ b/.github/workflows/bench_ec2_reusable.yml @@ -73,37 +73,16 @@ jobs: bench: name: Bench ${{ inputs.name }} needs: start-ec2-runner # required to start the main job when the runner is ready - runs-on: ${{ needs.start-ec2-runner.outputs.label }} # run the job on the newly created runner - steps: - - uses: actions/checkout@v4 - - name: Setup nix - uses: ./.github/actions/setup-nix - with: - devShell: ci - script: | - ARCH=$(uname -m) - cat >> $GITHUB_STEP_SUMMARY <<-EOF - ## Setup - Architecture: $ARCH - - $(uname -a) - - $(nix --version) - - $(astyle --version) - - $(${{ matrix.target.cross_prefix }}gcc --version | grep -m1 "") - - $(bash --version | grep -m1 "") - - ## CPU Info - $(cat /proc/cpuinfo) - EOF - - name: Run benchmark - uses: ./.github/actions/bench - with: - name: ${{ inputs.name }} - cflags: ${{ inputs.cflags }} - archflags: ${{ inputs.archflags }} - perf: PERF - store_results: ${{ inputs.store_results }} - bench_extra_args: ${{ inputs.bench_extra_args }} - gh_token: ${{ secrets.AWS_GITHUB_TOKEN }} + uses: ./.github/workflows/bench_core_reusable.yml + with: + runner: ${{ needs.start-ec2-runner.outputs.label }} + name: ${{ inputs.name }} + cflags: ${{ inputs.cflags }} + archflags: ${{ inputs.archflags }} + perf: PERF + store_results: ${{ inputs.store_results }} + bench_extra_args: ${{ inputs.bench_extra_args }} + secrets: inherit stop-ec2-runner: name: Stop ${{ github.event.inputs.name }} (${{ github.event.inputs.ec2_instance_type }}) permissions: