CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
88 lines
2.6 KiB
Python
Executable File
88 lines
2.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
# Copyright Advanced Micro Devices, Inc., or its affiliates.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import argparse
|
|
import difflib
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
|
|
def color_node(line: str, is_addition: bool):
|
|
if is_addition:
|
|
color = "blue"
|
|
else:
|
|
color = "red"
|
|
if "blue" in line:
|
|
color = "yellow"
|
|
if "]" in line and "invis" not in line:
|
|
idx = line.index("]")
|
|
return line[:idx] + f",color={color}" + line[idx:]
|
|
return line
|
|
|
|
|
|
def diff_dots(dots: list[str]) -> list[str]:
|
|
dots_diff = []
|
|
for i, dot in enumerate(dots):
|
|
if i + 1 == len(dots):
|
|
continue
|
|
dot_next = dots[i + 1]
|
|
if i == 0:
|
|
dots_diff.append(dot.split("\n"))
|
|
dots_diff.append(dot_next.split("\n"))
|
|
|
|
index = 0
|
|
index_next = 0
|
|
for diff in difflib.unified_diff(
|
|
dot.split("\n"),
|
|
dot_next.split("\n"),
|
|
n=0,
|
|
lineterm="",
|
|
):
|
|
if "@@" in diff:
|
|
index = int(diff.split(" ")[1].split(",")[0].strip("-")) - 1
|
|
index_next = int(diff.split(" ")[2].split(",")[0]) - 1
|
|
else:
|
|
if diff[0] == "+":
|
|
dots_diff[i + 1][index_next] = color_node(
|
|
dots_diff[i + 1][index_next],
|
|
True,
|
|
)
|
|
index_next += 1
|
|
elif diff[0] == "-":
|
|
dots_diff[i][index] = color_node(
|
|
dots_diff[i][index],
|
|
False,
|
|
)
|
|
index += 1
|
|
|
|
return ["\n".join(d) for d in dots_diff]
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Extract and render kernel graph.")
|
|
parser.add_argument(
|
|
"fnames",
|
|
type=str,
|
|
help="Dot files to compare",
|
|
nargs="+",
|
|
)
|
|
parser.add_argument(
|
|
"-o", "--output", type=str, help="Output file base name", default="dot_output"
|
|
)
|
|
parser.add_argument("-d", "--dot-only", default=False, action="store_true")
|
|
|
|
args = parser.parse_args()
|
|
dots_in = []
|
|
for fname in args.fnames:
|
|
dots_in.append(Path(fname).read_text())
|
|
|
|
dots = diff_dots(dots_in)
|
|
for i, dot in enumerate(dots):
|
|
out_fname = Path(args.output + f"_{i:04d}")
|
|
out_fname.with_suffix(".dot").write_text(dot)
|
|
if not args.dot_only:
|
|
with out_fname.with_suffix(".pdf").open("w") as out:
|
|
subprocess.run(["dot", "-Tpdf"], input=dot.encode(), stdout=out)
|