This is an archive of the discontinued LLVM Phabricator instance.

[openacc] Add dialect representation for atomic operations
AbandonedPublic

Authored by razvanlupusoru on Aug 24 2023, 1:09 PM.

Details

Summary

The OpenACC standard specifies an atomic construct in section 2.12
(of 3.3 spec), used to ensure that a specific location is accessed or
updated atomically. Four different clauses are allowed: read, write,
update, or capture. If no clause appears, it is as if update
is used.

The OpenMP specification defines the same clauses for omp atomic. The
types of expression and the clauses in the OpenACC spec match the OpenMP
spec exactly. The main difference is that the OpenMP specification is a
superset - it includes clauses for hint and memory order. It also
allows conditional expression statements. But otherwise, the expression
definition matches.

Thus, for OpenACC, we reuse the OpenMP implementation as follows:

  • The dialect operations are duplicated and the not needed parts removed

(hint and memory order). The goal is no dependence or coupling between
the two dialects so they can continue to evolve without hindrance from
the other. - The verification operations are also duplicated with the
not needed parts removed. This part could possibly be shared by having a
common verifier pieces that are templated. Having it shared could be
beneficial when fixing errors or adding further constraints - the
disadvantage is that it would introduce some coupling on design.

The frontend lowering necessary to generate the dialect can be reused.
This will be done in a follow up change.

Diff Detail

Event Timeline

razvanlupusoru created this revision.Aug 24 2023, 1:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2023, 1:09 PM
razvanlupusoru requested review of this revision.Aug 24 2023, 1:09 PM
clementval added inline comments.Aug 24 2023, 1:56 PM
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1268–1278

What is the use of these? I don't see any use in the lowering as well. Same question for the other ops.

razvanlupusoru added inline comments.Aug 24 2023, 4:21 PM
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1268–1278

My intent was to ensure that the operations provide same-ish interface as the OpenMP ones. But I agree this is not needed for now.

clementval added inline comments.Aug 25 2023, 12:42 PM
mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1268–1278

If needed it would be better to achieve this through a shared interface attached to the op itself.

mlir/include/mlir/Dialect/OpenACC/OpenACCOps.td
1268–1278

Great idea. I actually like the idea of this approach since it doesn't couple the two dialects! Nice. I will investigate what needs shared early next week.

Rebase. Remove several unused methods from new operations.

clementval accepted this revision.Aug 30 2023, 10:28 AM

Looks mostly good for me. Just one comment about the empty verifier.

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp
1101

It's better to disable the verifier in the op declaration so we don't need an empty verifier.

This revision is now accepted and ready to land.Aug 30 2023, 10:28 AM