Skip to content

Commit db40173

Browse files
committed
[Benchmark] Add UR SubmitKernel bench
1 parent 1fef4e2 commit db40173

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

.github/workflows/benchmarks_compute.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ jobs:
5757
adapter: [
5858
{str_name: "${{inputs.str_name}}",
5959
sycl_config: "${{inputs.sycl_config_params}}",
60-
unit: "${{inputs.unit}}"}
60+
unit: "${{inputs.unit}}"
61+
}
6162
]
6263
build_type: [Release]
6364
compiler: [{c: clang, cxx: clang++}]
@@ -155,7 +156,7 @@ jobs:
155156
156157
- name: Run benchmarks
157158
id: benchmarks
158-
run: numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py ~/bench_workdir ${{github.workspace}}/sycl_build ${{ inputs.bench_script_params }}
159+
run: numactl -N 0 ${{ github.workspace }}/ur-repo/scripts/benchmarks/main.py ~/bench_workdir ${{github.workspace}}/sycl_build ${{github.workspace}}/ur-repo ${{ matrix.adapter.str_name }} ${{ inputs.bench_script_params }}
159160

160161
- name: Add comment to PR
161162
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1

scripts/benchmarks/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Scripts for running performance tests on SYCL and Unified Runtime.
99

1010
## Running
1111

12-
`$ ./main.py ~/benchmarks_workdir/ ~/llvm/build/`
12+
`$ ./main.py ~/benchmarks_workdir/ ~/llvm/build/ ~/ur adapter_name`
1313

14-
This will download and build everything in `~/benchmarks_workdir/` using the compiler in `~/llvm/build/`, and then run the benchmarks. The results will be stored in `benchmark_results.md`.
14+
This will download and build everything in `~/benchmarks_workdir/` using the compiler in `~/llvm/build/`, UR source from `~/ur` and then run the benchmarks for `adapter_name` adapter. The results will be stored in `benchmark_results.md`.
1515

1616
The scripts will try to reuse the files stored in `~/benchmarks_workdir/`, but the benchmarks will be rebuilt every time. To avoid that, use `-no-rebuild` option.
1717

scripts/benchmarks/benches/compute.py

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ class ComputeBench:
1515
def __init__(self, directory):
1616
self.directory = directory
1717
self.built = False
18+
self.adapter_short_name = {'level_zero' : 'L0'}
1819
return
1920

2021
def setup(self):
2122
if self.built:
2223
return
2324

24-
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "0f758021dce9ba32341a503739b69db057433c59")
25+
repo_path = git_clone(self.directory, "compute-benchmarks-repo", "https://github.com/intel/compute-benchmarks.git", "08c41bb8bc1762ad53c6194df6d36bfcceff4aa2")
2526
build_path = create_build_path(self.directory, 'compute-benchmarks-build')
2627

2728
configure_command = [
@@ -31,14 +32,22 @@ def setup(self):
3132
f"-DCMAKE_BUILD_TYPE=Release",
3233
f"-DBUILD_SYCL=ON",
3334
f"-DSYCL_COMPILER_ROOT={options.sycl}",
34-
f"-DALLOW_WARNINGS=ON"
35+
f"-DALLOW_WARNINGS=ON",
36+
f"-DBUILD_UR=ON",
37+
f"-DUR_BUILD_TESTS=OFF",
38+
f"-DUR_BUILD_ADAPTER_L0=ON",
39+
f"-DUR_BUILD_TESTS=OFF",
40+
f"-DUMF_DISABLE_HWLOC=ON",
41+
f"-DBENCHMARK_UR_SOURCE_DIR={options.ur_dir}",
42+
f"-DUR_BUILD_ADAPTER_{self.adapter_short_name[options.ur_adapter_name]}=ON"
3543
]
3644
run(configure_command, add_sycl=True)
3745

3846
run(f"cmake --build {build_path} -j", add_sycl=True)
3947

4048
self.built = True
4149
self.bins = os.path.join(build_path, 'bin')
50+
self.libs = os.path.join(build_path, 'lib')
4251

4352
class ComputeBenchmark(Benchmark):
4453
def __init__(self, bench, name, test):
@@ -112,6 +121,29 @@ def bin_args(self) -> list[str]:
112121
"--KernelExecTime=1"
113122
]
114123

124+
class SubmitKernelUR(ComputeBenchmark):
125+
def __init__(self, bench, ioq):
126+
self.ioq = ioq
127+
super().__init__(bench, "api_overhead_benchmark_ur", "SubmitKernel")
128+
129+
def name(self):
130+
order = "in order" if self.ioq else "out of order"
131+
return f"api_overhead_benchmark_ur SubmitKernel {order}"
132+
133+
def extra_env_vars(self) -> dict:
134+
return {"UR_ADAPTERS_FORCE_LOAD" : os.path.join(self.bench.libs, f"libur_adapter_{options.ur_adapter_name}.so")}
135+
136+
def bin_args(self) -> list[str]:
137+
return [
138+
f"--Ioq={self.ioq}",
139+
"--DiscardEvents=0",
140+
"--MeasureCompletion=0",
141+
"--iterations=100000",
142+
"--Profiling=0",
143+
"--NumKernels=10",
144+
"--KernelExecTime=1"
145+
]
146+
115147
class ExecImmediateCopyQueue(ComputeBenchmark):
116148
def __init__(self, bench, ioq, isCopyOnly, source, destination, size):
117149
self.ioq = ioq
@@ -209,4 +241,3 @@ def bin_args(self) -> list[str]:
209241
"--numberOfElementsY=256",
210242
"--numberOfElementsZ=256",
211243
]
212-

scripts/benchmarks/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def main(directory, additional_env_vars, save_name, compare_names, filter):
3131
benchmarks = [
3232
SubmitKernelSYCL(cb, 0),
3333
SubmitKernelSYCL(cb, 1),
34+
SubmitKernelUR(cb, 0),
35+
SubmitKernelUR(cb, 1),
3436
QueueInOrderMemcpy(cb, 0, 'Device', 'Device', 1024),
3537
QueueInOrderMemcpy(cb, 0, 'Host', 'Device', 1024),
3638
QueueMemcpy(cb, 'Device', 'Device', 1024),
@@ -114,6 +116,8 @@ def validate_and_parse_env_args(env_args):
114116
parser = argparse.ArgumentParser(description='Unified Runtime Benchmark Runner')
115117
parser.add_argument('benchmark_directory', type=str, help='Working directory to setup benchmarks.')
116118
parser.add_argument('sycl', type=str, help='Root directory of the SYCL compiler.')
119+
parser.add_argument('ur_dir', type=str, help='Root directory of the UR.')
120+
parser.add_argument('ur_adapter_name', type=str, help='Options to build the Unified Runtime as part of the benchmark')
117121
parser.add_argument("--no-rebuild", help='Rebuild the benchmarks from scratch.', action="store_true")
118122
parser.add_argument("--env", type=str, help='Use env variable for a benchmark run.', action="append", default=[])
119123
parser.add_argument("--save", type=str, help='Save the results for comparison under a specified name.')
@@ -131,6 +135,8 @@ def validate_and_parse_env_args(env_args):
131135
options.sycl = args.sycl
132136
options.iterations = args.iterations
133137
options.timeout = args.timeout
138+
options.ur_dir = args.ur_dir
139+
options.ur_adapter_name = args.ur_adapter_name
134140

135141
benchmark_filter = re.compile(args.filter) if args.filter else None
136142

0 commit comments

Comments
 (0)