Skip to content

Commit b2c82ba

Browse files
authored
[Benchmarks] remove force rebuild path, fail on error in CI, shorten CI time (#20388)
## Change in CI ### Add exit-on-failure to benchmarks CI run There was exit-on-failure option available in benchmark scripts, but it was not used by CI that checks correctness. Now it is so we catch more errors in CI. ### Speed up benchmarks CI CI was running as many interations as in normal performance measurement, which was pointless for just checking scripts correctness. Now iterations count is limited to minimum which changed benchmarks CI time from 1 hour to 15 minutes. ## Change in Benchmark scripts ### disabled one failing benchmark, fixed another Once CI exits on any failure it revealed two errors in benchmarking. One was easy to fix. Another will be done in the future and now its benchmarks are disabled ### removed needs_rebuild argument Defining whether project use install dir is in one place - GitProject constructor, not in configure and needs_rebuild arguments which was error prone. No force rebuild path any more. "--no-rebuild" option to devops/scripts/benchmarks/main.py is removed and the behavior of the script is the same as previously was with that option. This simplifies the code Previously --no-rebuild option caused compute-benchmarks, llama , etc... dependent project to be not rebuild if already compiled in proper version (commit hash hardcoded in benchmarks scripts matches). Now this behavior is default and the only one. if suite is enabled by options (--sycl, --ur, etc..), compiled and its tag (e.g. compute-benchmarks tag) matches benchmarks's hardcoded one - it is not rebuild, otherwise it is rebuild. In CI simply workdir is cleaned before running main.py, so previous behavior is preserved. During manual work, if one wants to force a rebuild a dependent repo he/she needs to remove its binary dir from workdir.
1 parent 220a474 commit b2c82ba

File tree

15 files changed

+132
-91
lines changed

15 files changed

+132
-91
lines changed

.github/workflows/sycl-linux-precommit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ jobs:
242242
benchmark_upload_results: false
243243
benchmark_preset: 'Minimal'
244244
benchmark_dry_run: true
245+
benchmark_exit_on_failure: true
245246
repo_ref: ${{ github.sha }}
246247
toolchain_artifact: ${{ needs.build.outputs.toolchain_artifact }}
247248
toolchain_artifact_filename: ${{ needs.build.outputs.toolchain_artifact_filename }}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ on:
140140
type: string
141141
default: 'false'
142142
required: False
143+
benchmark_exit_on_failure:
144+
description: |
145+
Whether or not to fail the workflow upon a failure.
146+
type: string
147+
default: 'false'
148+
required: False
143149

144150
workflow_dispatch:
145151
inputs:
@@ -211,6 +217,12 @@ on:
211217
- "build-only"
212218
- "run-only"
213219

220+
benchmark_exit_on_failure:
221+
type: choice
222+
options:
223+
- "true"
224+
- "false"
225+
214226
permissions:
215227
contents: read
216228
packages: read
@@ -358,6 +370,7 @@ jobs:
358370
save_name: ${{ inputs.benchmark_save_name }}
359371
preset: ${{ inputs.benchmark_preset }}
360372
dry_run: ${{ inputs.benchmark_dry_run }}
373+
exit_on_failure: ${{ inputs.benchmark_exit_on_failure }}
361374
build_ref: ${{ inputs.repo_ref }}
362375
env:
363376
RUNNER_TAG: ${{ inputs.runner }}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ on:
4141
description: |
4242
Upload results to https://intel.github.io/llvm/benchmarks/.
4343
required: true
44+
exit_on_failure:
45+
type: string # true/false: workflow_dispatch does not support booleans
46+
description: |
47+
Fail benchmark script on any error. Limit number of iterations to just test correctness.
48+
required: false
49+
default: 'false'
4450
runner:
4551
type: string
4652
required: true
@@ -90,6 +96,13 @@ on:
9096
- false
9197
- true
9298
default: true
99+
exit_on_failure:
100+
description: Fail benchmark script on any error. Limit number of iterations to just test correctness.
101+
type: choice
102+
options:
103+
- false
104+
- true
105+
default: false
93106
runner:
94107
description: Self-hosted runner to use for the benchmarks
95108
type: choice
@@ -193,6 +206,7 @@ jobs:
193206
benchmark_upload_results: ${{ inputs.upload_results }}
194207
benchmark_save_name: ${{ needs.sanitize_inputs.outputs.benchmark_save_name }}
195208
benchmark_preset: ${{ inputs.preset }}
209+
benchmark_exit_on_failure: ${{ inputs.exit_on_failure }}
196210
repo_ref: ${{ needs.sanitize_inputs.outputs.build_ref }}
197211
toolchain_artifact: ${{ needs.build_sycl.outputs.toolchain_artifact }}
198212
toolchain_artifact_filename: ${{ needs.build_sycl.outputs.toolchain_artifact_filename }}

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ inputs:
3232
dry_run:
3333
type: string
3434
required: False
35+
exit_on_failure:
36+
type: string
37+
required: False
3538

3639
runs:
3740
using: "composite"
@@ -192,8 +195,10 @@ runs:
192195
sycl-ls
193196
echo "-----"
194197

195-
taskset -c "$CORES" ./devops/scripts/benchmarks/main.py \
196-
"$(realpath ./llvm_test_workdir)" \
198+
WORKDIR="$(realpath ./llvm_test_workdir)"
199+
if [ -n "$WORKDIR" ] && [ -d "$WORKDIR" ] && [[ "$WORKDIR" == *llvm_test_workdir* ]]; then rm -rf "$WORKDIR" ; fi
200+
201+
taskset -c "$CORES" ./devops/scripts/benchmarks/main.py "$WORKDIR" \
197202
--sycl "$(realpath ./toolchain)" \
198203
--ur "$(realpath ./ur/install)" \
199204
--adapter "$FORCELOAD_ADAPTER" \
@@ -204,7 +209,8 @@ runs:
204209
--preset "$PRESET" \
205210
--timestamp-override "$SAVE_TIMESTAMP" \
206211
--detect-version sycl,compute_runtime \
207-
--flamegraph inclusive
212+
${{ inputs.exit_on_failure == 'true' && '--exit-on-failure --iterations 1' || '' }}
213+
# TODO: add back: "--flamegraph inclusive" once works properly
208214

209215
echo "-----"
210216
python3 ./devops/scripts/benchmarks/compare.py to_hist \

devops/scripts/benchmarks/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ using the built compiler located in `~/llvm/build/` and
3636
installed Unified Runtime in directory `~/ur_install`,
3737
and then **run** the benchmarks for `adapter_name` adapter.
3838

39+
The scripts will try to reuse the files stored in `~/benchmarks_workdir/`.
40+
If any dependant projects binaries are already built, they will not be rebuilt
41+
again if their tags match tags specified by benchmarks source code.
42+
3943
>NOTE: By default `level_zero` adapter is used.
4044
4145
>NOTE: Pay attention to the `--ur` parameter. It points directly to the directory where UR is installed.
@@ -48,10 +52,6 @@ $ cmake --build ~/ur_build -j $(nproc)
4852
$ cmake --install ~/ur_build
4953
```
5054

51-
### Rebuild
52-
The scripts will try to reuse the files stored in `~/benchmarks_workdir/`, but the benchmarks will be rebuilt every time.
53-
To avoid that, use `--no-rebuild` option.
54-
5555
## Results
5656

5757
By default, the benchmark results are not stored.

devops/scripts/benchmarks/benches/benchdnn.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ def setup(self) -> None:
6666
self.git_tag(),
6767
Path(options.workdir),
6868
"onednn",
69-
force_rebuild=True,
69+
use_installdir=False,
7070
)
7171

72+
if not self.project.needs_rebuild():
73+
log.info(f"Rebuilding {self.project.name} skipped")
74+
return
75+
7276
extra_cmake_args = [
7377
f"-DCMAKE_PREFIX_PATH={options.sycl}",
7478
"-DCMAKE_CXX_COMPILER=clang++",
@@ -80,7 +84,6 @@ def setup(self) -> None:
8084
]
8185
self.project.configure(
8286
extra_cmake_args,
83-
install_prefix=False,
8487
add_sycl=True,
8588
)
8689
self.project.build(

devops/scripts/benchmarks/benches/compute.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from git_project import GitProject
1515
from options import options
1616
from utils.result import BenchmarkMetadata, Result
17+
from utils.logger import log
1718

1819
from .base import Benchmark, Suite, TracingType
1920
from .compute_metadata import ComputeMetadataGenerator
@@ -74,9 +75,13 @@ def setup(self) -> None:
7475
self.git_hash(),
7576
Path(options.workdir),
7677
"compute-benchmarks",
77-
force_rebuild=True,
78+
use_installdir=False,
7879
)
7980

81+
if not self.project.needs_rebuild():
82+
log.info(f"Rebuilding {self.project.name} skipped")
83+
return
84+
8085
extra_args = [
8186
f"-DBUILD_SYCL=ON",
8287
f"-DSYCL_COMPILER_ROOT={options.sycl}",
@@ -96,7 +101,7 @@ def setup(self) -> None:
96101
f"-Dunified-runtime_DIR={options.ur}/lib/cmake/unified-runtime",
97102
]
98103

99-
self.project.configure(extra_args, install_prefix=False, add_sycl=True)
104+
self.project.configure(extra_args, add_sycl=True)
100105
self.project.build(add_sycl=True)
101106

102107
def additional_metadata(self) -> dict[str, BenchmarkMetadata]:
@@ -266,12 +271,13 @@ def benchmarks(self) -> list[Benchmark]:
266271

267272
# Add UR-specific benchmarks
268273
benches += [
269-
MemcpyExecute(self, RUNTIMES.UR, 400, 1, 102400, 10, 1, 1, 1, 1, 0),
270-
MemcpyExecute(self, RUNTIMES.UR, 400, 1, 102400, 10, 0, 1, 1, 1, 0),
271-
MemcpyExecute(self, RUNTIMES.UR, 100, 4, 102400, 10, 1, 1, 0, 1, 0),
272-
MemcpyExecute(self, RUNTIMES.UR, 100, 4, 102400, 10, 1, 1, 0, 0, 0),
273-
MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 0),
274-
MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 1),
274+
# TODO: multithread_benchmark_ur fails with segfault
275+
# MemcpyExecute(self, RUNTIMES.UR, 400, 1, 102400, 10, 1, 1, 1, 1, 0),
276+
# MemcpyExecute(self, RUNTIMES.UR, 400, 1, 102400, 10, 0, 1, 1, 1, 0),
277+
# MemcpyExecute(self, RUNTIMES.UR, 100, 4, 102400, 10, 1, 1, 0, 1, 0),
278+
# MemcpyExecute(self, RUNTIMES.UR, 100, 4, 102400, 10, 1, 1, 0, 0, 0),
279+
# MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 0),
280+
# MemcpyExecute(self, RUNTIMES.UR, 4096, 4, 1024, 10, 0, 1, 0, 1, 1),
275281
UsmMemoryAllocation(self, RUNTIMES.UR, "Device", 256, "Both"),
276282
UsmMemoryAllocation(self, RUNTIMES.UR, "Device", 256 * 1024, "Both"),
277283
UsmBatchMemoryAllocation(self, RUNTIMES.UR, "Device", 128, 256, "Both"),
@@ -342,11 +348,12 @@ def cpu_count_str(self, separator: str = "") -> str:
342348

343349
def get_iters(self, run_trace: TracingType):
344350
"""Returns the number of iterations to run for the given tracing type."""
345-
return (
346-
self.iterations_trace
347-
if run_trace != TracingType.NONE
348-
else self.iterations_regular
349-
)
351+
if options.exit_on_failure:
352+
# we are just testing that the benchmark runs successfully
353+
return 3
354+
if run_trace == TracingType.NONE:
355+
return self.iterations_regular
356+
return self.iterations_trace
350357

351358
def supported_runtimes(self) -> list[RUNTIMES]:
352359
"""Base runtimes supported by this benchmark, can be overridden."""
@@ -764,6 +771,7 @@ def bin_args(self, run_trace: TracingType = TracingType.NONE) -> list[str]:
764771
"--contents=Zeros",
765772
"--multiplier=1",
766773
"--vectorSize=1",
774+
"--lws=256",
767775
]
768776

769777

devops/scripts/benchmarks/benches/gromacs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setup(self) -> None:
5757
self.git_tag(),
5858
Path(options.workdir),
5959
"gromacs",
60-
force_rebuild=True,
60+
use_installdir=False,
6161
)
6262

6363
# TODO: Detect the GPU architecture and set the appropriate flags
@@ -83,8 +83,12 @@ def setup(self) -> None:
8383
if options.unitrace:
8484
extra_args.append("-DGMX_USE_ITT=ON")
8585

86-
self.project.configure(extra_args, install_prefix=False, add_sycl=True)
87-
self.project.build(add_sycl=True, ld_library=self.oneapi.ld_libraries())
86+
if self.project.needs_rebuild():
87+
self.project.configure(extra_args, add_sycl=True)
88+
self.project.build(add_sycl=True, ld_library=self.oneapi.ld_libraries())
89+
else:
90+
log.info(f"Rebuilding {self.project.name} skipped")
91+
8892
download(
8993
options.workdir,
9094
self.grappa_url(),

devops/scripts/benchmarks/benches/llamacpp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from options import options
1515
from utils.oneapi import get_oneapi
1616
from git_project import GitProject
17+
from utils.logger import log
1718

1819

1920
class LlamaCppBench(Suite):
@@ -39,7 +40,6 @@ def setup(self) -> None:
3940
self.git_hash(),
4041
Path(options.workdir),
4142
"llamacpp",
42-
force_rebuild=True,
4343
)
4444

4545
models_dir = Path(options.workdir, "llamacpp-models")
@@ -54,6 +54,10 @@ def setup(self) -> None:
5454

5555
self.oneapi = get_oneapi()
5656

57+
if not self.project.needs_rebuild():
58+
log.info(f"Rebuilding {self.project.name} skipped")
59+
return
60+
5761
extra_args = [
5862
f"-DGGML_SYCL=ON",
5963
f"-DCMAKE_C_COMPILER=clang",

devops/scripts/benchmarks/benches/syclbench.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ def setup(self) -> None:
3636
self.git_hash(),
3737
Path(options.workdir),
3838
"sycl-bench",
39-
force_rebuild=True,
39+
use_installdir=False,
4040
)
4141

42+
if not self.project.needs_rebuild():
43+
log.info(f"Rebuilding {self.project.name} skipped")
44+
return
45+
4246
extra_args = [
4347
f"-DCMAKE_CXX_COMPILER={options.sycl}/bin/clang++",
4448
f"-DCMAKE_C_COMPILER={options.sycl}/bin/clang",
@@ -53,7 +57,7 @@ def setup(self) -> None:
5357
f"-DCMAKE_CXX_FLAGS=-fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch={options.hip_arch}"
5458
]
5559

56-
self.project.configure(extra_args, install_prefix=False, add_sycl=True)
60+
self.project.configure(extra_args, add_sycl=True)
5761
self.project.build(add_sycl=True)
5862

5963
def benchmarks(self) -> list[Benchmark]:

0 commit comments

Comments
 (0)