Overview

This directory has example usages of Intel® Threading Building Blocks (Intel® TBB).

Directories

GettingStarted
Examples from the Getting Started Guide.
concurrent_hash_map
Examples using concurrent_hash_map.
concurrent_priority_queue
Examples using concurrent_priority_queue.
graph
Examples using tbb::flow graph.
parallel_do
Examples using parallel_do.
parallel_for
Examples using parallel_for.
parallel_reduce
Examples using parallel_reduce.
pipeline
Examples using pipeline.
task
Examples using raw task interface.
task_group
Examples using task_group interface.
task_arena
Examples using the task priority feature.
test_all
Examples that test all the parts of the package.
common
Common files for building various examples. Should not be used directly. But if you copy an example to other place this folder should be copied also and should have the same relative path for copied example.

To Build

Build each example by using one of the following methods. The specific directions for each method can be found below.

Some of the following directions refer to a shell window; this refers to the command prompt environment/window normally used on your system. A shell might be a cmd.exe command prompt window (Windows* systems), or a sh, bash, csh, ksh, etc. (or compatible) shell window (Windows*, Linux* or OS X* systems).

To build by using a Microsoft* Visual Studio* project (Windows* systems):

Perform the following steps:
  1. Identify the solution (*.sln) file for the example you wish to build and run. For Microsoft* Visual Studio* 2010, the *.sln file is in the example's msvs sub-directory.
  2. Open the project by using one of the following methods:
  3. Press <ctrl-F5> to build and run the example.
  4. If you copied an example to another place separately from libraries you need to set %TBBROOT% variable pointing to <installdir> folder.

To build by using a Xcode* IDE project (OS X* systems):

Perform the following steps:
  1. Identify the project (*.xcodeproj) file for the example you wish to build and run.
  2. Open the project by using one of the following methods:
  3. Press <Apple-R>, or press the "Build and Go" button in the toolbox, to build and run the example.

To build by using a Makefile (Windows*, Linux* or OS X* systems):

Perform the following steps:
  1. Open a shell window. For Windows* systems, make sure this shell window has the proper environment defined for use with Microsoft* Visual Studio* (2010, 2012, 2013 or 2015); such a shell can be invoked from the Start menu, under Visual Studio, Visual Studio Tools, Visual Studio Command Prompt.
  2. Set up the environment in this shell window for use with Intel TBB.
    See below for how to set up the environment for Windows*, Linux* or OS X* systems.
  3. Unless you installed Intel TBB yourself, you may not have write permissions to the directory containing the example. In this case, make a copy of the example, and use the copy for the following steps.
  4. In the shell window, navigate to the directory for the example (or to the directory for the copy of the example if you made one in the previous step).
  5. Use one or more of the following commands to build and run the example. Here, make refers to the make command normally used on your system: this could be nmake, gmake, or make on Windows* systems, or make or gmake on Linux* or OS X* systems.
    make
    Default build and run. Equivalent to 'make release test'.
    make release
    Compile and link against the release version of Intel TBB runtime library. The resulting executable is left in the directory for the example.
    make debug
    Compile and link against the debug version of Intel TBB runtime library. The resulting executable is left in the directory for the example.
    make test
    Run an executable previously produced by one of the above commands.
    make [(above options or targets)] CXX={icl, icc}
    Build and run as above, but use Intel® compilers instead of default, native compilers (e.g., icl instead of cl.exe on Windows* systems, or icc instead of g++ on Linux* or OS X* systems).
    make [(above options or targets)] offload=mic
    Build and run the offload version of an example for Intel® Many Integrated Core (Intel® MIC) Architecture.
    Note: Only Intel® MIC Architecture with Linux* based host is currently supported.
    make clean
    Remove any executables or intermediate files produced by the above commands.

To build by using a Eclipse* IDE project (Windows* systems only):

Perform the following steps:
  1. Launch Eclipse* IDE. Create a new Eclipse* workspace located in the Intel TBB root directory.
  2. Perform the following steps to open a project you wish to build and run:
    1. Go to the "File -> Import" dialog and choose "Android -> Existing Android Code Into Workspace".
    2. Fill in the "Root directory" field with the project folder path.
      Note: To be built and run correctly, Intel TBB example project for Eclipse* IDE has to be located in %TBBROOT%\examples\<feature_name>\<example_name>\android folder.
    3. Make sure the "Copy projects into workspace" option is unchecked.
    4. Click "Finish".
  3. Press <ctrl-B> or use "Project -> Build All" or "Project -> Build Project" to build the example.
    Note: Do not forget to set the "NDK location" in "Window -> Preferences -> Android -> NDK".
  4. Use "Run -> Run Configurations" to create a new deployment configuration for your project. Choose "Android Application" configuration type and "Always prompt to pick device" target selection mode.
  5. To run the example, press <ctrl-F11> or use "Run -> Run" and select any compatible Android device.

To build by using a Android* Studio* project (Windows* systems only):

Perform the following steps:
  1. Launch Android* Studio* and open a project you wish to build and run by using one of the following methods: Note: To be built and run correctly, Intel TBB example project for Android* Studio* has to be located in %TBBROOT%\examples\<feature_name>\<example_name>\android_as folder;
    Also note that source files for Intel TBB example project for Android* Studio* are located in %TBBROOT%\examples\<feature_name>\<example_name>\android folder.
  2. Use "Tools -> Android -> Sync Project with Gradle Files" to synchronize your project with Gradle* build scripts.
  3. Press <Shift-F9>, or use "Build -> Make project" to build the example.
  4. Start any compatible Android* Virtual Device or plug in a real Android* device with the appropriate architecture.
  5. Press <Shift-F10>, or use "Run -> Run 'app'" to run the example.

To set up the environment (Windows* systems):

It is strongly recommended that the environment be set up when installing Intel TBB. Do this by selecting the appropriate check-box during the install. However, if the environment is not set up during installation, or you wish to build for an alternate architecture or Microsoft* Visual Studio* version, it may be set up, for a given type of shell window, by using one of the following commands:
For cmd.exe (command prompt):
<installdir>\bin\tbbvars.bat (arch) (vs)
    where (arch) must be is one of the following
        ia32         : Set up for IA-32  architecture
        intel64      : Set up for Intel® 64  architecture
    (vs) should be one of the following
        vs2010       : Set to use with Microsoft Visual Studio 2010 runtime DLLs
        vs2012       : Set to use with Microsoft Visual Studio 2012 runtime DLLs
        vs2013       : Set to use with Microsoft Visual Studio 2013 runtime DLLs
        vs2015       : Set to use with Microsoft Visual Studio 2015 runtime DLLs
        all          : Set to use TBB statically linked with Microsoft Visual C++ runtime
    if (vs) is not set TBB statically linked with Microsoft Visual C++ runtime will be used.

To set up the environment (Linux* or OS X* systems):

The environment may be set up, for a given type of shell window, by using one of the following commands:
For sh, bash, ksh, dash (or compatibles):
. <installdir>/bin/tbbvars.sh (arch) [platform [TBBROOT_detection_mode]]
For csh (or compatibles):
source <installdir>/bin/tbbvars.csh (arch) [platform [TBBROOT_detection_mode]]
Notes:
  • (arch) argument represents target architecture. Its possible values are 'ia32' or 'intel64'.
  • [platform] argument represents target platform. Its possible values are 'linux' or 'android'.
  • [TBBROOT_detection_mode] argument represents TBBROOT path detection method. Its only possible value is 'auto_tbbroot'. In this case the environment variable TBBROOT is detected automatically by using the tbbvars script directory path.
  • Environment setup need only be performed once per shell window to be used.
  • Always source tbbvars.sh or tbbvars.csh rather than executing them directly.
  • If the arguments to the sourced script are ignored (consult documentation for your shell) the alternative way to specify target is environment variables COMPILERVARS_ARCHITECTURE to pass (arch) to the script and COMPILERVARS_PLATFORM to pass [platform].

  • Up to parent directory

    Copyright © 2005-2016 Intel Corporation. All Rights Reserved.

    Intel is a registered trademark or trademark of Intel Corporation or its subsidiaries in the United States and other countries.

    * Other names and brands may be claimed as the property of others.