[Flang][OpenMP] Lower host_eval clauses during target lowering #200
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, the approach taken to deal with host-evaluated clauses for operations nested inside of
omp.target
was to use theHostClausesInsertionGuard
. This class moved the MLIR insertion point outside theomp.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 into theomp.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.