Skip to content

Add benchmarking with CI job #2

Add benchmarking with CI job

Add benchmarking with CI job #2

Workflow file for this run

name: Benchmarks
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
concurrency:
group: benchmarks-${{ github.ref }}
cancel-in-progress: true
jobs:
bench-linux:
name: 'linux ${{ matrix.sys.compiler }}-${{ matrix.sys.version }} ${{ matrix.sys.flags }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sys:
- { compiler: 'gcc', version: '12', flags: 'force_no_instr_set' }
- { compiler: 'gcc', version: '14', flags: 'avx' }
- { compiler: 'gcc', version: '13', flags: 'avx512' }
- { compiler: 'gcc', version: '13', flags: 'avx512pf' }
- { compiler: 'gcc', version: '13', flags: 'avx512vbmi' }
- { compiler: 'gcc', version: '14', flags: 'avx512vbmi2' }
- { compiler: 'gcc', version: '13', flags: 'avx512vnni' }
- { compiler: 'clang', version: '17', flags: 'sse3' }
- { compiler: 'clang', version: '17', flags: 'avx' }
env:
PLATFORM: linux-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.sys.flags }}
defaults:
run:
shell: bash -l {0}
steps:
- name: Setup GCC compiler
if: ${{ matrix.sys.compiler == 'gcc' }}
run: |
GCC_VERSION=${{ matrix.sys.version }}
sudo apt-get update
sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION gcc-$GCC_VERSION
echo "CC=gcc-$GCC_VERSION" >> $GITHUB_ENV
echo "CXX=g++-$GCC_VERSION" >> $GITHUB_ENV
- name: Setup Clang compiler
if: ${{ matrix.sys.compiler == 'clang' }}
run: |
LLVM_VERSION=${{ matrix.sys.version }}
sudo apt-get update
sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION g++
sudo ln -sf /usr/include/asm-generic /usr/include/asm
echo "CC=clang-$LLVM_VERSION" >> $GITHUB_ENV
echo "CXX=clang++-$LLVM_VERSION" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Set conda environment
uses: mamba-org/setup-micromamba@main
with:
environment-name: myenv
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true
- name: Setup SDE
if: startsWith(matrix.sys.flags, 'avx512')
run: sh install_sde.sh
- name: Configure CMake
env:
CC: ${{ env.CC }}
CXX: ${{ env.CXX }}
run: |
if [[ '${{ matrix.sys.flags }}' == 'avx' ]]; then CXX_FLAGS="$CXX_FLAGS -march=sandybridge"; fi
if [[ '${{ matrix.sys.flags }}' == 'sse3' ]]; then CXX_FLAGS="$CXX_FLAGS -march=nocona"; fi
if [[ '${{ matrix.sys.flags }}' == 'avx512' ]]; then CXX_FLAGS="$CXX_FLAGS -march=skylake-avx512"; fi
if [[ '${{ matrix.sys.flags }}' == 'avx512pf' ]]; then CXX_FLAGS="$CXX_FLAGS -march=knl"; fi
if [[ '${{ matrix.sys.flags }}' == 'avx512vbmi' ]]; then CXX_FLAGS="$CXX_FLAGS -march=cannonlake"; fi
if [[ '${{ matrix.sys.flags }}' == 'avx512vbmi2' ]]; then CXX_FLAGS="$CXX_FLAGS -march=icelake-server"; fi
if [[ '${{ matrix.sys.flags }}' == 'avx512vnni' ]]; then CXX_FLAGS="$CXX_FLAGS -march=knm"; fi
cmake -S . -B _bench_build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=$CC \
-DCMAKE_CXX_COMPILER=$CXX \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DBUILD_BENCHMARKS=ON
- name: Build
run: ninja -C _bench_build bench_algorithms
- name: Run benchmarks
run: |
if echo '${{ matrix.sys.flags }}' | grep -q 'avx512'; then
./sde-external-9.48.0-2024-11-25-lin/sde64 -tgl -- \
./_bench_build/benchmark/bench_algorithms \
--benchmark_repetitions=10 --benchmark_min_time=0.1s \
--benchmark_out=benchmark-result.json
else
./_bench_build/benchmark/bench_algorithms \
--benchmark_repetitions=10 --benchmark_min_time=0.1s \
--benchmark_out=benchmark-result.json
fi
- name: Install compare tool dependencies
run: |
python3 -m venv _gbench_venv
_gbench_venv/bin/pip install --quiet -r "$CONDA_PREFIX/share/googlebenchmark/tools/requirements.txt"
- name: Publish results to job summary
run: |
{
echo "## Benchmarks: \`$PLATFORM\`"
echo
echo '```'
_gbench_venv/bin/python "$CONDA_PREFIX/share/googlebenchmark/tools/compare.py" --no-color -a \
filters benchmark-result.json BM_std_ BM_xsimd_
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload benchmark artifact
uses: actions/upload-artifact@v4
with:
name: bench-${{ env.PLATFORM }}
path: benchmark-result.json
if-no-files-found: error
bench-macos:
name: 'macos-${{ matrix.os }}'
runs-on: macos-${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [14, 15]
env:
PLATFORM: macos-${{ matrix.os }}
defaults:
run:
shell: bash -e -l {0}
steps:
- uses: actions/checkout@v4
- name: Set conda environment
uses: mamba-org/setup-micromamba@main
with:
environment-name: myenv
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true
- name: Configure CMake
run: |
cmake -S . -B _bench_build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \
-DBUILD_BENCHMARKS=ON
- name: Build
run: cmake --build _bench_build --target bench_algorithms --parallel 8
- name: Run benchmarks
run: |
./_bench_build/benchmark/bench_algorithms \
--benchmark_repetitions=10 --benchmark_min_time=0.1s \
--benchmark_out=benchmark-result.json
- name: Install compare tool dependencies
run: |
python3 -m venv _gbench_venv
_gbench_venv/bin/pip install --quiet -r "$CONDA_PREFIX/share/googlebenchmark/tools/requirements.txt"
- name: Publish results to job summary
run: |
{
echo "## Benchmarks: \`$PLATFORM\`"
echo
echo '```'
_gbench_venv/bin/python "$CONDA_PREFIX/share/googlebenchmark/tools/compare.py" --no-color -a \
filters benchmark-result.json BM_std_ BM_xsimd_
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
- name: Upload benchmark artifact
uses: actions/upload-artifact@v4
with:
name: bench-${{ env.PLATFORM }}
path: benchmark-result.json
if-no-files-found: error