Design Patterns

Design Patterns#

This section provides some common parallel programming patterns and how to implement them in oneAPI Threading Building Blocks (oneTBB).

The description of each pattern has the following format:

  • Problem – describes the problem to be solved.

  • Context – describes contexts in which the problem arises.

  • Forces - considerations that drive use of the pattern.

  • Solution - describes how to implement the pattern.

  • Example – presents an example implementation.

Variations and examples are sometimes discussed. The code examples are intended to emphasize key points and are not full-fledged code. Examples may omit obvious const overloads of non-const methods.

Much of the nomenclature and examples are adapted from Web pages created by Eun-Gyu and Marc Snir, and the Berkeley parallel patterns wiki. See links in the General References section.

For brevity, some of the code examples use C++11 lambda expressions. It is straightforward, albeit sometimes tedious, to translate such lambda expressions into equivalent C++03 code.