Skip to content
Merged
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
5 changes: 3 additions & 2 deletions python/mori/jit/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ def get_cache_root() -> Path:
def _hash_tree(paths: list[Path]) -> str:
"""Compute a short content hash over files and directories.

For directories, all ``.hpp``, ``.h``, and ``.cpp`` files are included.
For directories, all ``.hpp``, ``.h``, ``.cpp``, and ``.hip`` files are
included, so ``#include``d translation units invalidate the cache too.
"""
h = hashlib.sha256()
for p in sorted(paths):
if p.is_file():
h.update(p.read_bytes())
elif p.is_dir():
for f in sorted(p.rglob("*")):
if f.suffix in (".hpp", ".h", ".cpp"):
if f.suffix in (".hpp", ".h", ".cpp", ".hip"):
h.update(f.read_bytes())
return h.hexdigest()[:12]

Expand Down
8 changes: 6 additions & 2 deletions python/mori/jit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def compile_genco(
sub_kernels = _PARALLEL_KERNEL_GROUPS.get(kernel_name)
if sub_kernels:
source_paths = [
mori_root / "src" / "ops" / "kernels",
mori_root / "src" / "ops",
mori_root / "include" / "mori",
]
cache_dir = get_cache_dir(
Expand Down Expand Up @@ -544,7 +544,11 @@ def compile_genco(
if not source.is_file():
raise FileNotFoundError(f"Kernel source not found: {source}")

source_paths = [source, mori_root / "include" / "mori"]
# The .hip translation unit #includes sibling sources from its subsystem
# (e.g. ops kernels pull in src/ops/dispatch_combine/*), so hash the whole
# subsystem source tree; hashing only the top-level .hip reuses a stale
# .hsaco when an included file changes.
source_paths = [(mori_root / source_dir).parent, mori_root / "include" / "mori"]
cache_dir = get_cache_dir(cfg.arch, source_paths, nic, profiler=profiler, ccqe=ccqe)
hsaco_path = cache_dir / f"{kernel_name}.hsaco"

Expand Down
Loading