Hello Regarding this issue which we discussed previously - I have created a patch that adds a warning when this situation is detected. When a metadirective in a explicitly marked target function is gimplified, it is checked to see if it contains a 'construct={target}' selector - if it does, then the containing function is marked with 'omp metadirective construct target'. In the omp-low pass, when function calls are processed, the target function is checked to see if it contains the marker. If it does and the call is not made in a target context, a warning is emitted. This will obviously not catch every possible occurence (e.g. if the function containing the metadirective is called from another target function which is then called locally, or if the call is made via a function pointer), but it might still be useful? Okay for mainline (once the metadirective patches are done)? Thanks Kwok On 26/07/2021 10:23 pm, Jakub Jelinek wrote: > On Mon, Jul 26, 2021 at 10:19:35PM +0100, Kwok Cheung Yeung wrote: >>> Yes, that is a target variant, but I'm pretty sure we've decided that >>> the target construct added for declare target is actually not a dynamic >>> property. So basically mostly return to the 5.0 wording with clarifications >>> for Fortran. See >>> https://github.com/OpenMP/spec/issues/2612#issuecomment-849742988 >>> for details. >>> Making the target in construct dynamic would pretty much force all the >>> scoring to be dynamic as well. >> >> In that comment, Deepak says: >> >> So, we decided to keep the target trait static, requiring that the declare >> target directive must be explicit and that the function version must be >> different from the version of the function that may be called outside of a >> target region (with the additional clarification that whether it differs or >> not will be implementation defined). >> >> "the function version must be different from the version of the function >> that may be called outside of a target region": This is what we do not have >> in GCC at the moment - the function versions called within and outside >> target regions are the same on the host. >> >> "whether it differs or not will be implementation defined": So whether a >> function with 'declare target' and a metadirective involving a 'target' >> construct behaves the same or not when called from both inside and outside >> of a target region is implementation defined? >> >> I will leave the treatment of target constructs in the selector as it is >> then, with both calls going to the same function with the metadirective >> resolving to the 'target' variant. I will try to address your other concerns >> later. > > I think you're right, it should differ in the host vs. target version iff > it is in explicit declare target block, my memory is weak, but let's implement > the 5.0 wording for now (and ignore the 5.1 wording later on) and only when > we'll be doing 5.2 change this (and change for both metadirective and > declare variant at that point). > Ok? > > Jakub >