This is an archive of the discontinued LLVM Phabricator instance.

[openacc] Add acc routine support to acc dialect
ClosedPublic

Authored by razvanlupusoru on Jul 25 2023, 5:04 PM.

Details

Summary

Adds representation for acc routine under new operation named
acc.routine. This operation is associated with a function symbol.
It also gets its own compiler generated synthetic symbol name so
that it can be referenced from the associated function. The clauses
associated with the acc routine directive are captured in the
acc.routine op.

The linking between the func.func and its acc.routine declaration
is done through the acc.routine_info attribute. In practice, a
single acc routine is associated with a function. But the spec does
not specifically restrict this - thus the 1:N relationship between
func.func and acc.routine allowed in the dialect. Additionally, it
makes sense that multiple acc routines could be used for a single
function depending on loop context - to allow flexible parallelization.

Most acc routine clauses are supported including gang, gang(dim:),
vector, worker, seq, nohost, and bind. The only one not
supported is device_type. This is because most other clauses also
miss this and the effort to add support for it needs to be coordinated
and consistent.

Diff Detail

Event Timeline

razvanlupusoru created this revision.Jul 25 2023, 5:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 25 2023, 5:04 PM
razvanlupusoru requested review of this revision.Jul 25 2023, 5:04 PM
clementval accepted this revision.Jul 26 2023, 8:42 AM

LGTM. Just couple of formatting nits. Also the pre-commit ci is failing for a clang-format issue.

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
1051–1054

Remove brace

1074–1076

Remove brace. I know that in some other place we keep them but in lowering we follow the llvm guidelines for this.

1077–1079

Remove brace

1092–1095

Remove brace

This revision is now accepted and ready to land.Jul 26 2023, 8:42 AM
vzakhari accepted this revision.Jul 26 2023, 10:10 AM

Looks good modulo Valentin's remarks.

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1363

nit: it may be worth verifying somewhere that the symbols are actually defined by acc.routine operations.

razvanlupusoru marked 4 inline comments as done.Jul 26 2023, 11:35 AM
razvanlupusoru added inline comments.
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1363

I agree. I will need to figure out how to do this effectively - I possibly need a verifier pass. The attribute itself cannot do the verification because a lookup in symbol table needs an operation - and the attribute verifier does not have that.

Add description to operation and attribute. Address reviewer comments.

This revision was landed with ongoing or failed builds.Jul 26 2023, 3:07 PM
This revision was automatically updated to reflect the committed changes.