Prototype Threading Designs

This section shows how to get started using the Threading Advisor. The main advantage of using this multi-analysis Threading Advisor workflow is the potential for what-if modeling with corresponding prediction of data sharing issues. The main disadvantage is medium to high runtime overhead.

Intel Advisor Typical Workflow: Prototype Threading Designs

Survey analysis - Shows the loops and functions where your application spends the most time. Use this information to discover candidates for parallelization with threads.

Annotations - Annotations are subroutine calls or macros (depending on the programming language) you insert to mark places in your application that are good candidates for later replacement with parallel framework code that enables threading parallel execution. Annotations can be processed by your current compiler but do not change the computations of your application.

Suitability analysis - Predicts the maximum speedup of your application based on the inserted annotations and a variety of what-if modeling parameters with which you can experiment. Use this information to choose the best candidates for parallelization with threads.

Dependencies analysis - Predicts parallel data sharing problems based on the inserted annotations. Use this information to fix the data sharing problems if the predicted maximum speedup benefit justifies the effort.

Set Up Environment

Environment

Set-Up Tasks

Intel® Parallel Studio XE/Linux* OS

  • Do one of the following:

    • Run one of the following source commands:

      • For csh/tcsh users: source <advisor-install-dir>/advixe-vars.csh

      • For bash users: source <advisor-install-dir>/advixe-vars.sh

      The default installation path, <advisor-install-dir>, is below:

      • /opt/intel/ for root users

      • $HOME/intel/ for non-root users

    • Add <advisor-install-dir>/bin32 or <advisor-install-dir>/bin64 to your path.

    • Run the <parallel-studio-install-dir>/psxevars.csh or <parallel-studio-install-dir>/psxevars.sh command. The default installation path, <parallel-studio-install-dir>, is below:

      • /opt/intel/ for root users

      • $HOME/intel/ for non-root users

  • Set the VISUAL or EDITOR environment variable to identify the external editor to launch when you double-click a line in an Intel Advisor source window. (VISUAL takes precedence over EDITOR.)

  • Set the BROWSER environment variable to identify the installed browser to display Intel Advisor documentation.

  • If you are using Intel® Threading Building Blocks (Intel® TBB), set the TBBROOT environment variable so your compiler can locate the installed Intel TBB include directory.

  • Make sure you run your application in the same Linux* OS environment as the Intel Advisor.

Intel Parallel Studio XE/Windows* OS

Note

Setting up the Windows* OS environment is necessary only if you plan to use the advixe-cl command to run the command line interface, or choose to use the advixe-gui command to launch the Intel Advisor standalone GUI instead of using available GUI or IDE launch options.

Do one of the following:

  • Run the <advisor-install-dir>\advixe-vars.bat command.

    The default installation path, <advisor-install-dir>, is below C:\Program Files (x86)\IntelSWTools\ (on certain systems, instead of Program Files (x86), the directory name is Program Files ).

  • Run the <parallel-studio-install-dir>\psxevars.bat command.

    The default installation path, <parallel-studio-install-dir>, is below C:\Program Files (x86)\IntelSWTools\.

Intel® System Studio

Note

Setting up the environment is necessary only if you plan to use the advixe-cl command to run the command line interface, or choose to use the advixe-gui command to launch the Intel Advisor standalone GUI instead of using available GUI or IDE launch options.

Run the <advisor-install-dir>\advixe-vars.bat command to set up your environment. The default installation path, <advisor-install-dir>, is below C:\Program Files (x86)\IntelSWTools\ (on certain systems, instead of Program Files (x86), the directory name is Program Files ).

Launch Intel Advisor and Create a Project

To launch the:

  • Intel Parallel Studio XE/Intel Advisor standalone GUI:

    • In the Linux* OS: Run the advixe-gui command.

    • In the Windows* OS: From the Microsoft Windows* All Apps screen, select Intel Parallel Studio XE 201n > Intel Advisor 201n

  • Intel System Studio/Intel Advisor standalone GUI: Choose Tools > Intel Advisor > Launch Intel Advisor from the IDE menu.

  • Intel Advisor plug-in to the Visual Studio* IDE: Open your solution in the Visual Studio* IDE.

To create an Intel Advisor project:

  1. Do one of the following

    • In the standalone GUI: Choose File > New > Project… to open the Create a Project dialog box. Supply a name and location for your project, then click the Create Project button to open the Project Properties dialog box.

    • In the Visual Studio* IDE: Choose Project > Intel Advisor 201n Project Properties... to open the Project Properties dialog box.

  2. On the left side of the Analysis Target tab, ensure the Survey Hotspots Analysis type is selected and set appropriate parameters.

  3. Set appropriate parameters for other analysis types and tabs. (Setting the binary/symbol search and source search directories is required for the Threading Advisor.)

Tip

  • If possible, use the Inherit settings from Survey Hotspots Analysis Type checkbox for other analysis types.

  • The Dependencies Analysis type consumes more resources than the Survey Hotspots Analysis type. If this analysis takes too long, consider decreasing the workload.

  • Select Track stack variables in the Dependencies Analysis type to detect all possible dependencies.

Run Survey Analysis

Intel Advisor Threading Workflow Tab: Survey Target

Under Survey Target in the Threading Workflow, click the Intel Advisor control: Run analysis control to collect Survey data while your application executes. Use the resulting information to discover candidates for parallelization with threads.

Note

If the Workflow is not displayed in the Visual Studio IDE: Click the Intel Advisor toolbar icon icon on the Intel Advisor toolbar.

Investigate Loops

Pay particular attention to the hottest loops in terms of Self Time and Total Time. Optimizing these loops provides the most benefit. Outermost loops with significant Total Time are often good candidates for parallelization with threads. Innermost loops and loops near innermost loops are often good candidates for vectorization.

Annotate Sources

Insert annotations to mark places in parts of your application that are good candidates for later replacement with parallel framework code that enables parallel execution.

The main types of Intel Advisor annotations mark the location of:

  • A parallel site. A parallel site is a region of code that contains one or more tasks that may execute in one or more parallel threads to distribute work. An effective parallel site typically contains a hotspot that consumes application execution time. To distribute these frequently executed instructions to different tasks that can run at the same time, the best parallel site is not usually located at the hotspot, but higher in the call tree.

  • One or more parallel tasks within a parallel site. A task is a portion of time-consuming code with data that can be executed in one or more parallel threads to distribute work.

  • Locking synchronization, where mutual exclusion of data access must occur in the parallel application.

The Intel Advisor User Guide offers sample annotated source code you can copy into your editor include:

Annotation Code Snippet

Purpose

Iteration Loop, Single Task

Create a simple loop structure, where the task code includes the entire loop body. This common task structure is useful when only a single task is needed within a parallel site.

Loop, One or More Tasks

Create loops where the task code does not include all of the loop body, or complex loops or code that requires specific task begin-end boundaries, including multiple task end annotations. This structure is also useful when multiple tasks are needed within a parallel site.

Function, One or More Tasks

Create code that calls multiple tasks within a parallel site.

Pause/Resume Collection

Temporarily pause data collection and later resume it, so you can skip uninteresting parts of application execution to minimize collected data and speed up analysis of large applications. Add these annotations outside a parallel site.

Build Settings

Set build (compiler and linker) settings specific to the language in use.

After inserting annotations, rebuild your application in release mode.

Tip

Choosing where to add task annotations may require some experimentation. If your parallel site has nested loops and the computation time used by the innermost loop is small, consider adding task annotations around the next outermost loop.

Run Suitability Analysis

Under Check Suitability in the Threading Workflow, click the Intel Advisor control: Run analysis control to collect Suitability data while your application executes.

The Suitability Report predicts maximum speedup based on the inserted annotations and what-if modeling parameters with which you can experiment, such as:

  • Different hardware configurations and parallel frameworks

  • Different trip counts and instance durations

  • Any plans to address parallel overhead, lock contention, or task chunking when you implement your parallel framework code

Use the resulting information to choose the best candidates for parallelization with threads.

Run Dependencies Analysis

Under Check Dependencies in the Threading Workflow, click the Intel Advisor control: Run analysis control to collect Dependencies data while your application executes. Use the resulting information to fix the data sharing problems if the predicted maximum speedup benefit justifies the effort.

Improve App Performance

If you decide the predicted maximum speedup benefit is worth the effort to add threading parallelism to your application:

  1. Complete developer/architect design and code reviews about the proposed parallel changes.

  2. Choose one parallel programming framework (threading model) for your application, such as Intel® Threading Building Blocks (Intel® TBB), OpenMP*, Microsoft Task Parallel Library* (TPL), or some other parallel framework.

  3. Add the parallel framework to your build environment.

  4. Add parallel framework code to synchronize access to the shared data resources, such as Intel TBB or OpenMP* locks.

  5. Add parallel framework code to create parallel tasks.

As you add the appropriate parallel code from the chosen parallel framework, you can keep, comment out, or replace the Intel Advisor annotations.

For more complete information about compiler optimizations, see our Optimization Notice.