## Overview

This directory has example usages of Threading Building Blocks.

## Directories

GettingStarted
  Examples from the Getting Started Guide.
concurrent_hash_map
  Examples using `concurrent_hash_map`.
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_priority
  Examples using the task priority feature.
test_all
  Examples that test all the parts of the package.
common
  Common files for building various examples. Not used directly.

## To Build

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

- Build by using a Microsoft* Visual Studio* project (Windows* systems only).
- Build by using a Xcode* IDE project (Mac OS* X systems only).
- Build by using a Makefile (Windows*, Linux* or Mac OS* X systems).

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 Mac 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* 2005, the *.sln file is in the example's msvs sub-directory. For other versions please use Microsoft* Visual Studio* project converter
   - <example_name>_cl.sln - Solution for Microsoft* Visual C++* compiler
   - <example_name>_icl.sln - Solution for Intel® C++ Compiler
2. Open the project by using one of the following methods:
   - Navigate to the *.sln file from My Computer, by using Windows Explorer, or by using another file browser. Double-click the *.sln file to invoke Microsoft* Visual Studio* and open the project.
   - Invoke Microsoft* Visual Studio* from the Start menu and use the "Open Project" dialog to navigate to and open the project.
3. Press <ctrl-F5> to build and run the example.

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

Perform the following steps:

1. Identify the project (*.xcodeproj) file for the example you wish to build and run.
   - The *.xcodeproj file is in the example's xcode sub-directory.
2. Open the project by using one of the following methods:
   - Navigate to the *.xcodeproj file by using the Finder. Double-click the *.xcodeproj file to invoke the Xcode* IDE and open the project.
   - Invoke the Xcode* IDE and use the "File ⇒ Open…" dialog to navigate to and open the project.
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 Mac 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* (.NET 2003 or 2005); 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 Threading Building Blocks.
   See below for how to set up the environment for Windows*, Linux* or Mac OS* X systems.
3. Unless you installed Threading Building Blocks 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 Mac OS* X systems.
   `make`
     Default build and run. Equivalent to 'make release test'.
   `make release`
     Compile and link against the release version of the Threading Building Blocks library. The resulting executable is left in the directory for the example.
   `make debug`
     Compile and link against the debug version of the Threading Building Blocks 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 Mac OS* X systems).
   `make clean`
     Remove any executables or intermediate files produced by the above commands.

#### To set up the environment (Windows* systems):

It is strongly recommended that the environment be set up when installing Threading Building Blocks. 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>\{ia32,intel64}\{vc8,vc9,vc_mt}\bin\tbbvars.bat`
For sh, bash, ksh (or compatibles):
  `. <installdir>\{ia32,intel64}\{vc8,vc9,vc_mt}\bin\tbbvars.sh`
For csh (or compatibles):
  `source <installdir>\{ia32,intel64}\{vc8,vc9,vc_mt}\bin\tbbvars.csh`
Notes:
  - Choose one of {ia32,intel64} depending on the architecture to be used.
  - 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.
  {vc8,vc9,vc_mt} {vc8,vc9,vc_mt} depending on which Microsoft* Visual Studio*

#### To set up the environment (Linux* or Mac 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 (or compatibles):
  . <installdir>/bin/tbbvars.sh
For csh (or compatibles):
  source <installdir>/bin/tbbvars.csh
For sh, bash, ksh (or compatibles), when using an alternate architecture or platform:
  . <installdir>/{ia32,intel64,ia64}/cc<gccversion>_libc<libcversion>_kernel<kernelversion>/bin/tbbvars.sh
For csh (or compatibles), when using an alternate architecture or platform:
  source <installdir>/{ia32,intel64,ia64}/cc<gccversion>_libc<libcversion>_kernel<kernelversion>/bin/tbbvars.csh
Notes:
  - Choose one of {ia32,intel64,ia64} depending on the architecture to be used.
  - Choose a cc<gccversion>_libc<libcversion>_kernel<kernelversion> value, from among the available platforms installed with Threading Building Blocks (for ia32, intel64 or ia64), depending on the platform to be used.
  - 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.

Up to parent directory

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

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks 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.