<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">says it was intended that the reordering in L10-11 be applied first, and then the reordering in L14-16 be applied. 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal">We probably need to discuss this in OpenMP Accel meeting, if you apply the above rule then present becomes a no-op.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Ravi<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>From:</b> Openmp-dev <openmp-dev-bounces@lists.llvm.org> <b>
On Behalf Of </b>Joel E. Denny via Openmp-dev<br>
<b>Sent:</b> Tuesday, August 04, 2020 11:37 AM<br>
<b>To:</b> Openmp-dev <openmp-dev@lists.llvm.org><br>
<b>Cc:</b> James Beyer <jbeyer@nvidia.com>; Tobias Burnus <tobias_burnus@mentor.com><br>
<b>Subject:</b> [Openmp-dev] OpenMP TR8 present map type modifier issues<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"># Complaint for data that's not present on exit from target data region #<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 321, L23-26 states:<o:p></o:p></p>
</div>
<div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<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.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:30.0pt">
<span style="font-size:10.0pt;font-family:"Courier New"">#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><o:p></o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Courier New"">} // i isn't present, but the present check doesn't happen on exit</span><o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">James agrees that this is the intended interpretation of TR8.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">My plan is to immediately push D84422, which implements this behavior and includes the above test.<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"># Complaint for data that's not present on exit from target region #<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">James agrees the above interpretation also applies to target regions.  However, I have not for<span style="font-size:10.0pt">mulated a valid test case</span>.  For example, James agrees the following attempt isn't valid OpenMP because it
 has a race and might pass or fail:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div style="margin-left:30.0pt">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">#pragma omp target enter data map(alloc:i)</span><o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:30.0pt">
<span style="font-size:10.0pt;font-family:"Courier New"">#pragma omp target nowait map(present, alloc:i)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:30.0pt">
<span style="font-size:10.0pt;font-family:"Courier New"">// i might not be present here, so the entry present check might fail</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:30.0pt">
<span style="font-size:10.0pt;font-family:"Courier New"">{}</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:30.0pt">
<span style="font-size:10.0pt;font-family:"Courier New"">#pragma omp target exit data map(delete:i)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><o:p> </o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;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.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><o:p> </o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;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.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><o:p> </o:p></p>
<div>
<p class="MsoNormal"># Effective ordering of map clauses #<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">OpenMP TR8 sec. 2.22.7.1 "map Clause", p. 319, L10-11 states:<o:p></o:p></p>
</div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<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.<o:p></o:p></p>
</blockquote>
</div>
</div>
<div>
<p class="MsoNormal">However, L14-16 states:<o:p></o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<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.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal">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.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><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><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><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:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">```</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">| device extension             | map clause reordering based on map types                     | :none:`unclaimed`        |                                                                    
   |</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">```</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">For 5.1:</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">```</span><o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">| device extension             | map clause reordering reordering based on 'present' modifier | :none:`unclaimed`        |                                                                    
   |</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">```</span><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Thanks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#888888">Joel<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>