better throughput scheduling with steady state cost model (WIP)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import argparse
|
||||
from collections import defaultdict, deque
|
||||
from collections import Counter, defaultdict, deque
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -13,6 +13,7 @@ from types import SimpleNamespace
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
sys.path.insert(0, str(REPO / "validation/tools/pim/pimcomp/correctness/synchronization"))
|
||||
import global_memory as sync
|
||||
from raptor_validation.pimsim_nn import export_raptor_pimsim_artifact
|
||||
|
||||
|
||||
def read_events(artifact):
|
||||
@@ -121,6 +122,40 @@ def check_lifetimes(streams):
|
||||
return shared, stalled_reader
|
||||
|
||||
|
||||
def check_periodic_estimate(report, streams):
|
||||
assert report["diagnostic_only"] and report["status"] == "estimated", report
|
||||
assert 0 <= report["recurrence_upper_ns"] - report["recurrence_lower_ns"] <= 1
|
||||
assert report["critical_cycle_distance"] > 0
|
||||
ratio = report["critical_cycle_delay_ns"] / report["critical_cycle_distance"]
|
||||
assert report["recurrence_lower_ns"] <= ratio <= report["recurrence_upper_ns"]
|
||||
signals, waits, memory = Counter(), {}, Counter()
|
||||
# The oracle exporter converts this fp32 fixture's addresses to int8 bytes.
|
||||
host_bytes = report["native_host_buffer_bytes"] // 4
|
||||
for core, events in streams.items():
|
||||
for _, op, *args in events:
|
||||
if op == 32:
|
||||
target, register, _ = args
|
||||
signals[core, target, register] += 1
|
||||
elif op == 31:
|
||||
_, register, count = args
|
||||
assert (core, register) not in waits
|
||||
waits[core, register] = count
|
||||
elif op in (25, 26) and args[0] < host_bytes:
|
||||
memory[op, "requests"] += 1
|
||||
memory[op, "bytes"] += args[1]
|
||||
planned = Counter()
|
||||
for event in report["event_registers"]:
|
||||
key = event["core"], event["register"]
|
||||
assert waits.pop(key) == event["expected"]
|
||||
for source in event["sources"]:
|
||||
planned[source["core"], *key] += source["count"]
|
||||
assert not waits and planned == signals
|
||||
for op, direction in ((25, "read"), (26, "write")):
|
||||
for quantity in ("bytes", "requests"):
|
||||
assert report[f"boundary_{direction}_{quantity}"] == memory[op, quantity], (
|
||||
direction, quantity, report[f"boundary_{direction}_{quantity}"], memory[op, quantity])
|
||||
|
||||
|
||||
def run_functional(artifact, inputs, references, outputs, out, policy, seed, reader=None):
|
||||
out.mkdir()
|
||||
command = [str(sync.RUST_BINARY), "--folder", str(artifact),
|
||||
@@ -158,13 +193,17 @@ def main():
|
||||
"--maccel=PIM", "--EmitPimCodegen", "--crossbar-size=128",
|
||||
f"--crossbar-count={weights}", f"--core-count={cores}", "--pipeline=4",
|
||||
f"--pim-target-config={sync.CONFIG_ROOT / arch / 'throughput_config_1000ms.json'}",
|
||||
"--mlir-disable-threading", "--pim-emit-json", "--pim-detect-communication-deadlock"]
|
||||
"--mlir-disable-threading", "--pim-periodic-diagnostics", "--pim-emit-json", "--pim-detect-communication-deadlock"]
|
||||
compiled = subprocess.run(command, capture_output=True, text=True,
|
||||
timeout=120, env=dict(os.environ, OMP_NUM_THREADS="1"))
|
||||
assert compiled.returncode == 0, compiled.stdout + compiled.stderr
|
||||
artifact = out / "pim"
|
||||
streams = read_events(artifact)
|
||||
shared, reader = check_lifetimes(streams)
|
||||
report = json.loads((out / "reports/pipeline_periodic.json").read_text())
|
||||
oracle = out / "pimsim_nn"
|
||||
export_raptor_pimsim_artifact(artifact, oracle)
|
||||
check_periodic_estimate(report, read_events(oracle))
|
||||
for policy, seed in (("greedy", 0), ("randomized", 1), ("randomized", 7)):
|
||||
run_functional(artifact, inputs, references, outputs,
|
||||
out / f"{policy}-{seed}", policy, seed)
|
||||
|
||||
Reference in New Issue
Block a user