Skip to content

compilation: run a rule's independent commands concurrently - #186

Open
atassis wants to merge 1 commit into
amd:develfrom
atassis:pr/parallel-rule-commands
Open

compilation: run a rule's independent commands concurrently#186
atassis wants to merge 1 commit into
amd:develfrom
atassis:pr/parallel-rule-commands

Conversation

@atassis

@atassis atassis commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Problem

execute() runs every command of every rule one after another:

for rule, commands in plan_steps:
    for command in commands:
        command.run()

A rule that emits one command per worklist artifact — KernelCompilationRule is the one that matters
— therefore costs the SUM of its compiles rather than the max, even though the commands write
separate outputs and never read each other's.

Fix

A rule declares whether its commands are independent (commands_are_independent, default off) and
execute runs those concurrently. The default is off deliberately: a rule that batches dependent
steps into one application must keep its order, and only the rule knows which kind it is.
KernelCompilationRule sets it, since it emits one command per KernelObjectArtifact, each reading
its own source and writing its own object.

The first failure is raised only after every sibling has finished, so a failing command cannot leave
half-written outputs behind a raised error.

Bounded by cores — each kernel compile is a single-threaded clang peaking near 205 MB of RSS.
IRON_COMPILE_JOBS overrides.

Test

On a two-kernel design the kernel-compile step goes 7.9 s -> 2.6 s of a 17.1 s build, with the
artifacts unchanged. The gain is max instead of sum, so it scales with a design's kernel count and
is nothing for a single-kernel design.

execute() ran every command of every rule one after another, so a design's
kernel objects cost the SUM of their compiles: 7.9 s of a 17.1 s encoder-MHA
build for two kernels, 2.6 s once parallel. Only the rule knows whether its
commands are independent, so it declares it; KernelCompilationRule does.
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.

1 participant