[PATCH v6 4/6] OpenMP: Fortran support for metadirectives and dynamic selectors

Tobias Burnus tburnus@baylibre.com
Thu Jan 30 10:06:36 GMT 2025


Hi Sandra,

Sandra Loosemore wrote:
>> * Unless it is quickly fixable, we agreed on deferring the bogus message
>>    "Error: ‘target’ construct with nested ‘teams’ construct contains 
>> directives
>>            outside of the ‘teams’ construct"
>>    to a new PR. That's for:
>> OpenMP_VV's 
>> tests/5.0/metadirective/test_metadirective_arch_is_nvidia.F90
...
> I filed PR118694 for this.
>
> This one is going to be hard to fix, or at least I don't have any good 
> ideas on how to fix it.  Cases that require late resolution without 
> dynamic selectors might be hacked around to recognize and skip over an 
> intervening metadirective between the "target" and "teams", but it 
> doesn't seem like the code for evaluating dynamic selectors can 
> generally be hoisted outside of the outer "target".

I think the typical pattern is:

omp target

   omp metadirective when(device={kind(gpu)} : teams distribute parallel 
for/do) otherwise(parallel do/for)

as, for GPUs, using 'teams' is usually a good idea, but for host 
fallback it isn't.

In GCC, this means that it is statically resolved but only late. (In 
other compilers, it is early resolved.)

But for dynamic selectors, I think printing an error makes sense – and 
it depends on the user-code how to resolve it best.

* * *

> I'll push the attached patch tomorrow, along with the remaining piece 
> of the series to update the implementation status table in the libgomp 
> manual, unless you want more time to do another round of review first. 
> Also need to update the GCC 15 release notes!

I glanced it again and it LGTM. Thanks!

[Glancing at it, I saw a missing space before '=' in

+      gfc_omp_variant *variant= c->ext.omp_variants;
]

Tobias



More information about the Fortran mailing list