Skip to content

Fix crash in ConvertParallelToGPU1 pass on grid×block loops with multiple inner parallels#2564

Open
xys-syx wants to merge 1 commit into
recreateexprfrom
fused-siblings
Open

Fix crash in ConvertParallelToGPU1 pass on grid×block loops with multiple inner parallels#2564
xys-syx wants to merge 1 commit into
recreateexprfrom
fused-siblings

Conversation

@xys-syx

@xys-syx xys-syx commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

The input IRs:

scf.parallel (%bx,%by,%bz, %tx,%ty,%tz) {
    scf.parallel (%i) = 0 to 8 { ... }
    scf.parallel (%j) = 0 to 8 { ... }
    scf.parallel (%k) = 0 to 8 { ... }
}

ConvertParallelToGPU1 pass crashed with llvm_unreachable("Unhandled case") (in ParallelizeBlockOps)

Fix with if the GPUDIMs equals 6 (grid -> [0, 3), block -> [3,6)), InnerParallelSerialization will serialize a parallel loop into scf.for.

@xys-syx xys-syx requested review from vimarsh6739 and wsmoses June 18, 2026 07:16
@vimarsh6739

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b62ef6353f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1894 to 1895
if (enclosingGpuDims < 6)
return failure();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve serialization for lower-dimensional launches

This guard only serializes inner sibling scf.parallel loops when the enclosing loops have six IVs total, so a valid lower-dimensional grid/block nest such as a 1D grid loop containing a 1D block loop is no longer handled. ParallelToGPULaunch pads missing dimensions to 1, and the previous depth-based check serialized these cases; with this change, multiple sibling inner parallels remain in the block body and ParallelizeBlockOps can still hit its llvm_unreachable("Unhandled case") on the second sibling.

Useful? React with 👍 / 👎.

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