Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Open MP / TBB

ekeom
Novice
1,164 Views

Dear all,

What are the mains differences between Open MP and TBB (Threading Building Blocks)? Clearly is TBB faster than openMP? Can TBB be activated using Fortran programming?

Best regards, Didace


0 Kudos
2 Replies
TimP
Honored Contributor III
1,164 Views
TBB is a C++ namespace implementation, so the threading is restricted to the C++. TBB in principle is more versatile than OpenMP, although it's still primarily a data parallel model. For problems in which OpenMP is well suited, it should perform better than TBB. We've been struggling over some cases where the difference in performance is more than it ought to be. In either case, programming skill is needed for good results.
Unfortunately, the threading library support for TBB, while compatible with Cilk+ and ArBB, isn't compatible with OpenMP, so it's difficult to make good use of TBB with Fortran. You would likely be able to use threaded parallelism only in C++ functions, using extern "C" linkage for interoperability with Fortran.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,164 Views
Didace,

As Tim points out, TBB does not integrate well with FORTRAN (we are on a Fortran forum).
This asside, for the C++ programmer, the selection of threading model will greatly depend on your application requirements. For applications where you principally have

loop
main context
parallel loop (or n-way fork)
main context
end loop

Then OpenMP will likely provide better performance

TBB is designed to better handle parallel tasks where the tasks tend to run with more independence. When a TBB task encounters a parallel_... statement there is no assumption as to the availibility of hardware theads to perform the slices of the loop or specified tasks. The threads may be (typically are) performing other tasks. Whereas in the typical OpenMP application, the assumption is thefull compliment of, or specified number of, threads are available.

Jim Dempsey
0 Kudos
Reply