Parallel Frameworks

Before you can add parallel code , you must first choose a parallel framework.

There are two popular mechanisms for using threads - either use high-level parallel frameworks or explicit threading APIs. Intel recommends using parallel frameworks for both ease of use and their ability to optimize for different situations.

For managed code such as C#, use the Microsoft Task Parallel Library* (TPL).

This document shows how to use the widely-used parallel frameworks for native code, which are included with most Intel® Parallel Studio XE editions and may be included with other compilers:

  • Intel® Threading Building Blocks

  • OpenMP*

Intel Threading Building Blocks (Intel® TBB) is a parallel programming framework for C++ code. Intel TBB is structured as a traditional C++ library, consisting of header files and a run-time library, so it can be used with any C++ compiler. Intel recommends that you consider using Intel TBB for introducing parallelism into C++ programs. Intel TBB programs can be run on any platform (OS/architecture pair) to which the Intel TBB library has been ported. For example, the Intel® C++ Compiler includes Intel TBB and supports Windows*, Linux*, and Apple OS X* operating systems. The open source version is available at http://www.threadingbuildingblocks.org.

OpenMP is a high-level framework that supports C, C++, and Fortran. OpenMP is provided by compiler support, so you modify your sources by using compiler directives rather than using types, variables, and calls. An OpenMP program can often be changed from parallel execution to serial execution by setting an environment variable or omitting a compiler option so the compiler ignores the directives. OpenMP 2 is supported by the Microsoft, the Intel, and the GNU* C, C++ and Fortran compilers. The OpenMP 3.0 standard adds TASK support and is supported by the Intel compilers, which also support parts of OpenMP 4.0. For Microsoft and GNU compilers, consult your compiler documentation for the current level of OpenMP support.

You can also use a different parallel framework.

Windows OS: Support for Parallel Frameworks by Microsoft and Intel Compilers

With a Fortran program, the only high-level parallel framework available is OpenMP. The following table summarizes the support by Microsoft and Intel Compilers for the recommended parallel frameworks for C/C++ programs on Windows OS systems.

Language and Compiler

Intel TBB

OpenMP

C programs, Intel C++ Compiler

Supported

C++ programs, Intel C++ Compiler

Supported

Supported

C programs, Microsoft Visual C++* Compiler

Supported

C++ programs, Microsoft Visual C++ Compiler

Supported

Supported

For more information about Intel TBB and OpenMP, see the following sections in this Intel Advisor help system. For detailed instructions, see the Intel® Composer XE documentation and the resources listed in Related Information.

Linux OS: Support for Parallel Frameworks by GNU* and Intel Compilers

With a Fortran program, the only high-level parallel framework available is OpenMP. The following table summarizes the support by GNU gcc* and Intel compilers for the recommended parallel frameworks for C/C++ programs on Linux OS systems.

Language and Compiler

Intel TBB

OpenMP

C programs, Intel C++ Compiler (icc)

Supported

C++ programs, Intel C++ Compiler icc)

Supported

Supported

C programs, GNU gcc Compiler (gcc)

Supported

C++ programs, GNU gcc Compiler (gxx)

Supported

Supported

For more information about Intel TBB and OpenMP, see the following sections in this Intel Advisor help system. For detailed instructions, see your compiler documentation and the resources listed in Related Information.

For more complete information about compiler optimizations, see our Optimization Notice.