Back to Taskflow

Intel® Threading Building Blocks.Common source code for samples

3rd-party/tbb/examples/common/index.html

4.0.02.9 KB
Original Source

Intel® Threading Building Blocks. Common source code for samples

This directory contains common code that is used in the Intel® Threading Building Blocks (Intel® TBB) samples.
This code is not intended to be used directly. It is incorporated automatically by the examples that need it.

Directories

gui GUI code for examples that have graphical user interfaces. Currently supports:

  • GDI+*, DirectDraw*, Direct2D* (Windows* systems)
  • OpenGL* (macOS* systems)
  • X window (Linux* or macOS* systems)

See the examples that use the GUI (stereo, tachyon, seismic, fractal) for more details. utilityCommon driver and utility code for examples. Currently provides:

  • class FastRandom - a random number generator that uses linear congruential method (fast_random.h)
  • class thread_number_range - a class to specify the numbers of threads an example should use (utility.h)
  • support for command line interface - class cli_argument_pack and function parse_cli_arguments (utility.h)

Common information

Number of threads

Most Intel TBB examples allow to specify n-of-threads, the set of thread numbers that should be used to run an example.
Usually, it is a range of the form low[:high[:(+|*|#)S]], where low and optional high are non-negative integers or 'auto' for the default choice, and optional step expression (+|*|#)S specifies how thread numbers are chosen within the range:

  • With +/*, the previous number is incremented/multiplied by S. E.g., expression '12:16:+1' means 12,13,14,15,16 threads, and '1:16:*2' means 1,2,4,8,16 threads.
  • With #, S is the desired number of steps between any subsequent powers of 2; it must be a power of 2 on its own, with most meaningful values being 2, 4, and 8. For a given number of threads, the actual step value is computed as the quotient of the nearest smaller power of 2 divided by the number of steps, but is at least 1. E.g., '1:32:#4' means 1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32 threads; note the step doubling at 8 and 16 to keep 4 steps between powers of 2.

A default value for the number of threads can be customized in an example. If not customized, it is '1:auto:#4'. The 'auto' parameter is substituted with a value returned by a specified function (this function is typically utility::get_default_num_threads(), which returns a copy of constant that was initialized with tbb::global_control::active_value(tbb::global_control::max_allowed_parallelism) at the start of the program).

Up to parent directory


Legal Information:

Intel and the Intel logo are trademarks of Intel Corporation in the U.S. and/or other countries.
* Other names and brands may be claimed as the property of others.
© 2020, Intel Corporation