[PPL-devel] OpenMP & PPL
Enea Zaffanella
zaffanella at cs.unipr.it
Wed Jan 3 11:17:29 CET 2018
On 31/12/2017 17:33, Thomas LE MÉZO wrote:
>
> Dear Enea, Dear all,
>
>
> 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 :
>
>
> #include <omp.h>
>
> namespace PPL = Parma_Polyhedra_Library;
>
>
> int main(){
>
> #pragma omp parallel for
> for(int i=0; i<1000; i++){
> PPL::C_Polyhedron ph1(3); // => segmentation fault at line 83 of
> Linear_Expression.cc
> PPL::C_Polyhedron ph2(3);
> ph1.intersection_assign(ph2);
> }
> return 0;
> }
>
> Would you have any idea about what is wrong?
>
Each thread should be properly initialized by creating a
PPL::Thread_Init object (and finalized by destroying it).
See for instance test01() in tests/Polyhedron/threadsafe1.cc
As an alternative, you could use the make_threadable wrapper (see
test02() in the same test).
> Is PPL compatible with using OpenMP?
>
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++).
In you code, I would try adding
PPL::Thread_Init thread_init;
as the very first line of the loop body.
This would maybe create more init objects than needed,
but (if I remember correctly) that should not be a problem.
Let us know how it goes.
Enea
>
> Thanks a lot in advance,
>
> Thomas
>
>
>
>
> _______________________________________________
> PPL-devel mailing list
> PPL-devel at cs.unipr.it
> http://www.cs.unipr.it/mailman/listinfo/ppl-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cs.unipr.it/pipermail/ppl-devel/attachments/20180103/8cc0ad22/attachment.htm>
More information about the PPL-devel
mailing list