"""Re-emit sip_view.svg in an academic palette (white background, black
strokes) and convert it to PDF for the 1H-codesign-paper Figure 1.
Source of truth: docs/diagrams/sip_view.svg (generated by
src/kernbench/topology/visualizer.py, dark-ish theme).
Treatment per user request: keep the layout intact, just force a white
canvas and turn every stroke black; promote faint label text to black so
all annotations stay legible on white.
"""
from __future__ import annotations
import re
import shutil
import subprocess
from pathlib import Path
REPO = Path(__file__).resolve().parents[2]
SRC_SVG = REPO / "docs" / "diagrams" / "sip_view.svg"
OUT_DIR = REPO / "docs" / "report" / "1H-codesign-paper" / "figures"
OUT_SVG = OUT_DIR / "sip_architecture.svg"
OUT_PDF = OUT_DIR / "sip_architecture.pdf"
# Drop the "SIP VIEW" title; the figure caption already names the level.
TITLE_REMOVE: list[tuple[str, str]] = [
(' SIP VIEW\n',
''),
]
COLOR_MAP: list[tuple[str, str]] = [
# canvas background slate-50 -> pure white
('fill="#f8fafc"', 'fill="#ffffff"'),
# all strokes -> black
('stroke="#3b82f6"', 'stroke="#000000"'), # UCIe mesh blue lines
('stroke="#475569"', 'stroke="#000000"'), # cube block borders
('stroke="#0ea5e9"', 'stroke="#000000"'), # I/O sky-blue lines
# link annotation text slate-500 -> black for readability
('fill="#64748b"', 'fill="#000000"'),
]
# Font-size bumps so labels survive LaTeX \linewidth scaling at the
# half-text-width subfigure. CUBE block labels overflow the 48px block
# rects, which is acceptable here.
FONT_MAP: dict[str, str] = {
"7": "10",
"14": "17",
}
# Tighten whitespace: cube grid occupies x=[84,564], y=[128,520]; IO
# chiplet sits around y~50. With the title removed, crop top to y=40 so
# the IO chiplet keeps a small headroom. Crop 70px on each side and 113
# px from bottom.
LAYOUT_FIXUP: list[tuple[str, str]] = [
('