<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:courier new,monospace;font-size:small">My apology. I think I didn't get Jim's email</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 16, 2020 at 2:11 PM Churbanov, Andrey <<a href="mailto:Andrey.Churbanov@intel.com">Andrey.Churbanov@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_3179201250473071032WordSection1">
<p class="MsoNormal">Couple of weeks ago Jim Cownie <span style="color:black"><<a href="mailto:jcownie@gmail.com" target="_blank">jcownie@gmail.com</a>> effectively answered your question.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:black">Let me try to re-iterate:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">> For each static_init_4 call, there is a static_fini call. Is this specific to its static_init_4 call?</span><u></u><u></u></p>
<p class="MsoNormal">Yes.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">> Is there a pairing of calls that can not be broken?</span><u></u><u></u></p>
<p class="MsoNormal">Yes, though I am not completely sure what you are asking about here.  You can break the code any way you want, but why?<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">> If we look at the static_fini call, the function arguments are the same.</span><u></u><u></u></p>
<p class="MsoNormal">Same as what?  They are probably same location info and global thread id as in the corresponding static_init call, if I got your question right.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">> It seems that if we have two static_init_4 function calls, we can interchange their static_fini calls. Does that make sense?</span><u></u><u></u></p>
<p class="MsoNormal">Not sure what is your goal here… All you can achieve by such broken code generation is to confuse an OMPT tool with unspecified results, possibly break statistics gathering, break checking of consistency of the OpenMP constructs, - all
 the code of static_fini does.<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">> If I move the static_fini call beyond Loop-B in IR; Should Loop-B be part of the Work Sharing environment and its iteration should be distributed similarly to Loop-A over the available
 threads?<u></u><u></u></span></p>
<p class="MsoNormal">All you can achive here is again to get broken code generation, and as a result to confuse an OMPT tool with unspecified results, etc.  The static_fini call does not affect parallelization in any way, so your second Loop-B will remain to
 be serial loop and will be redundantly executed by all threads of the team, regardless of the location of the static_fini call.  To make a loop work sharing, it should be parallelized (e.g. by adding “#pragma omp for” in the source code, given there exist
 enclosing parallel region).<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">As Jim suggested earlier, look at the code!<u></u><u></u></p>
<p class="MsoNormal"><span lang="RU"><u></u> <u></u></span></p>
<p class="MsoNormal">And please first describe the problem you want to solve. As opposed to trying to shuffle statements by guess.<u></u><u></u></p>
<p class="MsoNormal"><u></u> </p></div></div></blockquote><div><br></div><div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">If two #omp for loops are compatible (i.e they have same in terms of parameter values for call functions), I am trying two runs with single pair of static_init and static)fini calls </div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">#pragma omp for</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">Loop-A</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">#pragma omp for</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">Loop-B</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">Loop-A and Loop-B are compatible ( same iterations and chunk size)</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">---> will produce</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">call __kmpc_static_init4A()</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">Loop-A</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">call __kmpc_static_finiA()</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><br></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><div class="gmail_default">call __kmpc_static_init4B()</div><div class="gmail_default">Loop-B</div><div class="gmail_default">call __kmpc_static_finiB()</div></div><br></div><div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">---> want to achieve</div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"><div class="gmail_default"><div class="gmail_default">call __kmpc_static_init4A()</div><div class="gmail_default">Loop-A</div><div class="gmail_default">//call __kmpc_static_finiA()</div><div class="gmail_default">// Remove these two call values and adjust use values as necessay </div><div class="gmail_default"><div class="gmail_default">//call __kmpc_static_init4B()</div><div class="gmail_default">Loop-B</div><div class="gmail_default">call __kmpc_static_finiB()</div></div></div></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small"></div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">this will avoid the recalculation of chunk size etc.</div><br></div><div><div class="gmail_default" style="font-family:"courier new",monospace;font-size:small">Hope this helps!</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="EN-US"><div class="gmail-m_3179201250473071032WordSection1"><p class="MsoNormal"><u></u></p>
<p class="MsoNormal">Regards<span lang="RU">,<u></u><u></u></span></p>
<p class="MsoNormal">Andrey<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>From:</b> Abid Malik <<a href="mailto:abidmuslim@gmail.com" target="_blank">abidmuslim@gmail.com</a>> <br>
<b>Sent:</b> Monday, March 16, 2020 5:58 PM<br>
<b>To:</b> Churbanov, Andrey <<a href="mailto:Andrey.Churbanov@intel.com" target="_blank">Andrey.Churbanov@intel.com</a>><br>
<b>Cc:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [Openmp-dev] counts in the work sharing<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Thanks for the information.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">For each static_init_4 call, there is a static_fini call. Is this specific to its static_init_4 call? Is there a pairing of calls that can not be broken? If we look at the static_fini
 call, the function arguments are the same. It seems that if we have two static_init_4 function calls, we can interchange their static_fini calls. Does that make sense?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Suppose we have two loops, Loop-A and Loop-B ( Loop-A and Loop-B are identical in terms of iteration, chunk, increment, etc). One with omp for loop and other without it<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">#pragma omp for<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">{<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">  Loop-A<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">}<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Loop-B<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">If I move the static_fini call beyond Loop-B in IR; Should Loop-B be part of the Work Sharing environment and its iteration should be distributed similarly to Loop-A over the available
 threads?<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Thanks,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Mar 16, 2020 at 8:04 AM Churbanov, Andrey <<a href="mailto:Andrey.Churbanov@intel.com" target="_blank">Andrey.Churbanov@intel.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">For static schedule the runtime does not track iterations.  The __kmpc_for_static_init_4 (or similar, depending on the iteration variable type) is the only runtime call for a statically
 scheduled loop (not counting leading barrier if any). After it compiler just loops over obtained range of iterations without involving runtime any more.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Regards,<u></u><u></u></p>
<p class="MsoNormal">Andrey<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><b>From:</b> Openmp-dev <<a href="mailto:openmp-dev-bounces@lists.llvm.org" target="_blank">openmp-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Abid Malik via Openmp-dev<br>
<b>Sent:</b> Friday, March 13, 2020 9:35 PM<br>
<b>To:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a><br>
<b>Subject:</b> [Openmp-dev] counts in the work sharing<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Hello,<br clear="all">
</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">I am looking into the void __kmp_for_static_init4 function which marks the start work sharing. </span><span style="font-size:9pt;font-family:Verdana,sans-serif;color:black;background:rgb(238,243,245)">The
 function computes the upper and lower bounds and stride to be used for the set of iterations to be executed by the current thread from the statically scheduled loop that is described by the initial values of the bround, stride, increment and chunk size.  How
 the record of iterations is kept. Which function/file should I look into to keep track of the iteration?</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New""> </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Courier New"">Thanks,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">--
<u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">Abid M. Malik<br>
******************************************************<br>
"I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran<br>
"Success is not for the chosen few, but for the few who choose" --- John Maxwell<br>
"Being a good person does not depend on your religion or status in life, your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD YOU TREAT OTHERS"--- Abid<br>
"The Universe is talking to us, and the language of the Universe is mathematics."----Abid<br>
 <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
<p><br>
--------------------------------------------------------------------<br>
Joint Stock Company Intel A/O<br>
Registered legal address: Krylatsky Hills Business Park, <br>
17 Krylatskaya Str., Bldg 4, Moscow 121614, <br>
Russian Federation<u></u><u></u></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.<u></u><u></u></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<p class="MsoNormal">Abid M. Malik<br>
******************************************************<br>
"I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran<br>
"Success is not for the chosen few, but for the few who choose" --- John Maxwell<br>
"Being a good person does not depend on your religion or status in life, your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD YOU TREAT OTHERS"--- Abid<br>
"The Universe is talking to us, and the language of the Universe is mathematics."----Abid<br>
 <u></u><u></u></p>
</div>
</div>
</div>
</div>
<p><br>--------------------------------------------------------------------<br>Joint Stock Company Intel A/O<br>Registered legal address: Krylatsky Hills Business Park, <br>17 Krylatskaya Str., Bldg 4, Moscow 121614, <br>Russian Federation</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>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Abid M. Malik<br>******************************************************<br>"I have learned silence from the talkative, toleration from the intolerant, and kindness from the unkind"---Gibran<br>"Success is not for the chosen few, but for the few who choose" --- John Maxwell<br>"Being a good person does not depend on your religion or status in life, your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD YOU TREAT OTHERS"--- Abid<br>"The Universe is talking to us, and the language of the Universe is mathematics."----Abid<br> </div></div></div></div>