<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Ronan,<div class=""><br class=""></div><div class="">thanks for you answer.</div><div class="">I think I will try to implement your first suggestion, some inter procedural control flow analysis.</div><div class="">I would like to do it statically and not involving any dynamic analysis.</div><div class=""><br class=""></div><div class="">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</div><div class="">in parallel, if not I recursively check if its parent function is called inside an OpenMP construct and so on.</div><div class="">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" class="">http://llvm.org/docs/doxygen/html/classllvm_1_1CallGraph.html#details</a>) </div><div class="">do you think it could help?</div><div class=""><br class=""></div><div class="">Thanks.</div><div class="">Best,</div><div class="">Simone</div><div class=""><br class=""></div><div class=""><div apple-content-edited="true" class="">
<div class="">Simone Atzeni</div><div class=""><a href="mailto:simone.at@gmail.com" class="">simone.at@gmail.com</a></div><div class="">+1 (801) 696-8373</div>

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Feb 11, 2015, at 10:05, Ronan KERYELL <<a href="mailto:ronan-list@keryell.fr" class="">ronan-list@keryell.fr</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">On Tue, 10 Feb 2015 11:19:39 +0000, "Cownie, James H" <<a href="mailto:james.h.cownie@intel.com" class="">james.h.cownie@intel.com</a>> said:<br class=""></blockquote></blockquote></blockquote></blockquote></blockquote><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">is there a way to understand if an LLVM IR instruction will be<br class="">executed by an OpenMP constructs?<br class=""></blockquote></blockquote><br class="">    James> The simple answer is "No", you can't in general tell at<br class="">    James> compile time whether code will be executed in parallel. (It<br class="">    James> could be in a separate compilation unit, or even a dynamic<br class="">    James> library which is only dlopened at runtime).<br class=""><br class="">Yes, this is why the OpenMP API provides functions like<br class="">int omp_in_parallel(void);<br class="">to test it.<br class=""><br class="">    James> Even without those practical examples, even knowing whether a<br class="">    James> given IR instruction will ever be executed is clearly the<br class="">    James> same as the halting problem...<br class=""><br class="">This is true but let's focus on the cases when we know it is not<br class="">intractable... :-)<br class=""><br class="">You can apply some interprocedural control flow analysis in the compiler<br class="">and in some cases be sure it is executed or not in parallel. Doing this<br class="">in the LTO phase is a way to go.<br class=""><br class="">Another more pragmatic way is to rewrite some code bloc B by cloning it<br class="">in the following way:<br class=""><br class="">if omp_in_parallel() {<br class="">  // We know that here B is executed in a parallel context<br class="">  B<br class="">}<br class="">else {<br class="">  // We know that here B is not executed in a parallel context<br class="">  B<br class="">}<br class="">and then go on with some optimizations on both paths.<br class=""><br class="">So this is a dynamic+static approach which may worth it if B is big enough.<br class=""><br class="">You may also use some partial evaluation late in the compilation phases<br class="">to figure out that in some case omp_in_parallel() returns always true or<br class="">false and then remove the dead code.<br class="">-- <br class="">  Ronan KERYELL<br class="">_______________________________________________<br class="">Openmp-dev mailing list<br class=""><a href="mailto:Openmp-dev@dcs-maillist2.engr.illinois.edu" class="">Openmp-dev@dcs-maillist2.engr.illinois.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/openmp-dev<br class=""></div></blockquote></div><br class=""></div></body></html>