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
50 changes: 29 additions & 21 deletions api/steps/bebop/p2e/03_runworkload_event.step.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import re
import sys
from datetime import datetime
from pathlib import Path

from motia import FlowContext, queue

Expand All @@ -19,7 +20,7 @@
sys.path.insert(0, utils_path)

from utils.event_common import require_chip
from utils.path import bebop_cargo_env, chip_output_root, get_buckyball_path, log_dir, rtl_dir
from utils.path import bebop_cargo_env, get_buckyball_path, log_dir, rtl_dir
from utils.stream_run import stream_run_logger_async
from utils.event_common import check_result, get_origin_trace_id

Expand All @@ -33,16 +34,11 @@


def resolve_image(bbdir: str, image_name: str, chip: str) -> str:
"""Search chip workload build output recursively for <image_name>.hex."""
workload_root = os.path.join(chip_output_root(bbdir, chip), "workloads")
matches = glob.glob(f"{workload_root}/**/{image_name}.hex", recursive=True)
if not matches:
return ""
if len(matches) > 1:
raise ValueError(
f"multiple .hex files for {image_name!r} under {workload_root}: {matches}"
)
return matches[0]
"""Resolve a kernel image name to its deterministic output path."""
image_name = image_name.replace(r"\_", "_")
filename = image_name if image_name.endswith(".hex") else f"{image_name}.hex"
path = Path(bbdir) / "bb-tests" / "output" / "kernel" / chip / filename
return str(path) if path.is_file() else ""


def resolve_runtime_config(bitstream: str, requested_config: object) -> str:
Expand Down Expand Up @@ -114,7 +110,7 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
if not image_path:
ctx.logger.error(
f"image .hex not found for name: {image_name} "
f"(searched bb-tests/output/{chip}/workloads/)"
f"(expected bb-tests/output/kernel/{chip}/)"
)
await check_result(
ctx, 1, continue_run=False,
Expand Down Expand Up @@ -169,10 +165,14 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
stderr_prefix="bebop p2e runtime",
env={**os.environ.copy(), **bebop_cargo_env(bbdir, chip)},
)
runtime_lib_dir = os.path.join(build_dir, "vvacDir", "runtimeDir", "lib", "lib_arm")
rtcfg_path = os.path.join(build_dir, "vvacDir", "runtimeDir", "rtcfg")
libvctb_path = os.path.join(build_dir, "vvacDir", "runtimeDir", "lib", "lib_arm", "libvCtb.so")
if runtime_result.returncode != 0 or not all(os.path.isfile(path) for path in (rtcfg_path, libvctb_path)):
missing = [path for path in (rtcfg_path, libvctb_path) if not os.path.isfile(path)]
libvctb_path = os.path.join(runtime_lib_dir, "libvCtb.so")
libstdcxx_path = os.path.join(runtime_lib_dir, "libstdc++.so.6")
bebop_p2e_path = os.path.join(build_dir, "bebop-p2e")
runtime_artifacts = (rtcfg_path, libvctb_path, libstdcxx_path, bebop_p2e_path)
if runtime_result.returncode != 0 or not all(os.path.isfile(path) for path in runtime_artifacts):
missing = [path for path in runtime_artifacts if not os.path.isfile(path)]
if missing:
ctx.logger.error(f"P2E runtime artifacts missing: {missing}")
await check_result(
Expand All @@ -189,14 +189,15 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
)
return

# ── Run bebop run p2e ─────────────────────────────────────────────────
# Run the case-local executable produced above. It must load the VVAC
# runtime's libstdc++ (6.0.25), not Cargo/Nix's newer libstdc++; mixing the
# two ABIs crashes inside ICtbMgr::init(). Apply LD_LIBRARY_PATH only to
# the runtime process so Cargo itself keeps its normal library environment.
run_cmd = (
f"cargo run --release --features p2e "
f"--config=\"env.OUT_PATH='{build_dir}'\" "
f"-- run p2e "
f"\"{bebop_p2e_path}\" run p2e "
f"--image=\"{image_path}\" "
f"--bitstream=\"{bitstream}\" "
f"--log-dir=\"{log_dir}\""
f"--log-dir=\"{run_log}\""
)
if multi_fpga:
run_cmd += " --multi-fpga"
Expand All @@ -208,13 +209,20 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
if input_data.get(trace_name, False):
run_cmd += f" --{trace_name}"
ctx.logger.info(f"Running bebop p2e runworkload: {run_cmd}")
run_env = {**os.environ.copy(), **bebop_cargo_env(bbdir, chip)}
inherited_library_path = run_env.get("LD_LIBRARY_PATH")
run_env["LD_LIBRARY_PATH"] = (
f"{runtime_lib_dir}:{inherited_library_path}"
if inherited_library_path
else runtime_lib_dir
)
run_result = await stream_run_logger_async(
cmd=run_cmd,
logger=ctx.logger,
cwd=bebop_dir,
stdout_prefix="bebop p2e runworkload",
stderr_prefix="bebop p2e runworkload",
env={**os.environ.copy(), **bebop_cargo_env(bbdir, chip)},
env=run_env,
)

await check_result(
Expand Down
3 changes: 2 additions & 1 deletion api/steps/compiler/scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def build_compiler(
"buddy-opt",
"buddy-translate",
"buddy-llc",
"rax-pack",
"python-package-buddy",
"BuddyMLIRPythonModules",
],
Expand All @@ -180,7 +181,7 @@ def build_compiler(
task_scope=task_scope,
output_prefix="compiler build",
)
for tool in ("buddy-opt", "buddy-translate", "buddy-llc"):
for tool in ("buddy-opt", "buddy-translate", "buddy-llc", "rax-pack"):
if not (build / "bin" / tool).is_file():
raise RuntimeError(f"compiler build failed: missing {build / 'bin' / tool}")
return build
8 changes: 4 additions & 4 deletions api/steps/kernel/01_build_event.step.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,6 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
bbdir = get_buckyball_path()

kernel_src = os.path.join(bbdir, "bb-tests", "workloads", "lib", "kernel")
output_dir = os.path.join(bbdir, "bb-tests", "output", "kernel")

os.makedirs(output_dir, exist_ok=True)

try:
hart_params = hart_count_params(input_data)
model = kernel_model(input_data)
Expand All @@ -173,6 +169,10 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
ctx.logger.error(str(e))
await check_result(ctx, 1, continue_run=False, trace_id=origin_tid)
return
output_dir = os.path.join(bbdir, "bb-tests", "output", "kernel")
if chip:
output_dir = os.path.join(output_dir, chip)
os.makedirs(output_dir, exist_ok=True)
kernel_build = kernel_build_dir(
bbdir, hart_params, model, chip, interactive=interactive
)
Expand Down
19 changes: 12 additions & 7 deletions api/steps/regression/02_eval_performance_event.step.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,12 @@ def _workload_build(bbdir, chip, model, logger, task_scope):
)


def _kernel_build_cmds(bbdir, model, dataset=""):
def _kernel_build_cmds(bbdir, chip, model, dataset=""):
kernel_src = os.path.join(bbdir, "bb-tests", "workloads", "lib", "kernel")
hart_params = {"visible": 64, "total": 64, "hidden_base": 64}
kernel_build = _kernel.kernel_build_dir(bbdir, hart_params, model=model)
kernel_build = _kernel.kernel_build_dir(
bbdir, hart_params, model=model, chip=chip
)
ds_arg = ""
if dataset:
ds_arg = f" -DBUCKYBALL_MODEL_DATASET={shlex.quote(dataset)}"
Expand All @@ -102,14 +104,17 @@ def _kernel_build_cmds(bbdir, model, dataset=""):
f"-DBUCKYBALL_TOTAL_HART_COUNT=64 "
f"-DBUCKYBALL_HIDDEN_HART_BASE=64 "
f"-DBUCKYBALL_KERNEL_MODEL={model} "
f"-DBUCKYBALL_KERNEL_CHIP= "
f"-DBUCKYBALL_KERNEL_CHIP={chip} "
f"-DBUCKYBALL_KERNEL_INTERACTIVE=OFF"
f"{ds_arg}"
)
build = f"cmake --build {kernel_build} --target kernel-build"
payload = _kernel.fw_payload_name(hart_params, model=model)
fw_bin = os.path.join(bbdir, "bb-tests", "output", "kernel", f"{payload}.bin")
fw_hex = os.path.join(bbdir, "bb-tests", "output", "kernel", f"{payload}.hex")
kernel_output = os.path.join(
bbdir, "bb-tests", "output", "kernel", chip
)
fw_bin = os.path.join(kernel_output, f"{payload}.bin")
fw_hex = os.path.join(kernel_output, f"{payload}.hex")
return configure, build, fw_bin, fw_hex


Expand All @@ -118,7 +123,7 @@ def _p2e_run_cmds(bbdir, bitstream, image_name, chip, input_data):
if not image_path:
raise FileNotFoundError(
f"image .hex not found for name: {image_name} "
f"(searched bb-tests/output/{chip}/workloads/)"
f"(expected bb-tests/output/kernel/{chip}/)"
)
bitstream = os.path.abspath(bitstream)
build_dir = os.path.dirname(os.path.dirname(bitstream))
Expand Down Expand Up @@ -226,7 +231,7 @@ async def handler(input_data: dict, ctx: FlowContext) -> None:
spec = acc_specs[model]
try:
k_cfg, k_build, fw_bin, fw_hex = _kernel_build_cmds(
bbdir, model, dataset=spec["dataset"],
bbdir, chip, model, dataset=spec["dataset"],
)
except ValueError as e:
ctx.logger.error(str(e))
Expand Down
Loading