Hello.

In the past weeks I worked on the inclusion of experimental thread-safety support (mostly based on the work by Maxim Gaina) in the "devel" branch of the Parma Polyhedra Library.

A few relevant information:

- as said above, thread-safety support is only available in the git branch named "devel"

- in order to enable support for thread-safety, the library has to be configured using option "--enable-thread-safe"

- it assumes a compiler supporting C++11 threads (tested only with gcc on linux)

- currently thread-safety is only available when using the C++, C and Java language interfaces

- the timeout mechanism does NOT support thread safety (yet)

- a few examples of computations using multiple PPL threads can be found in:
      * demos/ppl_lcdd (for the C++ interface)
      * demos/ppl_lpsol (for the C interface)
      * interfaces/Java/tests/Variable_Output_thread_safe1.java

- it is worth stressing (again) that the library is *conditionally* thread safe: if any two application threads share library objects, the application should manage to properly serialize all accesses to these objects (note: even when all these accesses are meant to be read-only, because many PPL operators are "logically const", but may actually modify the internal representation of objects, therefore leading to race conditions)

- beware of inefficiencies coming from memory allocation; we suggest to replace the standard allocation mechanism with something that behaves better in a multi-threaded setting (e.g., TCMalloc).

It would be nice if people interested in this extension could give it a try and provide us with some feedback.

Enea.


On 08/10/2016 09:59 AM, Enea Zaffanella wrote:

Hello John.

The library, as is, is not thread safe (the main reason is that it uses a bunch of static caches to speed up single-threaded computations).

Maxim Gaina, a student under my supervision, produced a version of the library which is conditionally thread safe: safety is achieved as long as each thread has exclusive access to the PPL objects it works on. That is, either the objects are not shared between threads or the application code makes sure that shared objects are accessed at different times (e.g., using mutexes). The thread-safe version uses C++11 constructs and it was considering the C++ and C language interfaces only. For testing purposes, Maxim produced multi-threaded variants of demo programs ppl_lcdd and ppl_lpsol.

Afaict, Roberto was considering whether or not the work of Maxim was to be added to the main PPL library.

Cheers,
Enea


On 08/09/2016 11:23 PM, John Paulson wrote:
Hi Developers,

I have been using PPL for a couple of years, and I have just become interested in parallelizing an application I wrote that calls it. I tried to do this (using a parallel_for loop from TBB), but I ran into varied errors at run time.

I noticed that in the TODO file of the PPL distribution that it has "Make the library thread-safe" on the list. Has this been done yet? Would the lack of thread safety lead to strange run time errors?


Best,
John C. Paulson


_______________________________________________
PPL-devel mailing list
PPL-devel@cs.unipr.it
http://www.cs.unipr.it/mailman/listinfo/ppl-devel



_______________________________________________
PPL-devel mailing list
PPL-devel@cs.unipr.it
http://www.cs.unipr.it/mailman/listinfo/ppl-devel