<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:"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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {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 lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">Can you lift the level a little?<o:p></o:p></span></a></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">Why do you care whether an instruction is executed in a parallel region or not?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">What higher-level problem are you trying to solve?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<p class="MsoNormal"><span lang="EN-GB" 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 lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">Tel: +44 117 9071438</span><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D"><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 style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> openmp-dev-bounces@cs.uiuc.edu [mailto:openmp-dev-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Simone Atzeni<br>
<b>Sent:</b> Wednesday, February 11, 2015 5:15 PM<br>
<b>To:</b> Ronan KERYELL<br>
<b>Cc:</b> openmp-dev@dcs-maillist2.engr.illinois.edu<br>
<b>Subject:</b> Re: [Openmp-dev] Knowing if an IR instruction will be executed by an OpenMP region<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi Ronan,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">thanks for you answer.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I think I will try to implement your first suggestion, some inter procedural control flow analysis.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I would like to do it statically and not involving any dynamic analysis.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">My basic idea is that given an instruction we can check if it belongs or not to an OpenMP microtask, if yes it will be executed<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">in parallel, if not I recursively check if its parent function is called inside an OpenMP construct and so on.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">In order to do this I was taking a look to llvm::CallGraph (<a href="http://llvm.org/docs/doxygen/html/classllvm_1_1CallGraph.html#details">http://llvm.org/docs/doxygen/html/classllvm_1_1CallGraph.html#details</a>) <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">do you think it could help?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Best,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Simone<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">Simone Atzeni<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="mailto:simone.at@gmail.com">simone.at@gmail.com</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+1 (801) 696-8373<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Feb 11, 2015, at 10:05, Ronan KERYELL <<a href="mailto:ronan-list@keryell.fr">ronan-list@keryell.fr</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">On Tue, 10 Feb 2015 11:19:39 +0000, "Cownie, James H" <<a href="mailto:james.h.cownie@intel.com">james.h.cownie@intel.com</a>> said:<o:p></o:p></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">is there a way to understand if an LLVM IR instruction will be<br>
executed by an OpenMP constructs?<o:p></o:p></p>
</blockquote>
</blockquote>
<p class="MsoNormal"><br>
   James> The simple answer is "No", you can't in general tell at<br>
   James> compile time whether code will be executed in parallel. (It<br>
   James> could be in a separate compilation unit, or even a dynamic<br>
   James> library which is only dlopened at runtime).<br>
<br>
Yes, this is why the OpenMP API provides functions like<br>
int omp_in_parallel(void);<br>
to test it.<br>
<br>
   James> Even without those practical examples, even knowing whether a<br>
   James> given IR instruction will ever be executed is clearly the<br>
   James> same as the halting problem...<br>
<br>
This is true but let's focus on the cases when we know it is not<br>
intractable... :-)<br>
<br>
You can apply some interprocedural control flow analysis in the compiler<br>
and in some cases be sure it is executed or not in parallel. Doing this<br>
in the LTO phase is a way to go.<br>
<br>
Another more pragmatic way is to rewrite some code bloc B by cloning it<br>
in the following way:<br>
<br>
if omp_in_parallel() {<br>
 // We know that here B is executed in a parallel context<br>
 B<br>
}<br>
else {<br>
 // We know that here B is not executed in a parallel context<br>
 B<br>
}<br>
and then go on with some optimizations on both paths.<br>
<br>
So this is a dynamic+static approach which may worth it if B is big enough.<br>
<br>
You may also use some partial evaluation late in the compilation phases<br>
to figure out that in some case omp_in_parallel() returns always true or<br>
false and then remove the dead code.<br>
-- <br>
 Ronan KERYELL<br>
_______________________________________________<br>
Openmp-dev mailing list<br>
<a href="mailto:Openmp-dev@dcs-maillist2.engr.illinois.edu">Openmp-dev@dcs-maillist2.engr.illinois.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/openmp-dev">http://lists.cs.uiuc.edu/mailman/listinfo/openmp-dev</a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</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>