This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpenMP] Added assemblyFormat for atomic and critical operations
ClosedPublic

Authored by shraiysh on Feb 21 2022, 5:43 AM.

Details

Summary

This patch adds assemblyFormat for omp.critical.declare, omp.atomic.read,
omp.atomic.write, omp.atomic.update and omp.atomic.capture.

Also removing those clauses from parseClauses that aren't needed
anymore, thanks to the new assemblyFormats.

Diff Detail

Event Timeline

shraiysh created this revision.Feb 21 2022, 5:43 AM
shraiysh requested review of this revision.Feb 21 2022, 5:43 AM

Thanks @shraiysh for the patch. I have a few questions. Please find them below.

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

I think you have introduced the operations for atomic in an earlier patch. It was merged below I realised this problem. Probably we can fix this here.

According to OpenMP 5.0 specification, (section 2,17.7) atomic read can't have acq_rel or release memory-order clause.

610

Same thing here.

According to OpenMP 5.0 specification, (section 2,17.7) atomic write can't have acq_rel or acquire memory-order clause.

616–624

I do not understand the attribute name change. It doesn't look like $hint and $memory_order are colliding with other names in the critical operation (or other operations in atomic construct which you have updated). Is there a special need for this change?

620

It looks like this updates assembly format for critical construct too. Does it make sense to add it to the patch description? Also is there any need of adding a test case for the same?

643

Same thing here.

According to OpenMP 5.0 specification, (section 2,17.7) atomic update can't have acq_rel or acquire memory-order clause.

mlir/test/Dialect/OpenMP/ops.mlir
571

Just confirming once whether this whitespace is intentional.

614

The general format of these tests looks like the //CHECKs are closer to the statement that generates the IR. Does it make sense to format the atomic tests in the same vein for consistency?

NimishMishra requested changes to this revision.Feb 22 2022, 8:28 PM
This revision now requires changes to proceed.Feb 22 2022, 8:28 PM
shraiysh updated this revision to Diff 410709.Feb 22 2022, 10:05 PM
shraiysh marked 7 inline comments as done.

Addressed comments. Rebase with main.

shraiysh added inline comments.Feb 22 2022, 10:07 PM
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
616–624

Yes, oilist adds a unit attribute with the name of the literal associated with a clause. So, hint and memory_order are added by default and will cause collision with same name attributes.

620

Updated the patch description. Tests for this are already in ops.mlir so we don't have to add anything.

mlir/test/Dialect/OpenMP/ops.mlir
571

Yes, the generated printer emits a whitespace here - so to match that, this was updated.

614

I have tried to keep the CHECK for one atomic capture operation right above it so as to have one-one correspondence between atomic.capture ops.

Anyways, I was trying to keep minimal changes to testcases for this patch, because we want same behavior with new format. Best case scenario would be no changes to the tests at all! (We can do it in a separate patch later if you'd like)

shraiysh retitled this revision from [mlir][OpenMP] Added assemblyFormat for atomic operations to [mlir][OpenMP] Added assemblyFormat for atomic and critical operations.Feb 22 2022, 10:08 PM
shraiysh edited the summary of this revision. (Show Details)
NimishMishra accepted this revision.Feb 24 2022, 9:22 PM

Thanks @shraiysh. LGTM.

This revision is now accepted and ready to land.Feb 24 2022, 9:22 PM
shraiysh updated this revision to Diff 411747.Feb 28 2022, 12:36 AM

Ping for another approval from someone outside AMD.

Rebase with main.

shraiysh requested review of this revision.Mar 1 2022, 9:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 9:16 PM
rriddle accepted this revision.Mar 1 2022, 9:19 PM
This revision is now accepted and ready to land.Mar 1 2022, 9:19 PM
shraiysh updated this revision to Diff 412318.Mar 1 2022, 9:33 PM

Thanks for the review @rriddle. Rebase with main.