Skip to content

[CI][Benchmarks] Refactor Compute Runtime builds #19303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion devops/scripts/benchmarks/benches/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ def benchmarks(self) -> list[Benchmark]:
def name(self) -> str:
pass

def setup(self):
@abstractmethod
def setup(self) -> None:
return

def additional_metadata(self) -> dict[str, BenchmarkMetadata]:
Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/benchdnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def benchmarks(self) -> list:
)
return benchmarks

def setup(self):
def setup(self) -> None:
if options.sycl is None:
return

Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def git_url(self) -> str:
def git_hash(self) -> str:
return "83b9ae3ebb3563552409f3a317cdc1cf3d3ca6bd"

def setup(self):
def setup(self) -> None:
if options.sycl is None:
return

Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def benchmarks(self) -> list[Benchmark]:
# GromacsBenchmark(self, "0192", "rf", "eager"),
]

def setup(self):
def setup(self) -> None:
self.gromacs_src = git_clone(
self.directory,
"gromacs-repo",
Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/llamacpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def git_url(self) -> str:
def git_hash(self) -> str:
return "916c83bfe7f8b08ada609c3b8e583cf5301e594b"

def setup(self):
def setup(self) -> None:
if options.sycl is None:
return

Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/syclbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def git_url(self) -> str:
def git_hash(self) -> str:
return "31fc70be6266193c4ba60eb1fe3ce26edee4ca5b"

def setup(self):
def setup(self) -> None:
if options.sycl is None:
return

Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class TestSuite(Suite):
def __init__(self):
return

def setup(self):
def setup(self) -> None:
return

def name(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions devops/scripts/benchmarks/benches/umf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def __init__(self, directory):
def name(self) -> str:
return "UMF"

def setup(self):
def setup(self) -> None:
if not isUMFAvailable():
return []
return
self.built = True

def benchmarks(self) -> list[Benchmark]:
Expand Down
2 changes: 1 addition & 1 deletion devops/scripts/benchmarks/benches/velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def git_url(self) -> str:
def git_hash(self) -> str:
return "b22215c16f789100449c34bf4eaa3fb178983d69"

def setup(self):
def setup(self) -> None:
if options.sycl is None:
return

Expand Down
166 changes: 166 additions & 0 deletions devops/scripts/benchmarks/git_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Copyright (C) 2025 Intel Corporation
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from pathlib import Path
import shutil

from utils.logger import log
from utils.utils import run
from options import options


class GitProject:
def __init__(
self,
url: str,
ref: str,
directory: Path,
name: str,
force_rebuild: bool = False,
) -> None:
self._url = url
self._ref = ref
self._directory = directory
self._name = name
self._force_rebuild = force_rebuild
self._rebuild_needed = self._git_clone()

@property
def src_dir(self) -> Path:
return self._directory / f"{self._name}-src"

@property
def build_dir(self) -> Path:
return self._directory / f"{self._name}-build"

@property
def install_dir(self) -> Path:
return self._directory / f"{self._name}-install"

def needs_rebuild(self, check_build=False, check_install=False) -> bool:
"""Checks if the project needs to be rebuilt.

Args:
check_build (bool): If True, checks if the build directory exists and has some files.
check_install (bool): If True, checks if the install directory exists and has some files.

Returns:
bool: True if the project needs to be rebuilt, False otherwise.
"""
log.debug(f"Checking if project {self._name} needs rebuild.")
if self._force_rebuild:
log.debug(
f"Force rebuild is enabled for project {self._name}, rebuild needed."
)
if Path(self.build_dir).exists():
shutil.rmtree(self.build_dir)
return True
elif self._rebuild_needed:
return True
if check_build:
if self.build_dir.exists() and any(
path.is_file() for path in self.build_dir.glob("**/*")
):
log.debug(
f"Build directory {self.build_dir} exists and is not empty, no rebuild needed."
)
else:
log.debug(
f"Build directory {self.build_dir} does not exist or does not contain any file, rebuild needed."
)
return True
if check_install:
if self.install_dir.exists() and any(
path.is_file() for path in self.install_dir.glob("**/*")
):
log.debug(
f"Install directory {self.install_dir} exists and is not empty, no rebuild needed."
)
else:
log.debug(
f"Install directory {self.install_dir} does not exist or does not contain any file, rebuild needed."
)
return True
return False

def configure(
self,
extra_args: list | None = None,
install_prefix=True,
add_sycl: bool = False,
) -> None:
"""Configures the project."""
cmd = [
"cmake",
f"-S {self.src_dir}",
f"-B {self.build_dir}",
f"-DCMAKE_BUILD_TYPE=Release",
]
if install_prefix:
cmd.append(f"-DCMAKE_INSTALL_PREFIX={self.install_dir}")
if extra_args:
cmd.extend(extra_args)

run(cmd, add_sycl=add_sycl)

def build(
self,
target: str = "",
add_sycl: bool = False,
ld_library: list = [],
timeout: int | None = None,
) -> None:
"""Builds the project."""
target_arg = f"--target {target}" if target else ""
run(
f"cmake --build {self.build_dir} {target_arg} -j {options.build_jobs}",
add_sycl=add_sycl,
ld_library=ld_library,
timeout=timeout,
)

def install(self) -> None:
"""Installs the project."""
run(f"cmake --install {self.build_dir}")

def _git_clone(self) -> bool:
"""Clone a git repository into a specified directory at a specific commit.
Returns:
bool: True if the repository was cloned or updated, False if it was already up-to-date.
"""
log.debug(f"Cloning {self._url} into {self.src_dir} at commit {self._ref}")
if self.src_dir.exists() and Path(self.src_dir, ".git").exists():
log.debug(
f"Repository {self._url} already exists at {self.src_dir}, checking for updates."
)
run("git fetch", cwd=self.src_dir)
target_commit = (
run(f"git rev-parse {self._ref}", cwd=self.src_dir)
.stdout.decode()
.strip()
)
current_commit = (
run("git rev-parse HEAD", cwd=self.src_dir).stdout.decode().strip()
)
if current_commit != target_commit:
log.debug(
f"Current commit {current_commit} does not match target {target_commit}, checking out {self._ref}."
)
run("git reset --hard", cwd=self.src_dir)
run(f"git checkout {self._ref}", cwd=self.src_dir)
else:
log.debug(
f"Current commit {current_commit} matches target {target_commit}, no update needed."
)
return False
elif not self.src_dir.exists():
run(f"git clone --recursive {self._url} {self.src_dir}")
run(f"git checkout {self._ref}", cwd=self.src_dir)
else:
raise Exception(
f"The directory {self.src_dir} exists but is not a git repository."
)
log.debug(f"Cloned {self._url} into {self.src_dir} at commit {self._ref}")
return True
Loading