This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][Flang][MLIR] Add MLIR support for OpenMP requires directive
ClosedPublic

Authored by skatrak on Mar 30 2023, 3:58 AM.

Details

Summary

This patch introduces an MLIR attribute to the OpenMP dialect
representing the clauses that a 'requires' directive can define, with
the exception of the parameterized atomic_default_mem_order
clause. In that case, the existing omp.memory_order enumeration
can be used for representing its information instead.

The OffloadModuleInterface is also updated to provide methods to get
and set two new dialect attributes (omp.requires,
omp.atomic_default_mem_order) to store and use this information during
the lowering stages to LLVM IR.

Diff Detail

Event Timeline

skatrak created this revision.Mar 30 2023, 3:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 30 2023, 3:58 AM
skatrak requested review of this revision.Mar 30 2023, 3:58 AM
skatrak updated this revision to Diff 515704.Apr 21 2023, 5:51 AM

Rebase and update.

skatrak updated this revision to Diff 520318.May 8 2023, 3:24 AM

Remove omp.atomic_default_mem_order. This clause is now handled in semantics.

Please add tests to mlir/test/Dialect/OpenMP/ops.mlir

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
1696

Add a TODO for unsupported clause

skatrak updated this revision to Diff 527098.May 31 2023, 9:50 AM

Add unit test and comment.

skatrak marked an inline comment as done.May 31 2023, 9:58 AM

Thank you @TIFitis for the comments. Let me know if these changes address your concerns.

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
1696

I added a comment explaining that there's no need to add flags for the atomic_default_mem_order clause here, since the OMPC_MemoryOrder enum in OMP.td already defines the values it can have.

The currently proposed implementation in Flang, which can be seen in dependent patches to this one, doesn't even store the atomic default memory order clause in MLIR because it's handled early in a semantics pass. Even if later some other frontend needed this information in MLIR, an attribute with an OMPC_MemoryOrder field could be used to represent it.

TIFitis accepted this revision.Jun 2 2023, 12:08 PM

LGTM

This revision is now accepted and ready to land.Jun 2 2023, 12:08 PM
skatrak marked an inline comment as done.Jun 5 2023, 7:28 AM

Thank you, Akash. I'll wait for one more day before landing this patch in case somebody else has any further comments.