[Dune-devel] [SOCIS 2014]: C++11 threads vs POSIX threads

Agnese, Marco m.agnese13 at imperial.ac.uk
Thu Jun 5 19:41:44 CEST 2014


Hi dune developers,
I would like to discuss with you a crucial starting point of the project: which type of threads we want to use, C++11 or POSIX.

I studied mostly the C++11 threads (for example take a look of "The C++ programming language, Bjarne Stroustrup, 4th edition) and I think that this could be a good solution for several reasons:
1) no need of additional libraries 
2) standardized
3) type-safe
4) perfect integration with C++ (use of lambdas, functors and no need of using macros and void*)
5) simply notation
Moreover it offers different levels of concurrency support (from lowest level to the highest): atomic operations, threads and task).

A possible drawbacks of using C++11 threads is that we need a certain version of compilers. 
For example for GCC depending of the version we have different level of support (from http://gcc.gnu.org/projects/cxx0x.html):
Sequence points	Yes
Atomic operations GCC 4.4
Strong Compare and Exchange GCC 4.5
Bidirectional Fences GCC 4.8
Memory model GCC 4.8
Data-dependency ordering: atomics and memory model	 GCC 4.4
Propagating exceptions GCC 4.4
Abandoning a process and at_quick_exit GCC 4.8
Allow atomics use in signal handlers Yes
Thread-local storage GCC 4.8
Dynamic initialization and destruction with concurrency	GCC 4.3

What do you think?
Cheers,
Marco.




More information about the Dune-devel mailing list