Need a guide line for using TBB in C++11 compiler

Need a guide line for using TBB in C++11 compiler

I have read TBB reference but I still have no clue how to use TBB in C++11 compiler properly.

In my C++11 compatible compiler,

1. Should I use std::thread or include tbb own std thread class?

2. Can I mix compiler built-in threading library with tbb? Eg, Can std::mutex work in tbb::parallel_for?

I found a forum thread in 2012 but I can't figure it out the conclusion. Can anyone provide a guide line? For sure, I can write a test case to give it a try. But I'd like to hear it from tbb developers.

TIA

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

Hi Ricky,

Historically, Intel TBB had introduced many C++11-like features before the C++11 language was developed. There has never be a goal to implement the standard features within tbb-namespace, so such stuff as tbb::atomic, tbb::mutex and other seem obsolete. Therefore, if you need a functionality that is implemented in C++, I recommend using it instead of Intel TBB.

As for your questions:

1. Should I use std::thread or include tbb own std thread class?

Feel free to use std::thread.

2. Can I mix compiler built-in threading library with tbb? Eg, Can std::mutex work in tbb::parallel_for?

All C++11 synchronization primitives will work within Intel TBB parallel constructions. There are some differences in interfaces that are described in the C++11 Synchronization section. In addition, you can mix Intel TBB threading with any other threading. See the Appendix B Mixing With Other Threading Packages section.

Regards, Alex

Leave a Comment

Please sign in to add a comment. Not a member? Join today