https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128041
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=118694
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Thinking about this issue and PR 118694 and the implementation:
Anything that involves 'target' followed by a 'metadirective' where one of the
alternatives contains 'teams' must be handled as follows:
- put 'target with all its clauses' also into the metadirective choices
- and remove the outer target
i.e.
omp target if(cond) map(...)
omp metadirective
when(selector : parallel num_threads(cond))
when(selector2 : teams num_teams if(cond))
otherwise (nothing)
shall become relatively early:
omp metadirective
when(selector : target parallel if(cond) map(...) num_threads(cond))
when(selector2 : target teams if(target:cond) map(...) num_teams if(teams:
cond))
otherwise (target)
which avoids all issues related to nesting and 'teams'.
CAVEAT: If a clause is not target-consistent, this might lead to wrong results
– thus, one choice would be do only host the 'teams' – and keep also an inner
metadirective, i.e.:
omp metadirective
when(selector : target parallel if(cond) map(...) num_threads(cond))
when(selector2 : target teams if(target:cond) map(...) num_teams if(teams:
cond))
otherwise (target)
And obviously, when hoisting a 'DEVICE' selector before 'target' it needs to
become 'TARGET_DEVICE' selector.
And
metadirective when(selector : target) otherwise(nothing)
metadirective when(... : ...)
also needs to be handled. (This is all ugly!)
* * *
In any case, the currently generated code – esp. if statically resolvable
already on the host is bad by completely ignoring 'teams'.