This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpenMP] Add omp.single
ClosedPublic

Authored by shraiysh on Mar 22 2022, 10:17 PM.

Details

Summary

This patch adds omp.single according to Section 2.8.2 of OpenMP 5.0.

Also added tests for the same.

Co-authored-by: Kiran Kumar T P <kirankumar.tp@amd.com>

Diff Detail

Event Timeline

shraiysh created this revision.Mar 22 2022, 10:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 22 2022, 10:17 PM
shraiysh requested review of this revision.Mar 22 2022, 10:17 PM
peixin requested changes to this revision.Mar 23 2022, 1:38 AM
peixin added inline comments.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
228

I think copyprivate is missed. __kmpc_copyprivate is needed when lowering from MLIR to LLVMIR. I guess all the directives and clauses related to global thread variables need to be specified in OpenMP dialect.

mlir/test/Dialect/OpenMP/invalid.mlir
974

Remove this line.

This revision now requires changes to proceed.Mar 23 2022, 1:38 AM
shraiysh updated this revision to Diff 417529.Mar 23 2022, 1:52 AM

Addressed comments.

shraiysh marked an inline comment as done.Mar 23 2022, 1:53 AM
shraiysh added inline comments.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
228

Isn't privatization being handled during translation from PFT to MLIR at the moment? I did not put it in the operation because of that.

shraiysh added inline comments.Mar 23 2022, 1:59 AM
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
228

Data sharing and data copying - both have not been handled in MLIR so far. While data sharing (privatization) has been handled during translation from PFT to MLIR, data copying (copyin and copyprivate) have not been handled anywhere. We need to have a discussion where these should go. (I think their handling is going to be very similar to data sharing clauses and hence should go into translation from PFT to MLIR but I am not sure about this). @kiranchandramohan can you please advise on where these should be handled?

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

Yes, as @shraiysh says, at the moment we do not have handling for data-sharing or data-copying clauses in the OpenMP dialect. @peixin is it OK for you to add them (if necessary) when we start handling those clauses?

peixin accepted this revision.Mar 23 2022, 2:27 AM
peixin added inline comments.
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
228

The data sharing clauses for local data can be handled when lowering to MLIR such as private, shared, firstprivate. For global data, they will be needed when lowering to LLVM IR such as copyin and copyprivate.

Sure. Let's add them when we start working on them.

This revision is now accepted and ready to land.Mar 23 2022, 2:27 AM
This revision was automatically updated to reflect the committed changes.