Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions devops/actions/run-tests/benchmark/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ runs:
sycl-ls
echo "-----"

taskset -c "$CORES" ./devops/scripts/benchmarks/main.py \
"$(realpath ./llvm_test_workdir)" \
WORKDIR="$(realpath ./llvm_test_workdir)"
if [ -n "$WORKDIR" ] && [ -d "$WORKDIR" ]; then rm -rf "$WORKDIR" ; fi

taskset -c "$CORES" ./devops/scripts/benchmarks/main.py "$WORKDIR" \
--sycl "$(realpath ./toolchain)" \
--ur "$(realpath ./ur/install)" \
--adapter "$FORCELOAD_ADAPTER" \
Expand Down
4 changes: 0 additions & 4 deletions devops/scripts/benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ $ cmake --build ~/ur_build -j $(nproc)
$ cmake --install ~/ur_build
```

### Rebuild
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, a comment that scripts try to reuse binaries or rebuild projects automatically would be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applied


## Results

By default, the benchmark results are not stored.
Expand Down
3 changes: 1 addition & 2 deletions devops/scripts/benchmarks/benches/benchdnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def setup(self) -> None:
self.git_tag(),
Path(options.workdir),
"onednn",
force_rebuild=True,
use_installdir=False,
)

extra_cmake_args = [
Expand All @@ -80,7 +80,6 @@ def setup(self) -> None:
]
self.project.configure(
extra_cmake_args,
install_prefix=False,
add_sycl=True,
)
self.project.build(
Expand Down
7 changes: 4 additions & 3 deletions devops/scripts/benchmarks/benches/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def setup(self) -> None:
self.git_hash(),
Path(options.workdir),
"compute-benchmarks",
force_rebuild=True,
use_installdir=False,
)

extra_args = [
Expand All @@ -96,8 +96,9 @@ def setup(self) -> None:
f"-Dunified-runtime_DIR={options.ur}/lib/cmake/unified-runtime",
]

self.project.configure(extra_args, install_prefix=False, add_sycl=True)
self.project.build(add_sycl=True)
if self.project.needs_rebuild():
self.project.configure(extra_args, add_sycl=True)
self.project.build(add_sycl=True)

def additional_metadata(self) -> dict[str, BenchmarkMetadata]:
"""
Expand Down
4 changes: 2 additions & 2 deletions devops/scripts/benchmarks/benches/gromacs.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setup(self) -> None:
self.git_tag(),
Path(options.workdir),
"gromacs",
force_rebuild=True,
use_installdir=False,
)

# TODO: Detect the GPU architecture and set the appropriate flags
Expand All @@ -83,7 +83,7 @@ def setup(self) -> None:
if options.unitrace:
extra_args.append("-DGMX_USE_ITT=ON")

self.project.configure(extra_args, install_prefix=False, add_sycl=True)
self.project.configure(extra_args, add_sycl=True)
self.project.build(add_sycl=True, ld_library=self.oneapi.ld_libraries())
download(
options.workdir,
Expand Down
1 change: 0 additions & 1 deletion devops/scripts/benchmarks/benches/llamacpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def setup(self) -> None:
self.git_hash(),
Path(options.workdir),
"llamacpp",
force_rebuild=True,
)

models_dir = Path(options.workdir, "llamacpp-models")
Expand Down
4 changes: 2 additions & 2 deletions devops/scripts/benchmarks/benches/syclbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setup(self) -> None:
self.git_hash(),
Path(options.workdir),
"sycl-bench",
force_rebuild=True,
use_installdir=False,
)

extra_args = [
Expand All @@ -53,7 +53,7 @@ def setup(self) -> None:
f"-DCMAKE_CXX_FLAGS=-fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch={options.hip_arch}"
]

self.project.configure(extra_args, install_prefix=False, add_sycl=True)
self.project.configure(extra_args, add_sycl=True)
self.project.build(add_sycl=True)

def benchmarks(self) -> list[Benchmark]:
Expand Down
2 changes: 0 additions & 2 deletions devops/scripts/benchmarks/benches/velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def setup(self):
self.build()

def configure(self) -> None:
if options.rebuild and self.build_dir.exists():
shutil.rmtree(self.build_dir)
self.build_dir.mkdir(parents=True, exist_ok=True)

cmd = [
Expand Down
59 changes: 16 additions & 43 deletions devops/scripts/benchmarks/git_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def __init__(
ref: str,
directory: Path,
name: str,
force_rebuild: bool = False,
use_installdir: bool = True,
no_suffix_src: bool = False,
shallow_clone: bool = True,
) -> None:
self._url = url
self._ref = ref
self._directory = directory
self._name = name
self._force_rebuild = force_rebuild
self._use_installdir = use_installdir
self._no_suffix_src = no_suffix_src
self._shallow_clone = shallow_clone
self._rebuild_needed = self._setup_repo()
Expand All @@ -44,56 +44,29 @@ def build_dir(self) -> Path:
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.
def needs_rebuild(self) -> bool:
if self._rebuild_needed:
log.debug(
f"Rebuild needed because new sources were detected for project {self._name}."
)
return True

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.
dir_to_check = self.install_dir if self._use_installdir else self.build_dir

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:
if not (
dir_to_check.exists()
and any(path.is_file() for path in dir_to_check.glob("**/*"))
):
log.debug(
f"Force rebuild is enabled for project {self._name}, rebuild needed."
f"{dir_to_check} does not exist or does not contain any file, 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
log.debug(f"{dir_to_check} exists and is not empty, no rebuild needed.")
return False

def configure(
self,
extra_args: list | None = None,
install_prefix: bool = True,
add_sycl: bool = False,
) -> None:
"""Configures the project."""
Expand All @@ -103,7 +76,7 @@ def configure(
f"-B {self.build_dir}",
f"-DCMAKE_BUILD_TYPE=Release",
]
if install_prefix:
if self._use_installdir:
cmd.append(f"-DCMAKE_INSTALL_PREFIX={self.install_dir}")
if extra_args:
cmd.extend(extra_args)
Expand Down
6 changes: 0 additions & 6 deletions devops/scripts/benchmarks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,6 @@ def validate_and_parse_env_args(env_args):
help="Unified Runtime adapter to use.",
default="level_zero",
)
parser.add_argument(
"--no-rebuild",
help="Do not rebuild the benchmarks from scratch.",
action="store_true",
)
parser.add_argument(
"--redownload",
help="Always download benchmark data dependencies, even if they already exist.",
Expand Down Expand Up @@ -694,7 +689,6 @@ def validate_and_parse_env_args(env_args):
additional_env_vars = validate_and_parse_env_args(args.env)

options.workdir = args.benchmark_directory
options.rebuild = not args.no_rebuild
options.redownload = args.redownload
options.sycl = args.sycl
options.iterations = args.iterations
Expand Down
1 change: 0 additions & 1 deletion devops/scripts/benchmarks/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Options:
ur: str = None
ur_adapter: str = None
umf: str = None
rebuild: bool = True
redownload: bool = False
benchmark_cwd: str = "INVALID"
timeout: float = 600
Expand Down
15 changes: 8 additions & 7 deletions devops/scripts/benchmarks/utils/compute_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def build_gmmlib(self, repo, commit) -> tuple[Path, bool]:
log.info("Building GMMLib...")
project = GitProject(repo, commit, Path(options.workdir), "gmmlib")
rebuilt = False
if project.needs_rebuild(check_install=True):
project.configure(install_prefix=True)
if project.needs_rebuild():
project.configure()
project.build()
project.install()
rebuilt = True
Expand All @@ -74,8 +74,8 @@ def build_level_zero(self, repo, commit) -> tuple[Path, bool]:
)

rebuilt = False
if project.needs_rebuild(check_install=True):
project.configure(install_prefix=True)
if project.needs_rebuild():
project.configure()
project.build()
project.install()
rebuilt = True
Expand All @@ -88,7 +88,7 @@ def build_igc(self, repo, commit) -> tuple[Path, bool]:
log.info("Building IGC...")
igc_project = GitProject(repo, commit, Path(options.workdir), "igc")
rebuilt = False
if igc_project.needs_rebuild(check_install=True):
if igc_project.needs_rebuild():
# Clone igc dependencies by creating a GitProject instance for each dependency.
# Repos with commit hashes as refs can't be cloned shallowly.
GitProject(
Expand Down Expand Up @@ -142,7 +142,7 @@ def build_igc(self, repo, commit) -> tuple[Path, bool]:
"-DCMAKE_C_FLAGS=-Wno-error",
"-DCMAKE_CXX_FLAGS=-Wno-error",
]
igc_project.configure(extra_args=configure_args, install_prefix=True)
igc_project.configure(extra_args=configure_args)
# set timeout to 2h. IGC takes A LONG time to build if building from scratch.
igc_project.build(timeout=60 * 60 * 2)
# cmake --install doesn't work...
Expand Down Expand Up @@ -172,6 +172,7 @@ def build_compute_runtime(self):
options.compute_runtime_tag,
Path(options.workdir),
"compute-runtime",
use_installdir=False,
)

manifest_path = project.src_dir / "manifests" / "manifest.yml"
Expand All @@ -190,7 +191,7 @@ def build_compute_runtime(self):
self.igc, self.igc_rebuilt = self.build_igc(igc_repo, igc_commit)

if (
project.needs_rebuild(check_build=True)
project.needs_rebuild()
or self.level_zero_rebuilt
or self.gmmlib_rebuilt
or (options.build_igc and self.igc_rebuilt)
Expand Down
Loading