Pthread vs intel TBB and their relation to OpenMP?

For multi-threaded programming, taking into account combinations with the HPC (MPI) application, which one is better, can we say that from the point of view of Intel TBB functionality (thread building block) is comparable to pthread or not? I am only gaining experience with open mp, but I heard that TBB and Pthread offer finer thread control than open mp, but can TBB or TBB + OpenMP offer similar functionality compared to pthread?

+7
source share
2 answers

pthread is a thin shell over the OS infrastructure. It allows you to create a stream with a given basic stream function and some synchronization primitives (mutex semaphores, etc.). On Linux, pthread is implemented on top of the clone(2) system call. The Windows equivalent is called CreateThread . All other streaming materials are built on top of this base.

Intel TBB is a higher level, it gives parallel_for and parallel_reduce and similar higher-level constructs, similar to OpenMP, but implemented as a library, not a language extension.

OpenMPI is even higher level with a distributed infrastructure with several machines, but it is very old-fashioned and a bit awkward.

My advice: study the pthread library first until you understand it completely, and then look at the higher-level libraries.

+4
source

TBB allows you to write portable code on top of your own streaming function, so it makes the code more portable across various OS architectures. I do not think this is "more efficient" than pthread.

I didn’t use open MP personally, but in the past I worked with developers using open MP (as a technical expert on the processors used), and it seems to work well enough for certain things, but it’s harder for others to use open mp than to write their own the code. It all depends on what exactly you are doing. Of course, one of the advantages of openmp is that you can always recompile the code without the openmp option, and the code works directly as you expect [but not scattered, of course].

With an approach to streaming programs, you can much better control what happens in the stream, yes. But it also means much more work ...

+2
source

All Articles