diff --git a/src/mldebug/aie_util.py b/src/mldebug/aie_util.py index db62c85..48a89f8 100644 --- a/src/mldebug/aie_util.py +++ b/src/mldebug/aie_util.py @@ -250,7 +250,7 @@ def read_control_instr(self): """ spare_reg = self.aie_iface.Memory_tile_registers["SPARE_REG"] return { - f"MEM_TILE_{c}": self.impl.read_register(c, r, spare_reg) + f"MEM_TILE_{c}{r}": self.impl.read_register(c, r, spare_reg) for c, r in self._filter_tiles(self.aie_iface.MEM_TILE_T) } diff --git a/src/mldebug/backend/core_dump_impl.py b/src/mldebug/backend/core_dump_impl.py index ea34803..f38e8ca 100644 --- a/src/mldebug/backend/core_dump_impl.py +++ b/src/mldebug/backend/core_dump_impl.py @@ -8,7 +8,7 @@ import struct from pathlib import Path from mldebug.utils import print_tile_grid -from mldebug.arch import AIE_DEV_PHX, AIE_DEV_STX, AIE_DEV_TEL, AIE_DEV_NPU3 +from mldebug.arch import AIE_DEV_PHX, AIE_DEV_STX, AIE_DEV_TEL, AIE_DEV_NPU3, load_aie_arch from .backend_interface import BackendInterface try: @@ -62,7 +62,7 @@ class CoreDumpFallbackReader: Pure Python fallback implementation for reading core dump files. Replicates the C++ CoreDumpDataAccessBackend logic. """ - def __init__(self, core_dump_file, dev_name, no_header=False): + def __init__(self, core_dump_file, dev_name, no_header=False, args=None): """ Initialize the fallback reader @@ -70,9 +70,11 @@ def __init__(self, core_dump_file, dev_name, no_header=False): core_dump_file (str): Path to the binary core dump file dev_name (str): Device name (phx, stx, telluride, npu3) no_header (bool): If True, skip header parsing and treat data as starting at offset 0 + args: Used to update device and aie_iface. """ self.filename = core_dump_file self.dev_name = dev_name.lower() + self.args = args self.file_handle = None # Without a header to parse, we have no way to recover from an unknown device name. @@ -165,7 +167,8 @@ def _parse_header(self): if len(metadata_data) != 6: raise RuntimeError("Core dump file is corrupted: cannot read device metadata") - hw_gen, core_row_start, mem_row_start, mem_tile_rows, total_rows, total_cols = struct.unpack(" None: + def __init__(self, aie_overlay_tiles, ctx_id, pid, dev_name, core_dump_file=None, no_header=False, args=None) -> None: """ Initialize the Core Dump backend @@ -348,6 +358,7 @@ def __init__(self, aie_overlay_tiles, ctx_id, pid, dev_name, core_dump_file=None core_dump_file: Path to core dump file (required) no_header: If True, parse core dump assuming no header (data starts at offset 0). Forces use of the Python fallback reader. + args: Used for device management """ self.overlay_aie_core_tiles = aie_overlay_tiles self.pc_brkpts = [0, 0] @@ -360,7 +371,8 @@ def __init__(self, aie_overlay_tiles, ctx_id, pid, dev_name, core_dump_file=None if no_header or not HAS_XRT_BACKEND: # Python fallback reader is required to support headerless parsing - #print("[INFO] --no_header specified: using Python fallback reader (C++ binding does not support headerless mode)") + #print("[INFO] --no_header specified: using Python fallback reader " + # "(C++ binding does not support headerless mode)") self.use_fallback = True else: # Try to initialize the C++ binding first @@ -371,7 +383,7 @@ def __init__(self, aie_overlay_tiles, ctx_id, pid, dev_name, core_dump_file=None self.use_fallback = True if self.use_fallback: - self.fallback_reader = CoreDumpFallbackReader(core_dump_file, dev_name, no_header=no_header) + self.fallback_reader = CoreDumpFallbackReader(core_dump_file, dev_name, no_header=no_header, args=args) print("[INFO] Core Dump backend is read-only. Write/control operations will be ignored.") diff --git a/src/mldebug/backend/factory.py b/src/mldebug/backend/factory.py index 26abfe3..4bda2e1 100644 --- a/src/mldebug/backend/factory.py +++ b/src/mldebug/backend/factory.py @@ -69,5 +69,6 @@ def create_backend(backend_type, config): core_dump_mod = importlib.import_module("mldebug.backend.core_dump_impl") return core_dump_mod.CoreDumpImpl( config.tiles, config.ctx_id, config.pid, config.device, - core_dump_file=config.core_dump_file, no_header=config.no_header + core_dump_file=config.core_dump_file, no_header=config.no_header, + args=config.args, )