Skip to content

Commit

Permalink
[Flang][OpenMP] Lower host_eval clauses during target lowering
Browse files Browse the repository at this point in the history
Previously, the approach taken to deal with host-evaluated clauses for
operations nested inside of `omp.target` was to use the
`HostClausesInsertionGuard`. This class moved the MLIR insertion point outside
the `omp.target` operation, so that clause lowering would produce code to be
evaluated in the host device.

However, this approach resulted in the use of MLIR values defined only inside
of the target region outside of it. Then, some fix-up work was performed to
replace these uses with the equivalent values outside, which had to consider
multiple corner cases based on the types and the origin of these values.

This patch replaces that approach with another in which these host-evaluated
clauses are lowered as part of the processing of `omp.target` clauses, so the
created MLIR operations are correct from the beginning, without the need for a
fix-up pass.

For that, evaluations related to a target construct are analyzed and processed
independently of the established lowering process, also checking nested
evaluations for the code patterns for which `host_eval` operands have to be
introduced for the `omp.target` operation under construction. If one of these
patterns is found, the relevant clauses are evaluated and stored in a global
structure.

This global structure is checked and used when lowering clauses for operations
that can potentially be evaluated in the host, rather than immediately prior to
that operation. If it has already been evaluated in the host, the corresponding
`omp.target` region block argument is passed as an operand to that operation.
Otherwise, it is evaluated as usual.
  • Loading branch information
skatrak committed Nov 7, 2024
1 parent 2fae4cc commit 7a73464
Show file tree
Hide file tree
Showing 4 changed files with 325 additions and 523 deletions.
Loading

0 comments on commit 7a73464

Please sign in to comment.