Skip to content

Commit b5986cf

Browse files
Modify benchmark scripts and CI workflow to enable gdb_mode while debugging benchmarks
1 parent 0cdfaee commit b5986cf

File tree

6 files changed

+77
-14
lines changed

6 files changed

+77
-14
lines changed

.github/workflows/sycl-linux-run-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ on:
134134
type: string
135135
default: 'false'
136136
required: False
137+
benchmark_gdb_mode:
138+
type: string
139+
required: False
140+
default: 'false'
137141

138142
in_workflow_call_mode:
139143
description: |
@@ -378,4 +382,6 @@ jobs:
378382
dry_run: ${{ inputs.benchmark_dry_run }}
379383
exit_on_failure: ${{ inputs.benchmark_exit_on_failure }}
380384
build_ref: ${{ inputs.repo_ref }}
381-
runner: ${{ inputs.runner }}
385+
gdb_mode: ${{ inputs.benchmark_gdb_mode }}
386+
env:
387+
RUNNERbenchmark__TAG: ${{ inputs.runner }}

.github/workflows/sycl-ur-perf-benchmarking.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ on:
7878
options:
7979
- 'level_zero:gpu'
8080
- 'level_zero_v2:gpu'
81+
gdb_mode:
82+
type: choice
83+
options:
84+
- false
85+
- true
86+
default: false
8187

8288
concurrency:
8389
# Cancel a currently running workflow for:
@@ -175,7 +181,7 @@ jobs:
175181
uses: ./.github/workflows/sycl-linux-run-tests.yml
176182
secrets: inherit
177183
with:
178-
name: "Benchmarks (${{ matrix.runner }}, ${{ matrix.backend }}, preset: ${{ inputs.preset }})"
184+
name: "Benchmarks (${{ matrix.runner }}, ${{ matrix.backend }}, preset: ${{ inputs.preset }}, gdb_mode: ${{ inputs.gdb_mode }})"
179185
runner: ${{ matrix.runner }}
180186
image: ghcr.io/intel/llvm/sycl_ubuntu2404_nightly:latest
181187
image_options: -u 1001 --device=/dev/dri -v /dev/dri/by-path:/dev/dri/by-path --privileged --cap-add SYS_ADMIN
@@ -185,6 +191,7 @@ jobs:
185191
benchmark_save_name: ${{ needs.sanitize_inputs_dispatch.outputs.benchmark_save_name }}
186192
benchmark_preset: ${{ inputs.preset }}
187193
benchmark_exit_on_failure: ${{ inputs.exit_on_failure }}
194+
benchmark_gdb_mode: ${{ inputs.gdb_mode }}
188195
repo_ref: ${{ needs.sanitize_inputs_dispatch.outputs.build_ref }}
189196
toolchain_artifact: ${{ needs.build_sycl_dispatch.outputs.toolchain_artifact }}
190197
toolchain_artifact_filename: ${{ needs.build_sycl_dispatch.outputs.toolchain_artifact_filename }}
@@ -233,6 +240,7 @@ jobs:
233240
benchmark_upload_results: true
234241
benchmark_save_name: ${{ matrix.save_name }}
235242
benchmark_preset: ${{ matrix.preset }}
243+
benchmark_gdb_mode: false
236244
repo_ref: ${{ matrix.ref }}
237245
toolchain_artifact: ${{ needs.build_nightly.outputs.toolchain_artifact }}
238246
toolchain_artifact_filename: ${{ needs.build_nightly.outputs.toolchain_artifact_filename }}
@@ -259,5 +267,6 @@ jobs:
259267
benchmark_preset: 'Minimal'
260268
benchmark_dry_run: true
261269
benchmark_exit_on_failure: true
270+
benchmark_gdb_mode: ${{ inputs.gdb_mode }}
262271
repo_ref: ${{ github.sha }}
263272
# END benchmark framework builds and runs on PRs path

devops/actions/run-tests/benchmark/action.yml

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ inputs:
2323
type: string
2424
required: False
2525
default: ""
26+
gdb_mode:
27+
type: string
28+
required: False
2629
# dry-run is passed only to compare.py (to not fail on regression), not to main.py (where such flag would omit all benchmark runs)
2730
dry_run:
2831
type: string
@@ -267,6 +270,7 @@ runs:
267270
env:
268271
BENCH_WORKDIR: ${{ steps.establish_outputs.outputs.BENCH_WORKDIR }}
269272
BENCHMARK_RESULTS_REPO_PATH: ${{ steps.establish_outputs.outputs.BENCHMARK_RESULTS_REPO_PATH }}
273+
LLVM_BENCHMARKS_USE_GDB: ${{ inputs.gdb_mode }}
270274
run: |
271275
# Build and run benchmarks
272276
@@ -280,6 +284,7 @@ runs:
280284
echo "::endgroup::"
281285
echo "::group::run_benchmarks"
282286
287+
export LLVM_BENCHMARKS_USE_GDB=${LLVM_BENCHMARKS_USE_GDB}
283288
numactl --cpunodebind "$NUMA_NODE" --membind "$NUMA_NODE" \
284289
./devops/scripts/benchmarks/main.py "$BENCH_WORKDIR" \
285290
--sycl "$(realpath $CMPLR_ROOT)" \
@@ -299,17 +304,21 @@ runs:
299304
echo "::endgroup::"
300305
echo "::group::compare_results"
301306
302-
python3 ./devops/scripts/benchmarks/compare.py to_hist \
303-
--avg-type EWMA \
304-
--cutoff "$(date -u -d '7 days ago' +'%Y%m%d_%H%M%S')" \
305-
--name "$SAVE_NAME" \
306-
--compare-file "${BENCHMARK_RESULTS_REPO_PATH}/results/${SAVE_NAME}_${SAVE_TIMESTAMP}.json" \
307-
--results-dir "${BENCHMARK_RESULTS_REPO_PATH}/results/" \
308-
--regression-filter '^[a-z_]+_sycl .* CPU count' \
309-
--regression-filter-type 'SYCL benchmark (measured using CPU cycle count)' \
310-
--verbose \
311-
--produce-github-summary \
312-
${{ inputs.dry_run == 'true' && '--dry-run' || '' }} \
307+
if [ "$LLVM_BENCHMARKS_USE_GDB" == "false" ]; then
308+
python3 ./devops/scripts/benchmarks/compare.py to_hist \
309+
--avg-type EWMA \
310+
--cutoff "$(date -u -d '7 days ago' +'%Y%m%d_%H%M%S')" \
311+
--name "$SAVE_NAME" \
312+
--compare-file "${BENCHMARK_RESULTS_REPO_PATH}/results/${SAVE_NAME}_${SAVE_TIMESTAMP}.json" \
313+
--results-dir "${BENCHMARK_RESULTS_REPO_PATH}/results/" \
314+
--regression-filter '^[a-z_]+_sycl .* CPU count' \
315+
--regression-filter-type 'SYCL benchmark (measured using CPU cycle count)' \
316+
--verbose \
317+
--produce-github-summary \
318+
${{ inputs.dry_run == 'true' && '--dry-run' || '' }}
319+
else
320+
echo "Skipping regression comparison due to GDB mode enabled."
321+
fi
313322
314323
echo "::endgroup::"
315324
- name: Run benchmarks integration tests

devops/scripts/benchmarks/benches/compute.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import csv
77
import io
88
import math
9+
import os
910
from enum import Enum
1011
from itertools import product
1112
from pathlib import Path
@@ -76,6 +77,7 @@ def setup(self) -> None:
7677
"compute-benchmarks",
7778
use_installdir=False,
7879
)
80+
print(self._project)
7981

8082
if not self._project.needs_rebuild():
8183
log.info(f"Rebuilding {self._project.name} skipped")
@@ -88,7 +90,15 @@ def setup(self) -> None:
8890
f"-DUSE_SYSTEM_LEVEL_ZERO=OFF",
8991
f"-DCMAKE_CXX_COMPILER=clang++",
9092
f"-DCMAKE_C_COMPILER=clang",
93+
9194
]
95+
96+
is_gdb_mode = os.environ.get("LLVM_BENCHMARKS_USE_GDB", "") == "true"
97+
if is_gdb_mode:
98+
extra_args += [
99+
f"-DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG -fdebug-info-for-profiling",
100+
]
101+
92102
if options.ur_adapter == "cuda":
93103
extra_args += [
94104
"-DBUILD_SYCL_WITH_CUDA=ON",
@@ -561,6 +571,12 @@ def __enabled_runtimes(self) -> list[RUNTIMES]:
561571
return runtimes
562572

563573
def __parse_output(self, output: str) -> list[tuple[float, float]]:
574+
is_gdb_mode = os.environ.get("LLVM_BENCHMARKS_USE_GDB", "") == "true"
575+
print(output)
576+
577+
if is_gdb_mode:
578+
return [(0.0, 0.0)]
579+
564580
csv_file = io.StringIO(output)
565581
reader = csv.reader(csv_file)
566582
next(reader, None)

devops/scripts/benchmarks/git_project.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,15 @@ def configure(
7474
add_sycl: bool = False,
7575
) -> None:
7676
"""Configures the project."""
77+
78+
is_gdb_mode = os.environ.get("LLVM_BENCHMARKS_USE_GDB", "") == "true"
79+
build_type = "RelWithDebInfo" if is_gdb_mode else "Release"
80+
7781
cmd = [
7882
"cmake",
7983
f"-S {self.src_dir}",
8084
f"-B {self.build_dir}",
81-
f"-DCMAKE_BUILD_TYPE=Release",
85+
f"-DCMAKE_BUILD_TYPE={build_type}",
8286
]
8387
if self._use_installdir:
8488
cmd.append(f"-DCMAKE_INSTALL_PREFIX={self.install_dir}")

devops/scripts/benchmarks/utils/utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ def run(
4848
if isinstance(command, str):
4949
command = command.split()
5050

51+
is_gdb_mode = os.environ.get("LLVM_BENCHMARKS_USE_GDB", "") == "true"
52+
if command[0] == "taskset" and is_gdb_mode:
53+
gdb_cmd = [
54+
"gdb",
55+
"-return-child-result",
56+
"--batch",
57+
"--ex",
58+
"set confirm off",
59+
"--ex",
60+
"run",
61+
"--ex",
62+
"bt",
63+
"--ex",
64+
"quit",
65+
"--args",
66+
] + command
67+
command = gdb_cmd
68+
print(f"Running in gdb mode: {command}")
69+
5170
env = os.environ.copy()
5271
for ldlib in ld_library:
5372
if os.path.isdir(ldlib):

0 commit comments

Comments
 (0)