<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=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Helvetica;
        panose-1:2 11 6 4 2 2 2 2 2 4;}
@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;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:Menlo-Regular;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Verdana",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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 bgcolor="white" lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I think that the code should be viewed as not conforming to the OpenMP specification, since it is asserting
 (via the linear directive) something that is patently not true about the variable. (It’s stating that “lin” is incremented by 2 for each iteration of the loop, but that’s not the case since there is no code to do that!).<o:p></o:p></span></a></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Therefore the code can produce any result when running with OpenMP enabled.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Though, I  admit that at a quick skim, I can’t see where the specification would make this non-conforming…
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I suggest you ask in an appropriate forum on the OpenMP web site
</span><a href="http://forum.openmp.org/forum/"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US">http://forum.openmp.org/forum/</span></a><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US">
 since this seems to be an issue for the specification, not our specific implementation.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">-- Jim<br>
<br>
James Cownie <james.h.cownie@intel.com><br>
SSG/DPD/TCAR (Technical Computing, Analyzers and Runtimes)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">Tel: +44 117 9071438</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> Openmp-dev [mailto:openmp-dev-bounces@lists.llvm.org]
<b>On Behalf Of </b>Alexey Bataev via Openmp-dev<br>
<b>Sent:</b> Monday, November 21, 2016 9:16 AM<br>
<b>To:</b> Arpith C Jacob <acjacob@us.ibm.com>; openmp-dev@lists.llvm.org<br>
<b>Cc:</b> Hyojin Sung <hsung@us.ibm.com><br>
<b>Subject:</b> Re: [Openmp-dev] Behavior of linear clause on omp simd<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi Arpith,<o:p></o:p></p>
<p>I think the result is correct. See example 1.8 linear Clause in Loop Constructs in OpenMP 4.5 Examples document. The variable j gets final value 50 after the loop, not 49. So I think 21 is the right answer.<o:p></o:p></p>
<p>But there is another problem. Should we change the value of lin variable at all, taking into account that there is no code for lin variable incrementation inside the loop body? If the OpenMP program must generate the same result in non-OpenMP mode, then
 we have to have lin=1 in all iterations and at the end of the loop. What do you think?<o:p></o:p></p>
<pre>Best regards,<o:p></o:p></pre>
<pre>Alexey Bataev<o:p></o:p></pre>
<div>
<p class="MsoNormal">On 11/18/2016 11:02 PM, Arpith C Jacob wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p>Hi,<br>
<br>
I wanted to understand if the linear clause on a simd directive is behaving according to spec. Consider the following program:<br>
<br>
---<br>
<span style="font-family:"Menlo-Regular",serif;color:#E000E0">#include </span><span style="font-family:"Menlo-Regular",serif;color:#A11F12"><stdio.h></span><br>
<br>
<span style="font-family:"Menlo-Regular",serif;color:#00C200">int</span><span style="font-family:"Menlo-Regular",serif"> main() {</span><br>
<span style="font-family:"Menlo-Regular",serif;color:#00C200">int</span><span style="font-family:"Menlo-Regular",serif"> a[</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">11</span><span style="font-family:"Menlo-Regular",serif">];</span><br>
<span style="font-family:"Menlo-Regular",serif;color:#00C200">int</span><span style="font-family:"Menlo-Regular",serif"> lin =
</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">1</span><span style="font-family:"Menlo-Regular",serif">;</span><br>
<br>
<span style="font-family:"Menlo-Regular",serif;color:#E000E0">#pragma omp simd linear(lin:</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">2</span><span style="font-family:"Menlo-Regular",serif;color:#E000E0">)</span><br>
<span style="font-family:"Menlo-Regular",serif;color:#E26200">for</span><span style="font-family:"Menlo-Regular",serif"> (</span><span style="font-family:"Menlo-Regular",serif;color:#00C200">int</span><span style="font-family:"Menlo-Regular",serif"> i=</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">1</span><span style="font-family:"Menlo-Regular",serif">;
 i<=</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">10</span><span style="font-family:"Menlo-Regular",serif">; i++) {</span><br>
<span style="font-family:"Menlo-Regular",serif">a[i] = lin;</span><br>
<span style="font-family:"Menlo-Regular",serif">}</span><br>
<br>
<span style="font-family:"Menlo-Regular",serif">printf(</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"linear=
</span><span style="font-family:"Menlo-Regular",serif;color:#E000E0">%d\n</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"</span><span style="font-family:"Menlo-Regular",serif">, lin);</span><br>
<span style="font-family:"Menlo-Regular",serif">printf(</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"A =
</span><span style="font-family:"Menlo-Regular",serif;color:#E000E0">\n</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"</span><span style="font-family:"Menlo-Regular",serif">);</span><br>
<span style="font-family:"Menlo-Regular",serif;color:#E26200">for</span><span style="font-family:"Menlo-Regular",serif"> (</span><span style="font-family:"Menlo-Regular",serif;color:#00C200">int</span><span style="font-family:"Menlo-Regular",serif"> i=</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">1</span><span style="font-family:"Menlo-Regular",serif">;
 i<=</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">10</span><span style="font-family:"Menlo-Regular",serif">; i++) {</span><br>
<span style="font-family:"Menlo-Regular",serif">printf(</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"</span><span style="font-family:"Menlo-Regular",serif;color:#E000E0">%d</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">
 "</span><span style="font-family:"Menlo-Regular",serif">, a[i]);</span><br>
<span style="font-family:"Menlo-Regular",serif">}</span><br>
<br>
<span style="font-family:"Menlo-Regular",serif">printf(</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"</span><span style="font-family:"Menlo-Regular",serif;color:#E000E0">\n</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">"</span><span style="font-family:"Menlo-Regular",serif">);</span><br>
<br>
<span style="font-family:"Menlo-Regular",serif;color:#E26200">return</span><span style="font-family:"Menlo-Regular",serif">
</span><span style="font-family:"Menlo-Regular",serif;color:#A11F12">0</span><span style="font-family:"Menlo-Regular",serif">;</span><br>
<br>
<span style="font-family:"Menlo-Regular",serif">}</span><br>
---<br>
<br>
Output:<br>
<br>
<span style="font-family:"Menlo-Regular",serif">linear= 21</span><br>
<span style="font-family:"Menlo-Regular",serif">A = </span><br>
<span style="font-family:"Menlo-Regular",serif">1 3 5 7 9 11 13 15 17 19 </span><br>
<br>
The variable 'lin' has a value of '21' after the simd loop. According to the spec, should it have a value of '19' instead?<br>
<br>
<span style="font-family:"Helvetica",sans-serif">> The value corresponding to the sequentially last iteration of the</span><br>
<span style="font-family:"Helvetica",sans-serif">> associated loop(s) is assigned to the original list item.</span><br>
<br>
Thanks,<br>
Arpith<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Corporation (UK) Limited<br>
Registered No. 1134945 (England)<br>
Registered Office: Pipers Way, Swindon SN3 1RJ<br>
VAT No: 860 2173 47</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>