Question

I'm using MSVC 2010 starting a new MFC-project and now trying to decide which lib to use for concurrent tasks. I know of the new C++0x thread features but it's not implemented in VC10. VC12 is not yet an option but it will come in the future. I do have the Microsoft PPL which looks good to me but we might move from Windows to Linux for new projects to come, so for reusing code maybe staying with the STL is more portable? For that I have the option to use boost in order to change to std with VC12.

My question is what should I prefere, PPL or temporarily boost and then std? I would like to hear your experiences with both, which one is more powerful, more convenience, advantages and disadvantages.

Was it helpful?

Solution

The PPL and the C++11 concurrency libraries are not really direct substitutes. PPL offers a higher level, task based approach to concurrency and can be both easier to work with and more efficient than managing threads directly using std::thread or similar threading libraries. PPL also includes things like parallel algorithms (parallel_for_each, parallel_transform, parallel_reduce, parallel_sort, etc.) and concurrent containers which are not included in the C++11 concurrency libraries.

It's also worth noting that the PPL and Intel's TBB (Threading Building Blocks) are designed to share the same interface to a large extent and TBB is supported on Linux so there is some cross platform portability when using the PPL. Intel, Microsoft and NVIDIA have a joint proposal for a parallel algorithms library for future versions of the C++ standard (C++14 and beyond) which are based on the PPL/TBB.

OTHER TIPS

Boost threads are easy, portable, well documented, and my usual go-to form of concurrency in C++ these days. If you're thinking of having linux builds going, don't rely on any VC features or your move will be very painful (done it the hard way myself before...).

That being said the new STL content is very similar to boost in most regards, so you could use boost as a stepping stone to std without much pain. I would read this post on differences between boost and C++11 threads and interpret for your use case before I made a concrete decision.

My experience with PPL is fairly limited but the creation of tasks (threads) may feel a bit different than traditional threads and have different control path options. You'll also mostly likely get fixed in Visual Studio/Windows if you go the PPL route -- so keep that in your evaluation of library choice. I did read that good PPL examples are bit sparse (probably why quick searches didn't give me better result on comparing PPL to other concurrency libraries).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top