Skip to content

Commit f5e375d

Browse files
committed
[benchmarks] use manifest to build compute-runtime dependencies
Instead of hardcoding compute runtime dependencies, scripts will now fetch its manifest file to see what are the correct versions of dependencies to build them. This patch also adds an option to build IGC from source.
1 parent a6bb8fb commit f5e375d

File tree

7 files changed

+102
-17
lines changed

7 files changed

+102
-17
lines changed

.github/workflows/benchmarks-reusable.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ jobs:
205205
--umf ${{ github.workspace }}/umf_build
206206
--adapter ${{ matrix.adapter.str_name }}
207207
--compute-runtime ${{ inputs.compute_runtime_commit }}
208+
--build-igc
208209
${{ inputs.upload_report && '--output-html' || '' }}
209210
${{ inputs.bench_script_params }}
210211

scripts/benchmarks/README.md

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

1010
## Running
1111

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

1414
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

16-
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.
16+
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

1818
## Running in CI
1919

@@ -47,7 +47,27 @@ are stored [here](https://oneapi-src.github.io/unified-runtime/benchmark_results
4747
### Python
4848

4949
dataclasses-json==0.6.7
50+
PyYAML==6.0.2
51+
Mako==1.3.0
5052

5153
### System
5254

53-
libopencv-dev
55+
Sobel Filter benchmark:
56+
57+
`$ sudo apt-get install libopencv-dev`
58+
59+
### Compute-runtime and IGC
60+
61+
The scripts have an option to build compute-runtime and all related components from source:
62+
63+
`$ ./main.py ~/benchmarks_workdir/ --compute-runtime [tag] --build-igc`
64+
65+
For this to work, the system needs to have the appropriate dependencies installed.
66+
67+
compute-runtime (Ubuntu):
68+
69+
`$ sudo apt-get install cmake g++ git pkg-config`
70+
71+
IGC (Ubuntu):
72+
73+
`$ sudo apt-get install flex bison libz-dev cmake libc6 libstdc++6 python3-pip`

scripts/benchmarks/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def validate_and_parse_env_args(env_args):
244244
parser.add_argument('--ur', type=str, help='UR install prefix path', default=None)
245245
parser.add_argument('--umf', type=str, help='UMF install prefix path', default=None)
246246
parser.add_argument('--adapter', type=str, help='Options to build the Unified Runtime as part of the benchmark', default="level_zero")
247-
parser.add_argument("--no-rebuild", help='Rebuild the benchmarks from scratch.', action="store_true")
247+
parser.add_argument("--no-rebuild", help='Do not rebuild the benchmarks from scratch.', action="store_true")
248248
parser.add_argument("--env", type=str, help='Use env variable for a benchmark run.', action="append", default=[])
249249
parser.add_argument("--save", type=str, help='Save the results for comparison under a specified name.')
250250
parser.add_argument("--compare", type=str, help='Compare results against previously saved data.', action="append", default=["baseline"])
@@ -262,6 +262,7 @@ def validate_and_parse_env_args(env_args):
262262
parser.add_argument("--dry-run", help='Do not run any actual benchmarks', action="store_true", default=False)
263263
parser.add_argument("--compute-runtime", nargs='?', const=options.compute_runtime_tag, help="Fetch and build compute runtime")
264264
parser.add_argument("--iterations-stddev", type=int, help="Max number of iterations of the loop calculating stddev after completed benchmark runs", default=options.iterations_stddev)
265+
parser.add_argument("--build-igc", help="Build IGC from source instead of using the OS-installed version", action="store_true", default=options.build_igc)
265266

266267
args = parser.parse_args()
267268
additional_env_vars = validate_and_parse_env_args(args.env)
@@ -283,6 +284,10 @@ def validate_and_parse_env_args(env_args):
283284
options.dry_run = args.dry_run
284285
options.umf = args.umf
285286
options.iterations_stddev = args.iterations_stddev
287+
options.build_igc = args.build_igc
288+
289+
if args.build_igc and args.compute_runtime is None:
290+
parser.error("--build-igc requires --compute-runtime to be set")
286291
if args.compute_runtime is not None:
287292
options.build_compute_runtime = True
288293
options.compute_runtime_tag = args.compute_runtime

scripts/benchmarks/options.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Options:
3030
build_compute_runtime: bool = False
3131
extra_ld_libraries: list[str] = field(default_factory=list)
3232
extra_env_vars: dict = field(default_factory=dict)
33-
compute_runtime_tag: str = 'c1ed0334d65f6ce86d7273fe4137d1d4a5b5fa7c'
33+
compute_runtime_tag: str = '24.52.32224.8'
34+
build_igc: bool = False
3435

3536
options = Options()
3637

scripts/benchmarks/utils/compute_runtime.py

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import os
77
import re
8+
import yaml
89

910
from pathlib import Path
1011
from .utils import *
@@ -21,9 +22,7 @@ def replace_in_file(file_path, search_pattern, replacement):
2122

2223
class ComputeRuntime:
2324
def __init__(self):
24-
self.gmmlib = self.build_gmmlib()
25-
self.level_zero = self.build_level_zero()
26-
self.compute_runtime = self.build_compute_runtime(self.gmmlib, self.level_zero)
25+
self.compute_runtime = self.build_compute_runtime()
2726

2827
return
2928

@@ -32,14 +31,15 @@ def ld_libraries(self) -> list[str]:
3231
os.path.join(self.gmmlib, "lib64"),
3332
os.path.join(self.level_zero, "lib64"),
3433
os.path.join(self.compute_runtime, "bin"),
34+
os.path.join(self.igc, "lib"),
3535
]
3636

3737
def env_vars(self) -> dict:
3838
return {"ZE_ENABLE_ALT_DRIVERS" : os.path.join(self.compute_runtime, "bin", "libze_intel_gpu.so"),
3939
"OCL_ICD_FILENAMES" : os.path.join(self.compute_runtime, "bin", "libigdrcl.so")}
4040

41-
def build_gmmlib(self):
42-
self.gmmlib_repo = git_clone(options.workdir, "gmmlib-repo", "https://github.com/intel/gmmlib.git", "9104c2090158b35d440afdf8ec940d89cc7b3c6a")
41+
def build_gmmlib(self, repo, commit):
42+
self.gmmlib_repo = git_clone(options.workdir, "gmmlib-repo", repo, commit)
4343
self.gmmlib_build = os.path.join(options.workdir, "gmmlib-build")
4444
self.gmmlib_install = os.path.join(options.workdir, "gmmlib-install")
4545
configure_command = [
@@ -54,8 +54,8 @@ def build_gmmlib(self):
5454
run(f"cmake --install {self.gmmlib_build}")
5555
return self.gmmlib_install
5656

57-
def build_level_zero(self):
58-
self.level_zero_repo = git_clone(options.workdir, "level-zero-repo", "https://github.com/oneapi-src/level-zero.git", "3969f34c16a843b943b948f8fe7081ef87deb369")
57+
def build_level_zero(self, repo, commit):
58+
self.level_zero_repo = git_clone(options.workdir, "level-zero-repo", repo, commit)
5959
self.level_zero_build = os.path.join(options.workdir, "level-zero-build")
6060
self.level_zero_install = os.path.join(options.workdir, "level-zero-install")
6161

@@ -75,10 +75,64 @@ def build_level_zero(self):
7575
run(f"cmake --install {self.level_zero_build}")
7676
return self.level_zero_install
7777

78-
def build_compute_runtime(self, gmmlib, level_zero):
78+
79+
def build_igc(self, repo, commit):
80+
self.igc_repo = git_clone(options.workdir, "igc", repo, commit)
81+
self.vc_intr = git_clone(options.workdir, "vc-intrinsics", "https://github.com/intel/vc-intrinsics", "facb2076a2ce6cd6527c1e16570ba0fbaa2f1dba")
82+
self.llvm_project = git_clone(options.workdir, "llvm-project", "https://github.com/llvm/llvm-project", "llvmorg-14.0.5")
83+
llvm_projects = os.path.join(self.llvm_project, "llvm", "projects")
84+
self.ocl = git_clone(llvm_projects, "opencl-clang", "https://github.com/intel/opencl-clang", "ocl-open-140")
85+
self.translator = git_clone(llvm_projects, "llvm-spirv", "https://github.com/KhronosGroup/SPIRV-LLVM-Translator", "llvm_release_140")
86+
self.spirv_tools = git_clone(options.workdir, "SPIRV-Tools", "https://github.com/KhronosGroup/SPIRV-Tools.git", "173fe3c60a8d9c7d35d7842ae267bb9df267a127")
87+
self.spirv_headers = git_clone(options.workdir, "SPIRV-Headers", "https://github.com/KhronosGroup/SPIRV-Headers.git", "2b2e05e088841c63c0b6fd4c9fb380d8688738d3")
88+
89+
self.igc_build = os.path.join(options.workdir, "igc-build")
90+
self.igc_install = os.path.join(options.workdir, "igc-install")
91+
configure_command = [
92+
"cmake",
93+
f"-B {self.igc_build}",
94+
f"-S {self.igc_repo}",
95+
f"-DCMAKE_INSTALL_PREFIX={self.igc_install}",
96+
f"-DCMAKE_BUILD_TYPE=Release",
97+
]
98+
run(configure_command)
99+
100+
# set timeout to 30min. IGC takes A LONG time to build if building from scratch.
101+
run(f"cmake --build {self.igc_build} -j", timeout=600 * 3)
102+
# cmake --install doesn't work...
103+
run("make install", cwd=self.igc_build)
104+
return self.igc_install
105+
106+
def read_manifest(self, manifest_path):
107+
with open(manifest_path, 'r') as file:
108+
manifest = yaml.safe_load(file)
109+
return manifest
110+
111+
def get_repo_info(self, manifest, component_name):
112+
component = manifest['components'].get(component_name)
113+
if component:
114+
repo = component.get('repository')
115+
revision = component.get('revision')
116+
return repo, revision
117+
return None, None
118+
119+
def build_compute_runtime(self):
79120
self.compute_runtime_repo = git_clone(options.workdir, "compute-runtime-repo", "https://github.com/intel/compute-runtime.git", options.compute_runtime_tag)
80121
self.compute_runtime_build = os.path.join(options.workdir, "compute-runtime-build")
81122

123+
manifest_path = os.path.join(self.compute_runtime_repo, "manifests", "manifest.yml")
124+
manifest = self.read_manifest(manifest_path)
125+
126+
level_zero_repo, level_zero_commit = self.get_repo_info(manifest, 'level_zero')
127+
self.level_zero = self.build_level_zero(level_zero_repo, level_zero_commit)
128+
129+
gmmlib_repo, gmmlib_commit = self.get_repo_info(manifest, 'gmmlib')
130+
self.gmmlib = self.build_gmmlib(gmmlib_repo, gmmlib_commit)
131+
132+
if options.build_igc:
133+
igc_repo, igc_commit = self.get_repo_info(manifest, 'igc')
134+
self.igc = self.build_igc(igc_repo, igc_commit)
135+
82136
cmakelists_path = os.path.join(self.compute_runtime_repo, "level_zero", "cmake", "FindLevelZero.cmake")
83137
# specifying custom L0 is problematic...
84138
replace_in_file(cmakelists_path, r'(\$\{LEVEL_ZERO_ROOT\}\s*)', r'\1NO_DEFAULT_PATH\n')
@@ -95,9 +149,12 @@ def build_compute_runtime(self, gmmlib, level_zero):
95149
"-DNEO_ENABLE_i915_PRELIM_DETECTION=1",
96150
"-DNEO_ENABLE_I915_PRELIM_DETECTION=1",
97151
"-DNEO_SKIP_UNIT_TESTS=1",
98-
f"-DGMM_DIR={gmmlib}",
99-
f"-DLEVEL_ZERO_ROOT={level_zero}"
152+
f"-DGMM_DIR={self.gmmlib}",
153+
f"-DLEVEL_ZERO_ROOT={self.level_zero}"
100154
]
155+
if options.build_igc:
156+
configure_command.append(f"-DIGC_DIR={self.igc}")
157+
101158
run(configure_command)
102159
run(f"cmake --build {self.compute_runtime_build} -j")
103160
return self.compute_runtime_build

scripts/benchmarks/utils/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from options import options
1414
from pathlib import Path
1515

16-
def run(command, env_vars={}, cwd=None, add_sycl=False, ld_library=[]):
16+
def run(command, env_vars={}, cwd=None, add_sycl=False, ld_library=[], timeout=options.timeout):
1717
try:
1818
if isinstance(command, str):
1919
command = command.split()
@@ -32,7 +32,7 @@ def run(command, env_vars={}, cwd=None, add_sycl=False, ld_library=[]):
3232

3333
env.update(env_vars)
3434

35-
result = subprocess.run(command, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, timeout=options.timeout) # nosec B603
35+
result = subprocess.run(command, cwd=cwd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, timeout=timeout) # nosec B603
3636

3737
if options.verbose:
3838
print(result.stdout.decode())

third_party/benchmark_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ sphinxcontrib-websupport==1.2.4
4141
sphinx-rtd-theme==1.0.0
4242
urllib3==2.2.2
4343
dataclasses-json==0.6.7
44+
PyYAML==6.0.1

0 commit comments

Comments
 (0)