This is an archive of the discontinued LLVM Phabricator instance.

[mlir][OpenMP] Added omp.task
ClosedPublic

Authored by shraiysh on Apr 12 2022, 1:03 AM.

Details

Summary

This patch adds tasking construct according to Section 2.10.1 of OpenMP 5.0

Diff Detail

Event Timeline

shraiysh created this revision.Apr 12 2022, 1:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 1:03 AM
shraiysh requested review of this revision.Apr 12 2022, 1:03 AM
peixin added inline comments.Apr 12 2022, 2:00 AM
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
63
  1. depend is not one construct. It is one clause.
  1. dependsource and dependsink are only used in ordered construct. The depend clause in task, taskwait, and some other offloading constructs use another format: depend(in | out | ...), which also has modifier and locator-list. Maybe we should split these two formats into two definitions to clearly differentiate their usage. BTW, it seems this depend clause format is not supported in parser currently. If you want to delay the depend clause support, it is also ok, but it's better not move this for now.
539

nit: I32 -> I64

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

It is a boolean value.

534

Same here. Can we define it as a Boolean value? I think we have an option in MLIR.

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

The depend clause for the task construct is going through a revision in the language committee. One should go through the proposed revision before defining it.

shraiysh updated this revision to Diff 422158.Apr 12 2022, 3:03 AM

Addressed comments.

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

Yes, thank you for pointing this out. I was planning to do this later but forgot to undo the move.

533

A boolean value is an I1. Are you referring to UnitAttr? It cannot be used here because the value of UnitAttr is a compile-time constant but here it is a value at runtime.

539

I kept it I32 because the task related runtime functions accept i32 as priority values. Allowing an I64 value as priority here and having a INT64_MAX as priority might lead to unexpected behavior due to data loss during translation.

peixin accepted this revision.Apr 12 2022, 5:04 AM

LGTM. Please wait for at least one more approve befire land.

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

Right. OpenMP 5.2 made great changes to depend clause. But I think we should support OpenMP 5.0/5.1 since there are some old workloads using them. We can delay the support of new features from OpenMP 5.2. Finally, we should support both of new depend clause in OpenMP 5.2 and old depend clause before OpenMP 5.1.

539

OK. I didn't check the runtime argument type. I32 is right.

mlir/test/Dialect/OpenMP/ops.mlir
899

Nit: split the test case with "// -----"

This revision is now accepted and ready to land.Apr 12 2022, 5:04 AM

LGTM

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

thanks. Got it

shraiysh updated this revision to Diff 422235.Apr 12 2022, 7:57 AM

Rebase and added a verifier check. Hence requesting review again.

shraiysh added inline comments.Apr 12 2022, 7:59 AM
mlir/test/Dialect/OpenMP/ops.mlir
899

With the verifier, I needed the symbol @add_f32 in scope. So, I moved the testcase above which gives me access to the symbol.

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

Can you add the OutlineableAopenMPOpInterface and the AutomaticAllocationScope? What about the ReductionClauseInterface?

shraiysh updated this revision to Diff 422280.Apr 12 2022, 10:17 AM

Added interfaces.

shraiysh added inline comments.Apr 12 2022, 10:21 AM
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
488

I do not see anything using the OutlineableOpenMPOpInterface. Plus its description also seems to be incomplete. I understand what kind of operations will have this interface, but is something actually using it?

shraiysh updated this revision to Diff 422284.Apr 12 2022, 10:23 AM

Added OutlineableOpenMPOpInterface. Missed it last time.

LGTM.

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

At the moment, it is used to find a place to insert allocas in flang/lib/Optimizer/Builder/FIRBuilder.cpp and also to check whether allocas should be marked as pinned.
There are potentially other uses as you suspect.

shraiysh added inline comments.Apr 12 2022, 11:19 AM
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
488

Alright. Thank you for the details.

shraiysh closed this revision.Apr 12 2022, 7:48 PM

This has been merged but the commit is somehow not being picked up by phabricator. Similar thing happened with D123562 (the commit right before this one)

This revision was landed with ongoing or failed builds.Apr 13 2022, 2:31 PM