Tutorial

  • 12/04/2020
  • Public Content

Building the Intel® Threading Building Blocks Version

To build the Intel® Threading Building Blocks (Intel® TBB) version, you will modify the sample application to use Intel® TBB and then compile the modified code. You will then start the application and then compare the time with the baseline performance time.
  1. Set the
    build_with_tbb
    project as the startup project.
  2. For project
    build_with_tbb
    , change the compiler to the Intel® C++ Compiler (
    Project > Intel Compiler > Use Intel C++
    ).
  3. For the project
    build_with_tbb
    click
    Project > Properties > Intel Performance Libraries > Intel® Threading Building Blocks > Use Intel® TBB (Yes)
    to set the Intel® TBB environment variables. The environment variables that are set is defined in Notes section.
  4. Open the source file
    tachyon.tbb.cpp
    in the project
    build_with_tbb
    .
  5. Remove the comment marks for the Intel® TBB headers to declare the Intel® TBB functions that will be used in the sample application as given below.
    #include <tbb/tbb.h>
  6. Make the following changes in the
    parallel_thread
    function.
    • Convert the serial function with a loop that is to be parallelized to a function object that Intel® TBB algorithms (in this case
      parallel for
      will use. The function body needs to be moved into a C++11 lambda function passed to the Intel® TBB
      parallel for
      .
    • Move the iteration-independent value of
      mboxsize
      out of the loop.
    • Remove the validity check of
      video->next_frame
      .
      • Exiting a loop in the middle of a parallelized loop is not permitted.
    • Check against the complete change shown in
      tachyon.tbb_solution.cpp
      .
  7. Build
    build_with_tbb
    in release configuration.
The makefile automatically runs the sample after it is built.
Compare the time to render the image to the baseline performance time.
  • If Microsoft* Visual Studio cannot find the Intel® TBB header files, click
    Project > Properties > Configuration Properties > C/C++ > General > Additional Include Directories
    and add a path to the
    <install-dir>
    \tbb\include
    .
  • If Microsoft* Visual Studio cannot find the Intel® TBB libraries at link time, click
    Project > Properties > Configuration Properties > Linker > General > Additional Library Directories
    and add a path to the
    <install-dir>
    \redist\tbb\vc_mt

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.