<div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div><div>Hi,<br></div><div><br></div><div>In
 the 7/29 OpenMP in LLVM call, we discussed several issues related to 
OpenMP TR8's present map type modifier.  As suggested, I've discussed 
these issues with James Beyer.  Below are the conclusions I gathered from that 
discussion and my plans going forward.  Please let me know if there are 
any concerns.<br></div><div><br></div><div><span><div># Complaint for data that's not present on exit from target data region #<br></div><div><br></div><div>OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 321, L23-26 states:</div></span><div><div><div><span>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p>If the map clause appears on a target, target data, target enter<br>
data or target exit data construct with a present map-type-modifier<br>
then on entry to the region if the corresponding list item does not <br>
appear in the device data environment an error occurs and the <br>
program terminates.</p></blockquote></span>There is no corresponding 
statement about the exit from a region.  As a result, the following test
 case is a valid OpenMP program that should not fail:<br></div><div><br></div><div><span><div>
<p class="MsoNormal" style="margin-left:40px"><font size="2"><span style="font-family:monospace">#pragma omp target enter data map(alloc:i)<br>#pragma omp target data map(present, alloc: i)<br>{<br>  #pragma omp target exit data map(delete:i)</span></font></p><div style="margin-left:40px"><font size="2"><span style="font-family:monospace">
</span></font><font size="2"><span style="font-family:monospace">
</span></font></div></div></span><div style="margin-left:40px">
<p class="MsoNormal"><font size="2"><span style="font-family:monospace">} // i isn't present, but the present check doesn't happen on exit<br></span></font></p></div></div><div><br></div><div>James agrees that this is the intended interpretation of TR8.</div><div><br></div><div>My plan is to immediately push D84422, which implements this behavior and includes the above test.</div><div><div><br></div><div><span><div># Complaint for data that's not present on exit from target region #</div></span></div></div><div><br></div><div>James agrees the above interpretation also applies to target regions.  However, I have not for<font size="2">mulated a valid test case</font>.  For example, James agrees the following attempt isn't valid OpenMP because it has a race and might pass or fail:<br></div><span><div><br></div><div style="margin-left:40px"><font size="2"><span style="font-family:monospace">#pragma omp target enter data map(alloc:i)</span></font></div></span><p class="MsoNormal" style="margin-left:40px"><font size="2"><span style="font-family:monospace">#pragma omp target nowait map(present, alloc:i)</span></font></p><p class="MsoNormal" style="margin-left:40px"><font size="2"><span style="font-family:monospace">// i might not be present here, so the entry present check might fail</span></font></p><div style="margin-left:40px">
</div><p class="MsoNormal" style="margin-left:40px"><font size="2"><span style="font-family:monospace">{}<br></span></font></p><span><div style="margin-left:40px">
</div><p class="MsoNormal" style="margin-left:40px"><font size="2"><span style="font-family:monospace">#pragma omp target exit data map(delete:i)</span></font></p><p class="MsoNormal"><font size="2"><span style="font-family:monospace"><span style="font-family:arial,sans-serif"><br></span></span></font></p><p class="MsoNormal"><font size="2"><span style="font-family:monospace"><span style="font-family:arial,sans-serif">D84422
 includes a comment saying we're not bothering to eliminate the presence
 check on exit from a target region because we lack a test case.<br></span></span></font></p><p class="MsoNormal"><font size="2"><span style="font-family:monospace"><span style="font-family:arial,sans-serif"><br></span></span></font></p><p class="MsoNormal"><font size="2"><span style="font-family:monospace"><span style="font-family:arial,sans-serif">My
 plan is not to pursue this issue for now.  If someone later manages to 
write a test, I'd be happy to fix the implementation in a followup 
patch.<br></span></span></font></p><p class="MsoNormal"><font size="2"><span style="font-family:monospace"><span style="font-family:arial,sans-serif"><br></span></span></font></p></span><span><div># Effective ordering of map clauses #<br></div><div><br></div></span><div>OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 319, L10-11 states:<br></div><span><div><div>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p>For a given construct, the effect of a map clause with the to, from,<br>
or tofrom map-type is ordered before the effect of a map clause with<br>
the alloc, release, or delete map-type.</p></blockquote></div></div></span><div>However, L14-16 states:</div><div><span>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p>If a map clause with a present map-type-modifier is present in a map <br>
clause, then the effect of the clause is ordered before all other<br>
map clauses that do not have the present modifier.</p></blockquote></span>James agrees this combination is contradictory for cases like<span style="font-family:arial,sans-serif">
 `map(tofrom:var) map(present,alloc:var)`.  He says it was intended that
 the reordering in L10-11 be applied first, and 
then the reordering in L14-16 be applied.  We also discussed with Tobias
 Burnus from Mentor, who then filed OpenMP spec issue 2337, which also 
covers additional issues with the way reordering is specified.<br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">My plan for this issue is to add the following entries to Clang's OpenMP status doc:</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">For 5.0, in which L10-11 also appear but do not seem to be implemented in Clang:<br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">```<br></span></div><div><span style="font-family:arial,sans-serif">|
 device extension             | map clause reordering based on map types
                     | :none:`unclaimed`        |                        
                                               |</span></div><div><span style="font-family:arial,sans-serif">```</span></div><div><span style="font-family:arial,sans-serif"><br></span></div><div><span style="font-family:arial,sans-serif">For 5.1:<br></span></div><div><span style="font-family:arial,sans-serif"><br></span></div><span style="font-family:arial,sans-serif">```</span><div><span style="font-family:arial,sans-serif">|
 device extension             | map clause reordering reordering based 
on 'present' modifier | :none:`unclaimed`        |                      
                                                 |<br></span></div><div><span style="font-family:arial,sans-serif"></span></div><div><span style="font-family:arial,sans-serif">```<br></span></div></div></div><br><div>Thanks.</div><font color="#888888"><font color="#888888"><font color="#888888"><div><br></div><div>Joel</div></font></font></font></div></div></div><div><br><br></div></div>