Skip to content

Additional metadata for kernel args - #159

Merged
mawad-amd merged 2 commits into
mainfrom
colramos/accordo-updates
Nov 24, 2025
Merged

mawad-amd merged 2 commits into
mainfrom
colramos/accordo-updates

Conversation

@coleramos425

Copy link
Copy Markdown
Collaborator

This PR extends Accordo's Snapshot functionality to capture GPU kernel dispatch dimensions (grid size and block/workgroup size) alongside kernel argument data. This enhancement provides additional context about kernel execution configuration, which is valuable for validation and debugging, specifically for kernel extraction tools.

Changes

Python API:

  • Extended Snapshot dataclass with optional grid_size and block_size fields
  • Updated Snapshot.summary() to display grid/block dimensions when available
  • Modified capture_snapshot() to pass metadata file path via environment variable

C++ Runtime Hook:

  • Added dispatch metadata extraction in write_packets() when processing HSA_PACKET_TYPE_KERNEL_DISPATCH packets
  • Metadata written as JSON to a temporary file specified by ACCORDO_METADATA_FILE environment variable
  • Captures grid dimensions (x, y, z) and workgroup dimensions (x, y, z) for the traced kernel

Example Usage

from accordo import Accordo

# Configure validation
config = Accordo.Config(
    kernel_name="matrixTransposeShared_0",
    kernel_args=[
        Accordo.KernelArg(name="out", type="float*"),
        Accordo.KernelArg(name="in", type="const float*"),
        Accordo.KernelArg(name="width", type="int"),
        Accordo.KernelArg(name="height", type="int"),
    ],
    tolerance=1e-6
)

validator = Accordo(config)

# Capture snapshot - grid/block dimensions automatically included
ref_snapshot = validator.capture_snapshot(
    binary=["./b2b_matrix_transpose_ref"],
    working_directory=".",
    timeout_seconds=30
)

print(ref_snapshot.summary())

Output:

Snapshot Summary:
  Binary: ./b2b_matrix_transpose_ref
  Working Directory: /workspace/examples/bank_conflict/b2b_matrix_transpose
  Execution Time: 1353.43ms
  Number of Arrays: 1
  Grid Size: x=1024, y=1024, z=1
  Block Size: x=16, y=16, z=1
  Array 0: shape=(1048576,), dtype=float32

coleramos425 and others added 2 commits November 21, 2025 16:46

@mawad-amd mawad-amd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@mawad-amd
mawad-amd merged commit 7203c08 into main Nov 24, 2025
2 of 3 checks passed
@mawad-amd
mawad-amd deleted the colramos/accordo-updates branch November 24, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants