From 558e4278bd6a41c3096800b88e9a16bbb7ba7f86 Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:04:54 -0500 Subject: [PATCH 1/3] Runtime frame trace: launch arguments, allocations, sizes, resets and an injected failure The recording device decodes the arguments of the encoder, decoder and block kernels (and Model L's, per clean/l/FORMATS.md): device addresses as allocation + offset, ints, the encoder / decoder parameters. Flags for per-frame render sizes, game resets, a failing launch, the model format and map. New checks for Model M: dataflow encoder -> enc1 and dec1 -> decoder, buffer extents, the history between frames, reset and parity, changing sizes, a failed launch stopping its frame. Nothing changes in the runtime. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/tests/runtime_frame_trace.cpp | 183 +++++++++++++++++++++--- clean/tests/test_runtime_frame_trace.py | 144 ++++++++++++++++--- 2 files changed, 292 insertions(+), 35 deletions(-) diff --git a/clean/tests/runtime_frame_trace.cpp b/clean/tests/runtime_frame_trace.cpp index 9b96100d..9041e636 100644 --- a/clean/tests/runtime_frame_trace.cpp +++ b/clean/tests/runtime_frame_trace.cpp @@ -1,19 +1,31 @@ // SPDX-License-Identifier: MIT // The runtime's frame sequence on the CPU, without a GPU: the runtime (clean/runtime/runtime.cpp) runs whole frames on -// a recording device (host memory; launches are recorded, not executed). For clean/tests/test_runtime_frame_trace.py. +// a recording device (host memory; launches are recorded, not executed). For clean/tests/test_runtime_frame_trace.py +// and clean/l/runtime/tests/test_l_runtime_frame.py. // -// runtime_frame_trace [runtime options] +// runtime_frame_trace [runtime options] [flags] // -// The model is read in the converter's raw layout (model_format 1). Prints the create result, then one line per -// device event of every frame: "load [ as ]", "launch "; "ERR " -// on a failure. The code object files are not read: names in the build folder (empty files) select the runtime's -// optional paths as real code objects would. Inputs are zeros (the recording device does not compute), so only the -// sequence is meaningful. +// rw x rh is the maximum render size. Flags: +// --format= model_format (default 1: the converter's raw layout; 2: model.wgcm, with --map) +// --map= the converter map (map_path) +// --sizes=WxH,... the render size of frame 0, 1, ... (repeated; default: the maximum every frame) +// --reset=f,... frames the game asks for a reset (WgRtFrame.reset = 1) +// --fail=@ that kernel's launch fails in that frame (the device returns false) +// +// Prints the create result and the allocations ("alloc b "), the code objects loaded ("load [ as +// ]"), then per frame "frame index parity

reset rw rh " (wg_rt_info) and one line per +// launch: "launch ", followed for the kernels of the table below by " | " and the decoded +// arguments: a device address as b+ (allocation k) or 0, an int as its value, the encoder and decoder +// parameters as E{rw,rh,fw,fh,frame,reset} / D{rw,rh,fw,fh,reset}. A failed frame prints what was launched up to the +// failure and "ERR frame : "; the next frame runs. "ERR " at create. The code object files are not +// read: names in the build folder (empty files) select the runtime's optional paths as real code objects would. Inputs +// are zeros (the recording device does not compute): the sequence and the arguments are what is checked. #include #include #include #include #include +#include #include #include @@ -25,20 +37,69 @@ using namespace wgrt; namespace { +// The parameter structures the runtime passes (clean/runtime/runtime.cpp; kernels/encoder.hip WgEncParams, +// kernels/decoder.hip WgDecParams): only the fields printed are named. +struct EncParams { + int rw, rh, fw, fh, hw, hh, frame, reset, depth_inverted, pad0; + float f[19]; +}; +static_assert(sizeof(EncParams) == 116, "EncParams"); +struct DecParams { + int rw, rh, fw, fh, reset, pad0; + float f[8]; +}; +static_assert(sizeof(DecParams) == 56, "DecParams"); + +// Argument kinds per kernel (name after any "tag/"): p = device address, i = int, E / D = the parameters above. A name +// ending in '*' matches every kernel that starts with it (only its first arguments, which all forms share). +struct Signature { + const char* name; + const char* kinds; +}; +const Signature kSignatures[] = { + {"input_encoder", "ppppppppppppE"}, // Model M's encoder and Model L's values (q in place of the features) + {"coef_decoder", "ppppppppD"}, // Model M's decoder (also its pack12 form) + {"swin_block_*", "ppppiiii"}, // Model M's blocks: x, skip, out, w, H, W, ox, oy + {"l_swin_block_c32*", "ppppiiii"}, // Model L's blocks (clean/l/FORMATS.md) + {"l_linear_32_32_relu", "pppi"}, + {"l_linear_32_32_f16", "pppi"}, + {"l_project_gather", "pppii"}, + {"l_dec_project", "pppii"}, + {"l_coef", "ppppppD"}, +}; + +const char* kinds_of(const std::string& kernel) { + const size_t slash = kernel.find('/'); + const std::string k = slash == std::string::npos ? kernel : kernel.substr(slash + 1); + for (const Signature& s : kSignatures) { + const size_t n = std::strlen(s.name); + if (s.name[n - 1] == '*' ? k.compare(0, n - 1, s.name, n - 1) == 0 : k == s.name) return s.kinds; + } + return nullptr; +} + class RecordingDevice : public Device { public: std::vector* log; std::map> mem; + std::map index; // allocation number of each block + int allocs = 0, frame = -1, fail_frame = -1; + std::string fail_kernel; DevPtr next = 0x10000; explicit RecordingDevice(std::vector* l) : log(l) {} std::string name() const override { return "recording device (CPU test)"; } bool alloc(DevPtr* p, size_t bytes) override { *p = next; mem[next].assign(bytes ? bytes : 1, 0); + index[next] = allocs; + log->push_back("alloc b" + std::to_string(allocs++) + " " + std::to_string(bytes)); next += (bytes + 0xFFFF) / 0x10000 * 0x10000 + 0x10000; return true; } - void free(DevPtr p) override { mem.erase(p); } + void free(DevPtr p) override { + mem.erase(p); + index.erase(p); + } uint8_t* at(DevPtr p, size_t n) { auto it = mem.upper_bound(p); if (it == mem.begin()) return nullptr; @@ -46,6 +107,14 @@ class RecordingDevice : public Device { if (p - it->first + n > it->second.size()) return nullptr; return it->second.data() + (p - it->first); } + std::string addr(DevPtr p) { + if (!p) return "0"; + auto it = mem.upper_bound(p); + if (it == mem.begin()) return "?" + std::to_string(p); + --it; + if (p - it->first >= it->second.size()) return "?" + std::to_string(p); + return "b" + std::to_string(index[it->first]) + "+" + std::to_string(p - it->first); + } bool upload(DevPtr dst, const void* src, size_t n) override { uint8_t* d = at(dst, n); if (d && n) std::memcpy(d, src, n); @@ -76,8 +145,36 @@ class RecordingDevice : public Device { log->back() += " as " + tag; return true; } - bool launch(const std::string& kernel, unsigned grid, unsigned block, void**) override { - log->push_back("launch " + kernel + " " + std::to_string(grid) + " " + std::to_string(block)); + bool launch(const std::string& kernel, unsigned grid, unsigned block, void** args) override { + if (frame == fail_frame && kernel == fail_kernel) { + err_ = "injected launch failure: " + kernel; + log->push_back("failed " + kernel); + return false; + } + std::string line = "launch " + kernel + " " + std::to_string(grid) + " " + std::to_string(block); + if (const char* kinds = kinds_of(kernel)) { + line += " |"; + for (size_t i = 0; kinds[i]; ++i) { + line += " "; + switch (kinds[i]) { + case 'p': line += addr(*static_cast(args[i])); break; + case 'i': line += std::to_string(*static_cast(args[i])); break; + case 'E': { + const EncParams& e = *static_cast(args[i]); + line += "E{" + std::to_string(e.rw) + "," + std::to_string(e.rh) + "," + std::to_string(e.fw) + "," + + std::to_string(e.fh) + "," + std::to_string(e.frame) + "," + std::to_string(e.reset) + "}"; + break; + } + case 'D': { + const DecParams& d = *static_cast(args[i]); + line += "D{" + std::to_string(d.rw) + "," + std::to_string(d.rh) + "," + std::to_string(d.fw) + "," + + std::to_string(d.fh) + "," + std::to_string(d.reset) + "}"; + break; + } + } + } + } + log->push_back(line); return true; } bool sync() override { return true; } @@ -88,6 +185,17 @@ class RecordingDevice : public Device { bool elapsed_done_ms(int, int, float* ms) override { return *ms = 0.0f, true; } }; +std::vector split(const std::string& s, char sep) { + std::vector out; + for (size_t a = 0; a <= s.size();) { + size_t b = s.find(sep, a); + if (b == std::string::npos) b = s.size(); + if (b > a) out.push_back(s.substr(a, b - a)); + a = b + 1; + } + return out; +} + } // namespace // The device backends are not linked (runtime_create gets the recording device); the runtime still names them. @@ -116,10 +224,43 @@ int main(int argc, char** argv) { cfg.oh = std::atoi(argv[6]); cfg.depth_inverted = 1; cfg.auto_exposure = 0; - cfg.runtime_options = argc > 8 ? argv[8] : ""; const int frames = std::atoi(argv[7]); + std::string options, map_path, fail; + std::vector> sizes; + std::set resets; + for (int a = 8; a < argc; ++a) { + const std::string s = argv[a]; + if (s.compare(0, 9, "--format=") == 0) { + cfg.model_format = std::atoi(s.c_str() + 9); + } else if (s.compare(0, 6, "--map=") == 0) { + map_path = s.substr(6); + } else if (s.compare(0, 8, "--sizes=") == 0) { + for (const std::string& wh : split(s.substr(8), ',')) { + const size_t x = wh.find('x'); + if (x == std::string::npos) return std::printf("ERR bad size %s\n", wh.c_str()), 2; + sizes.emplace_back(std::atoi(wh.c_str()), std::atoi(wh.c_str() + x + 1)); + } + } else if (s.compare(0, 8, "--reset=") == 0) { + for (const std::string& f : split(s.substr(8), ',')) resets.insert(std::atoi(f.c_str())); + } else if (s.compare(0, 7, "--fail=") == 0) { + fail = s.substr(7); + } else if (s.compare(0, 2, "--") == 0) { + return std::printf("ERR unknown flag %s\n", s.c_str()), 2; + } else { + options = s; + } + } + cfg.runtime_options = options.c_str(); + cfg.map_path = map_path.empty() ? nullptr : map_path.c_str(); + auto dev = std::make_unique(&log); + RecordingDevice* rec = dev.get(); + if (!fail.empty()) { + const size_t at = fail.find('@'); + rec->fail_kernel = fail.substr(0, at); + rec->fail_frame = at == std::string::npos ? 0 : std::atoi(fail.c_str() + at + 1); + } std::string err; - Runtime* rt = runtime_create(cfg, std::make_unique(&log), &err); + Runtime* rt = runtime_create(cfg, std::move(dev), &err); if (!rt) return std::printf("ERR create: %s\n", err.c_str()), 0; std::printf("create ok model %s\n", runtime_model(rt)); for (const std::string& l : log) std::printf("%s\n", l.c_str()); @@ -127,18 +268,26 @@ int main(int argc, char** argv) { const size_t px = (size_t)cfg.max_rw * cfg.max_rh; std::vector color(px * 3, 0.0f), depth(px, 0.0f), motion(px * 2, 0.0f); for (int f = 0; f < frames; ++f) { - if (wg_rt_upload_inputs(rt, cfg.max_rw, cfg.max_rh, color.data(), depth.data(), motion.data()) != 0) + const int rw = sizes.empty() ? cfg.max_rw : sizes[f % sizes.size()].first; + const int rh = sizes.empty() ? cfg.max_rh : sizes[f % sizes.size()].second; + rec->frame = f; + if (wg_rt_upload_inputs(rt, rw, rh, color.data(), depth.data(), motion.data()) != 0) return std::printf("ERR upload: %s\n", runtime_error(rt).c_str()), 0; WgRtFrame fr = WgRtFrame(); - fr.rw = cfg.max_rw; - fr.rh = cfg.max_rh; + fr.rw = rw; + fr.rh = rh; fr.mv_scale[0] = fr.mv_scale[1] = 1.0f; fr.exposure = 1.0f; fr.pre_exposure = 1.0f; - if (!runtime_frame(rt, fr, nullptr)) return std::printf("ERR frame %d: %s\n", f, runtime_error(rt).c_str()), 0; - std::printf("frame %d\n", f); + fr.reset = resets.count(f) ? 1 : 0; + const bool ok = runtime_frame(rt, fr, nullptr); + WgRtFrameInfo info = WgRtFrameInfo(); + wg_rt_info(rt, &info); + std::printf("frame %d index %d parity %d reset %d rw %d rh %d\n", f, info.index, info.parity, info.reset, info.rw, + info.rh); for (const std::string& l : log) std::printf("%s\n", l.c_str()); log.clear(); + if (!ok) std::printf("ERR frame %d: %s\n", f, runtime_error(rt).c_str()); } std::printf("kernels %s\n", runtime_kernels(rt)); runtime_destroy(rt); diff --git a/clean/tests/test_runtime_frame_trace.py b/clean/tests/test_runtime_frame_trace.py index 20478c80..ea2dd5d1 100644 --- a/clean/tests/test_runtime_frame_trace.py +++ b/clean/tests/test_runtime_frame_trace.py @@ -9,6 +9,10 @@ - a full build's optional code objects (names only) select the default paths: pack12 decoder, dec1 fused with dec0, wave64 post; - the same run twice gives the same trace; +- the recorder's arguments: the encoder's features are enc1's input and dec1's output the decoder's (same buffer), + every one large enough for its map; the render size, the padded grid, reset and parity in the encoder's and + decoder's parameters, with the render size changing between frames (aligned and non-aligned) and a game reset; +- a launch that fails stops its frame there (nothing after it), and the next frame runs whole; - model=L is refused at create for now. The runtime options of the environment (WG_*) are removed for the runs. Built with the host C++ compiler @@ -53,16 +57,16 @@ def model_dir(): SHIPPING = ("decoder__pack12.co", "dec1_dec0__pack12.co", "post_w64.co") -def run_trace(rw=64, rh=64, ow=96, oh=96, frames=3, options="", build_files=()): +def run_trace(rw=64, rh=64, ow=96, oh=96, frames=3, options="", build_files=(), flags=()): """The program's output lines. The build folder holds empty files of the names in build_files (the recording - device reads no code object; the runtime chooses its paths by the names present).""" + device reads no code object; the runtime chooses its paths by the names present). flags: the program's --flags.""" build = tempfile.mkdtemp(prefix="wg_ftb_") for n in build_files: open(os.path.join(build, n), "wb").close() env = {k: v for k, v in os.environ.items() if not k.upper().startswith("WG_")} try: - r = subprocess.run([trace_exe(), build, model_dir(), str(rw), str(rh), str(ow), str(oh), str(frames), options], - capture_output=True, text=True, env=env, timeout=600) + r = subprocess.run([trace_exe(), build, model_dir(), str(rw), str(rh), str(ow), str(oh), str(frames), options, + *flags], capture_output=True, text=True, env=env, timeout=600) finally: shutil.rmtree(build, ignore_errors=True) if r.returncode != 0: @@ -70,22 +74,65 @@ def run_trace(rw=64, rh=64, ow=96, oh=96, frames=3, options="", build_files=()): return r.stdout.splitlines() +class Trace: + """A parsed run: create (the first line), allocs {k: bytes}, loads, frames [{"info": {...}, "launches": [Launch], + "failed": kernel or None, "error": message or None}], kernels {key: value}.""" + + def __init__(self, lines): + self.create, self.allocs, self.loads, self.frames, self.kernels = lines[0], {}, [], [], {} + for ln in lines[1:]: + if ln.startswith("alloc b"): + k, n = ln[7:].split(" ") + self.allocs[int(k)] = int(n) + elif ln.startswith("load "): + self.loads.append(ln[5:]) + elif ln.startswith("frame "): + f = ln.split(" ") + info = {f[i]: int(f[i + 1]) for i in range(2, len(f) - 1, 2)} + self.frames.append({"info": info, "launches": [], "failed": None, "error": None}) + elif ln.startswith("launch "): + self.frames[-1]["launches"].append(Launch(ln[7:])) + elif ln.startswith("failed "): + self.frames[-1]["failed"] = ln[7:] + elif ln.startswith("ERR frame "): + self.frames[-1]["error"] = ln.split(": ", 1)[1] + elif ln.startswith("kernels "): + self.kernels = dict(kv.split("=", 1) for kv in ln[8:].split(" ") if "=" in kv) + else: + raise AssertionError("unexpected line: " + ln) + + def extent(self, addr): + """Bytes from a decoded address b+ to the end of its allocation.""" + k, off = addr[1:].split("+") + return self.allocs[int(k)] - int(off) + + +class Launch: + """One launch line: kernel, grid, block and, for the kernels the recorder decodes, args (strings: b+, + 0, an int, E{...} / D{...}).""" + + def __init__(self, text): + head, _, tail = text.partition(" | ") + self.kernel, g, b = head.split(" ") + self.grid, self.block = int(g), int(b) + self.args = tail.split(" ") if tail else [] + + def kgb(self): + return (self.kernel, self.grid, self.block) + + def params(self, i): + """The values of E{...} / D{...} at argument i, as ints.""" + return [int(v) for v in self.args[i][2:-1].split(",")] + + def parse(lines): """(create line, [loaded code objects], [[(kernel, grid, block)] per frame], kernels line).""" - loads, frames, kernels = [], [], None - for ln in lines[1:]: - if ln.startswith("load "): - loads.append(ln[5:]) - elif ln.startswith("frame "): - frames.append([]) - elif ln.startswith("launch "): - k, g, b = ln[7:].split(" ") - frames[-1].append((k, int(g), int(b))) - elif ln.startswith("kernels "): - kernels = dict(kv.split("=", 1) for kv in ln[8:].split(" ") if "=" in kv) - else: - raise AssertionError("unexpected line: " + ln) - return lines[0], loads, frames, kernels + t = Trace(lines) + return t.create, t.loads, [[ln.kgb() for ln in f["launches"]] for f in t.frames], t.kernels + + +def ceil32(v): + return -(-v // 32) * 32 class ModelM(unittest.TestCase): @@ -122,6 +169,67 @@ def test_shipping_build(self): def test_repeatable(self): self.assertEqual(run_trace(rw=80, rh=48, ow=120, oh=72), run_trace(rw=80, rh=48, ow=120, oh=72)) + def test_dataflow_and_extents(self): + """The encoder's features are what enc1's first block reads, dec1's output what the decoder reads; every buffer + holds the map it gets (allocation sizes from the recorder).""" + for rw, rh in ((64, 64), (80, 48)): + t = Trace(run_trace(rw=rw, rh=rh, ow=96, oh=96, frames=2)) + fw, fh = ceil32(rw), ceil32(rh) + tokens = (fw // 2) * (fh // 2) + for f in t.frames: + ls = f["launches"] + enc = next(i for i, ln in enumerate(ls) if ln.kernel == "input_encoder") + dec = next(i for i, ln in enumerate(ls) if ln.kernel == "coef_decoder") + feat = ls[enc].args[6] + self.assertEqual(ls[enc + 1].kernel.startswith("swin_block_c64"), True, ls[enc + 1].kernel) + self.assertEqual(ls[enc + 1].args[0], feat) # enc1 reads enc0's features + self.assertGreaterEqual(t.extent(feat), tokens * 64) + dec1 = [ln for ln in ls[:dec] if ln.kernel.startswith("swin_block_c64")][-1] + self.assertEqual(ls[dec].args[0], dec1.args[2]) # the decoder reads dec1's output + self.assertGreaterEqual(t.extent(dec1.args[2]), tokens * 64) + self.assertEqual(ls[enc].params(12)[:4], [rw, rh, fw, fh]) + self.assertEqual(ls[dec].params(8)[:4], [rw, rh, fw, fh]) + self.assertEqual(dec1.args[4:6], [str(fh // 2), str(fw // 2)]) # H, W of dec1: the F/2 grid + # the history between frames: the latent the decoder writes (its argument 6) and the near motion the + # encoder writes (its argument 7) are what the next frame's encoder reads (its arguments 4 and 5) + for a, b in zip(t.frames, t.frames[1:]): + prev = {ln.kernel: ln for ln in a["launches"]} + cur = {ln.kernel: ln for ln in b["launches"]} + self.assertEqual(cur["input_encoder"].args[4], prev["coef_decoder"].args[6]) + self.assertEqual(cur["input_encoder"].args[5], prev["input_encoder"].args[7]) + self.assertNotEqual(cur["input_encoder"].args[4], prev["input_encoder"].args[4]) + + def test_reset_parity_and_sizes(self): + """Reset (first frame, the game's reset, a size change) and parity reach the encoder and decoder; the render + size can change from frame to frame (non-aligned sizes included).""" + sizes = "--sizes=96x96,96x96,96x96,80x48,80x48,64x64" + t = Trace(run_trace(rw=96, rh=96, ow=144, oh=144, frames=6, flags=(sizes, "--reset=2"))) + resets = [f["info"]["reset"] for f in t.frames] + self.assertEqual(resets, [1, 0, 1, 1, 0, 1]) # first frame, the game's reset, two size changes + parities = [f["info"]["parity"] for f in t.frames] + self.assertTrue(all(p in (0, 1) for p in parities) and parities[0] != parities[1]) + for f, (rw, rh) in zip(t.frames, [(96, 96)] * 3 + [(80, 48)] * 2 + [(64, 64)]): + self.assertEqual((f["info"]["rw"], f["info"]["rh"]), (rw, rh)) + ls = {ln.kernel: ln for ln in f["launches"]} + e, d = ls["input_encoder"].params(12), ls["coef_decoder"].params(8) + self.assertEqual(e[:4], [rw, rh, ceil32(rw), ceil32(rh)]) + self.assertEqual(d[:4], [rw, rh, ceil32(rw), ceil32(rh)]) + self.assertEqual(e[5], f["info"]["reset"]) + self.assertEqual(d[4], f["info"]["reset"]) + + def test_failed_launch_stops_the_frame(self): + t = Trace(run_trace(frames=3, flags=("--fail=coef_decoder@1",))) + ok0, bad, ok2 = t.frames + self.assertIsNone(ok0["error"]) + self.assertEqual(bad["failed"], "coef_decoder") + self.assertIn("injected launch failure: coef_decoder", bad["error"]) + names = [ln.kernel for ln in bad["launches"]] + self.assertNotIn("coef_decoder", names) + self.assertEqual(names, [ln.kernel for ln in ok0["launches"]][:len(names)]) # nothing after the failure + self.assertTrue(names and names[-1].startswith("swin_block_c64")) # it stopped right after dec1 + self.assertIsNone(ok2["error"]) + self.assertIn("coef_decoder", [ln.kernel for ln in ok2["launches"]]) # the next frame runs whole + def test_model_l_refused(self): lines = run_trace(options="model=L") self.assertEqual(len(lines), 1) From 61a9e4944e50e9e0bde1d1c43d5b2c1c42e85c53 Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:15:15 -0500 Subject: [PATCH 2/3] Runtime frame trace: the fused dec1 + decoder block's arguments; no unknown address in a decoded argument swin_block_c64_add_dec0* takes x, skip, w, H, W, ox, oy (not the blocks' common form): the generic entry read an int as an address. The tests now assert that no decoded argument is an unknown address (the shipping build runs the fused block). Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/tests/runtime_frame_trace.cpp | 3 +++ clean/tests/test_runtime_frame_trace.py | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clean/tests/runtime_frame_trace.cpp b/clean/tests/runtime_frame_trace.cpp index 9041e636..1e64b16c 100644 --- a/clean/tests/runtime_frame_trace.cpp +++ b/clean/tests/runtime_frame_trace.cpp @@ -71,6 +71,9 @@ const Signature kSignatures[] = { const char* kinds_of(const std::string& kernel) { const size_t slash = kernel.find('/'); const std::string k = slash == std::string::npos ? kernel : kernel.substr(slash + 1); + // dec1's block fused with the decoder (swin_block_c64_add_dec0*): x, skip, w, H, W, ox, oy, then the decoder's + // arguments: not the blocks' common form + if (k.find("_add_dec0") != std::string::npos) return "pppiiii"; for (const Signature& s : kSignatures) { const size_t n = std::strlen(s.name); if (s.name[n - 1] == '*' ? k.compare(0, n - 1, s.name, n - 1) == 0 : k == s.name) return s.kinds; diff --git a/clean/tests/test_runtime_frame_trace.py b/clean/tests/test_runtime_frame_trace.py index ea2dd5d1..475afcd1 100644 --- a/clean/tests/test_runtime_frame_trace.py +++ b/clean/tests/test_runtime_frame_trace.py @@ -101,6 +101,10 @@ def __init__(self, lines): else: raise AssertionError("unexpected line: " + ln) + def unknown(self): + """Decoded arguments that are no allocation's address (a wrong entry in the recorder's table shows here).""" + return [(ln.kernel, a) for f in self.frames for ln in f["launches"] for a in ln.args if a.startswith("?")] + def extent(self, addr): """Bytes from a decoded address b+ to the end of its allocation.""" k, off = addr[1:].split("+") @@ -156,7 +160,9 @@ def test_frames(self): def test_shipping_build(self): """With the optional code objects of a full build: the pack12 decoder, dec1 fused with dec0, wave64 post.""" - create, loads, frames, kernels = parse(run_trace(frames=2, build_files=SHIPPING)) + t = Trace(run_trace(frames=2, build_files=SHIPPING)) + self.assertEqual(t.unknown(), []) + create, loads, frames, kernels = t.create, t.loads, [[ln.kgb() for ln in f["launches"]] for f in t.frames], t.kernels self.assertEqual(create, "create ok model M") for want in ("decoder__pack12.co as d0p12", "dec1_dec0__pack12.co as d1p12", "post_w64.co as w64"): self.assertIn(want, loads) @@ -174,6 +180,7 @@ def test_dataflow_and_extents(self): holds the map it gets (allocation sizes from the recorder).""" for rw, rh in ((64, 64), (80, 48)): t = Trace(run_trace(rw=rw, rh=rh, ow=96, oh=96, frames=2)) + self.assertEqual(t.unknown(), []) fw, fh = ceil32(rw), ceil32(rh) tokens = (fw // 2) * (fh // 2) for f in t.frames: From 35e86544b7fb4396b73d0ad641d205003d7ea57e Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 20:17:34 -0500 Subject: [PATCH 3/3] Runtime frame trace test: one assignment per line Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/tests/test_runtime_frame_trace.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clean/tests/test_runtime_frame_trace.py b/clean/tests/test_runtime_frame_trace.py index 475afcd1..f275e51a 100644 --- a/clean/tests/test_runtime_frame_trace.py +++ b/clean/tests/test_runtime_frame_trace.py @@ -162,7 +162,8 @@ def test_shipping_build(self): """With the optional code objects of a full build: the pack12 decoder, dec1 fused with dec0, wave64 post.""" t = Trace(run_trace(frames=2, build_files=SHIPPING)) self.assertEqual(t.unknown(), []) - create, loads, frames, kernels = t.create, t.loads, [[ln.kgb() for ln in f["launches"]] for f in t.frames], t.kernels + create, loads, kernels = t.create, t.loads, t.kernels + frames = [[ln.kgb() for ln in f["launches"]] for f in t.frames] self.assertEqual(create, "create ok model M") for want in ("decoder__pack12.co as d0p12", "dec1_dec0__pack12.co as d1p12", "post_w64.co as w64"): self.assertIn(want, loads)