Skip to content

[Flang][MLIR][OpenMP] Explicitly represent omp.target kernel types#1767

Draft
skatrak wants to merge 1 commit intoamd-stagingfrom
amd/dev/safonsof/explicit-kernel-type
Draft

[Flang][MLIR][OpenMP] Explicitly represent omp.target kernel types#1767
skatrak wants to merge 1 commit intoamd-stagingfrom
amd/dev/safonsof/explicit-kernel-type

Conversation

@skatrak
Copy link
Member

@skatrak skatrak commented Mar 16, 2026

Downstream cherry-pick of llvm#186166 to test and address merge conflicts in advance, only to be merged after it has been approved upstream.

Currently, the kernel type (i.e. `generic`, `spmd`, `spmd-no-loop` and
`bare`) of an `omp.target` operation is not an explicit attribute of the
operation. Rather, this is inferred based on the contents of its region
and clauses.

The problems with this approach are that it can be a potentially resource
intensive check for large kernels, and misidentifications are prone to
happen based on the presence of arbitrary operations from other dialects.

Since the AST already contains the information needed to identify the
kernel type in a more reliable manner, this patch moves that
responsiblity to the Flang frontend. Other MLIR passes that create
`omp.target` operations are updated as well.

One known limitation of this approach is that the MLIR op verifier for
`omp.target` can't completely check that the contents of its region are
compatible with the declared kernel type without being exposed to the
same pattern-matching limitations that this patch is removing. Also, the
`TargetOp::getInnermostCapturedOmpOp()` function is maintained but,
ideally, a better solution should be implemented to remove its expensive
and potentially flaky checks from MLIR.
@z1-cciauto
Copy link
Collaborator

@ronlieb ronlieb self-requested a review March 16, 2026 17:49
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