|
| 1 | +name: Benchmark – PR (build) |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: benchmark-pr-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + bench-linux: |
| 16 | + name: 'linux ${{ matrix.sys.compiler }}-${{ matrix.sys.version }} ${{ matrix.sys.flags }}' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + sys: |
| 22 | + - { compiler: 'gcc', version: '12', flags: 'force_no_instr_set' } |
| 23 | + - { compiler: 'gcc', version: '14', flags: 'avx' } |
| 24 | + - { compiler: 'gcc', version: '13', flags: 'avx512' } |
| 25 | + - { compiler: 'gcc', version: '13', flags: 'avx512pf' } |
| 26 | + - { compiler: 'gcc', version: '13', flags: 'avx512vbmi' } |
| 27 | + - { compiler: 'gcc', version: '14', flags: 'avx512vbmi2' } |
| 28 | + - { compiler: 'gcc', version: '13', flags: 'avx512vnni' } |
| 29 | + - { compiler: 'clang', version: '17', flags: 'sse3' } |
| 30 | + - { compiler: 'clang', version: '17', flags: 'avx' } |
| 31 | + |
| 32 | + defaults: |
| 33 | + run: |
| 34 | + shell: bash -l {0} |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Setup GCC compiler |
| 38 | + if: ${{ matrix.sys.compiler == 'gcc' }} |
| 39 | + run: | |
| 40 | + GCC_VERSION=${{ matrix.sys.version }} |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION gcc-$GCC_VERSION |
| 43 | + echo "CC=gcc-$GCC_VERSION" >> $GITHUB_ENV |
| 44 | + echo "CXX=g++-$GCC_VERSION" >> $GITHUB_ENV |
| 45 | +
|
| 46 | + - name: Setup Clang compiler |
| 47 | + if: ${{ matrix.sys.compiler == 'clang' }} |
| 48 | + run: | |
| 49 | + LLVM_VERSION=${{ matrix.sys.version }} |
| 50 | + sudo apt-get update |
| 51 | + sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION g++ |
| 52 | + sudo ln -sf /usr/include/asm-generic /usr/include/asm |
| 53 | + echo "CC=clang-$LLVM_VERSION" >> $GITHUB_ENV |
| 54 | + echo "CXX=clang++-$LLVM_VERSION" >> $GITHUB_ENV |
| 55 | +
|
| 56 | + - uses: actions/checkout@v4 |
| 57 | + |
| 58 | + - name: Set conda environment |
| 59 | + uses: mamba-org/setup-micromamba@main |
| 60 | + with: |
| 61 | + environment-name: myenv |
| 62 | + environment-file: environment-dev.yml |
| 63 | + init-shell: bash |
| 64 | + cache-downloads: true |
| 65 | + |
| 66 | + - name: Setup SDE |
| 67 | + if: startsWith(matrix.sys.flags, 'avx512') |
| 68 | + run: sh install_sde.sh |
| 69 | + |
| 70 | + - name: Configure CMake |
| 71 | + env: |
| 72 | + CC: ${{ env.CC }} |
| 73 | + CXX: ${{ env.CXX }} |
| 74 | + run: | |
| 75 | + CMAKE_EXTRA_ARGS="" |
| 76 | + if [[ '${{ matrix.sys.flags }}' == 'avx' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=sandybridge"; fi |
| 77 | + if [[ '${{ matrix.sys.flags }}' == 'sse3' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=nocona"; fi |
| 78 | + if [[ '${{ matrix.sys.flags }}' == 'avx512' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=skylake-avx512"; fi |
| 79 | + if [[ '${{ matrix.sys.flags }}' == 'avx512pf' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=knl"; fi |
| 80 | + if [[ '${{ matrix.sys.flags }}' == 'avx512vbmi' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=cannonlake"; fi |
| 81 | + if [[ '${{ matrix.sys.flags }}' == 'avx512vbmi2' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=icelake-server"; fi |
| 82 | + if [[ '${{ matrix.sys.flags }}' == 'avx512vnni' ]]; then CMAKE_EXTRA_ARGS="-DTARGET_ARCH=knm"; fi |
| 83 | + cmake -S . -B _bench_build \ |
| 84 | + -G Ninja \ |
| 85 | + -DCMAKE_BUILD_TYPE=Release \ |
| 86 | + -DCMAKE_C_COMPILER=$CC \ |
| 87 | + -DCMAKE_CXX_COMPILER=$CXX \ |
| 88 | + $CMAKE_EXTRA_ARGS \ |
| 89 | + -DBUILD_BENCHMARKS=ON |
| 90 | +
|
| 91 | + - name: Build |
| 92 | + run: ninja -C _bench_build bench_algorithms |
| 93 | + |
| 94 | + - name: Run benchmarks |
| 95 | + run: | |
| 96 | + if echo '${{ matrix.sys.flags }}' | grep -q 'avx512'; then |
| 97 | + ./sde-external-9.48.0-2024-11-25-lin/sde64 -tgl -- \ |
| 98 | + ./_bench_build/benchmark/bench_algorithms \ |
| 99 | + --benchmark_format=json --benchmark_out=benchmark-result.json |
| 100 | + else |
| 101 | + ./_bench_build/benchmark/bench_algorithms \ |
| 102 | + --benchmark_format=json --benchmark_out=benchmark-result.json |
| 103 | + fi |
| 104 | +
|
| 105 | + - name: Upload benchmark artifact |
| 106 | + uses: actions/upload-artifact@v4 |
| 107 | + with: |
| 108 | + name: bench-linux-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.sys.flags }}-${{ github.sha }} |
| 109 | + path: benchmark-result.json |
| 110 | + if-no-files-found: error |
| 111 | + |
| 112 | + bench-macos: |
| 113 | + name: 'macos-${{ matrix.os }}' |
| 114 | + runs-on: macos-${{ matrix.os }} |
| 115 | + strategy: |
| 116 | + fail-fast: false |
| 117 | + matrix: |
| 118 | + os: [14, 15] |
| 119 | + |
| 120 | + defaults: |
| 121 | + run: |
| 122 | + shell: bash -e -l {0} |
| 123 | + |
| 124 | + steps: |
| 125 | + - uses: actions/checkout@v4 |
| 126 | + |
| 127 | + - name: Set conda environment |
| 128 | + uses: mamba-org/setup-micromamba@main |
| 129 | + with: |
| 130 | + environment-name: myenv |
| 131 | + environment-file: environment-dev.yml |
| 132 | + init-shell: bash |
| 133 | + cache-downloads: true |
| 134 | + |
| 135 | + - name: Configure CMake |
| 136 | + run: | |
| 137 | + cmake -S . -B _bench_build \ |
| 138 | + -DCMAKE_BUILD_TYPE=Release \ |
| 139 | + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ |
| 140 | + -DBUILD_BENCHMARKS=ON |
| 141 | +
|
| 142 | + - name: Build |
| 143 | + run: cmake --build _bench_build --target bench_algorithms --parallel 8 |
| 144 | + |
| 145 | + - name: Run benchmarks |
| 146 | + run: | |
| 147 | + ./_bench_build/benchmark/bench_algorithms \ |
| 148 | + --benchmark_format=json --benchmark_out=benchmark-result.json |
| 149 | +
|
| 150 | + - name: Upload benchmark artifact |
| 151 | + uses: actions/upload-artifact@v4 |
| 152 | + with: |
| 153 | + name: bench-macos-${{ matrix.os }}-${{ github.sha }} |
| 154 | + path: benchmark-result.json |
| 155 | + if-no-files-found: error |
0 commit comments