Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

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

Ricky_Z_
Beginner
474 Views

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

0 Kudos
1 Solution
Alexei_K_Intel
Employee
474 Views

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

View solution in original post

0 Kudos
1 Reply
Alexei_K_Intel
Employee
475 Views

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

0 Kudos
Reply