<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 31/12/2017 17:33, Thomas LE MÉZO
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:AM4PR0501MB2850E608ECFC0168F32023D78B1B0@AM4PR0501MB2850.eurprd05.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;
color: rgb(0, 0, 0); font-family: Calibri, Helvetica,
sans-serif, "EmojiFont", "Apple Color
Emoji", "Segoe UI Emoji", NotoColorEmoji,
"Segoe UI Symbol", "Android Emoji",
EmojiSymbols;">
<p style="margin-top:0; margin-bottom:0">Dear <span>Enea, Dear
all,</span></p>
<p style="margin-top:0; margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span>I tried recently
to implement a multi-thread version of my thesis code using
PPL library. I used OpenMP and the last version of ppl on
devel git branch as I read you have been working on a
thread-safe implementation (thread-safe option with
configure). I didn't succeed in writing a correct program;
see for instance this simple code that return a segmentation
fault :</span></p>
<p style="margin-top:0; margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span><span>#include
<omp.h></span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span><span>namespace
PPL = Parma_Polyhedra_Library;</span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span><span>int main(){</span><br>
</span></p>
<p style="margin-top:0; margin-bottom:0"><span></span></p>
<div>#pragma omp parallel for<br>
for(int i=0; i<1000; i++){<br>
<span><span>PPL</span></span>::C_Polyhedron ph1(3);
// => segmentation fault
<span>at line 83 of Linear_Expression.cc</span><br>
<span><span>PPL</span></span>::C_Polyhedron ph2(3);<br>
ph1.intersection_assign(ph2);<br>
}</div>
<div> return 0;</div>
<div>}<br>
</div>
<br>
<p style="margin-top:0; margin-bottom:0">Would you have any idea
about what is wrong?</p>
</div>
</blockquote>
<br>
Each thread should be properly initialized by creating a
PPL::Thread_Init object (and finalized by destroying it).<br>
See for instance test01() in tests/Polyhedron/threadsafe1.cc<br>
As an alternative, you could use the make_threadable wrapper (see
test02() in the same test).<br>
<br>
<blockquote type="cite"
cite="mid:AM4PR0501MB2850E608ECFC0168F32023D78B1B0@AM4PR0501MB2850.eurprd05.prod.outlook.com">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;
color: rgb(0, 0, 0); font-family: Calibri, Helvetica,
sans-serif, "EmojiFont", "Apple Color
Emoji", "Segoe UI Emoji", NotoColorEmoji,
"Segoe UI Symbol", "Android Emoji",
EmojiSymbols;">
<p style="margin-top:0; margin-bottom:0"> Is PPL compatible with
using OpenMP?</p>
</div>
</blockquote>
<br>
I never tried using it with OpenMP ... however, as long as thread
initializations (and finalizations) are performed as suggested
above, things should be working (there is also a library
initialization part, but that is automatically done when working in
C++).<br>
<br>
In you code, I would try adding<br>
<br>
PPL::Thread_Init thread_init;<br>
<br>
as the very first line of the loop body.<br>
This would maybe create more init objects than needed,<br>
but (if I remember correctly) that should not be a problem.<br>
<br>
Let us know how it goes.<br>
<br>
Enea<br>
<br>
<blockquote type="cite"
cite="mid:AM4PR0501MB2850E608ECFC0168F32023D78B1B0@AM4PR0501MB2850.eurprd05.prod.outlook.com">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt;
color: rgb(0, 0, 0); font-family: Calibri, Helvetica,
sans-serif, "EmojiFont", "Apple Color
Emoji", "Segoe UI Emoji", NotoColorEmoji,
"Segoe UI Symbol", "Android Emoji",
EmojiSymbols;">
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Thanks a lot in
advance,</p>
<p style="margin-top:0; margin-bottom:0">Thomas<br>
</p>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
PPL-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:PPL-devel@cs.unipr.it">PPL-devel@cs.unipr.it</a>
<a class="moz-txt-link-freetext" href="http://www.cs.unipr.it/mailman/listinfo/ppl-devel">http://www.cs.unipr.it/mailman/listinfo/ppl-devel</a>
</pre>
</blockquote>
<br>
</body>
</html>