Examine Potential Correctness Problems

Examine your program to predict likely data sharing problems by using the Correctness tool. Because the Correctness tool watches multiple memory locations as your program executes, you need to minimize the input data set. To do this:

Build a Target for the Correctness Tool

This step was completed previously, using a debug build that includes debug information and no optimization. See the Intel Advisor GUI.

Reduce the Input Data Set

When you run the Correctness tool, it executes the target executable against the supplied data set. If you supplied a full data set for the Correctness tool, this would require a run time of 50 to several hundred times longer than the normal execution time of the target executable. So, for the next example, you should reduce the data set by using the project's properties or by modifying the source code. You may have noticed that the main() entry point accepts command arguments and we specify the arguments without requiring a rebuild. The default board size is 14, but you can specify a value of 8:

When using the Intel Advisor GUI, select Project Properties and specify:

  • Target type of Correctness Analysis

  • Application of .../nqueens/2_nqueens_annotated_debug

  • Application parameters of 8

Specify Project properties for the Correctness tool

On the command line, add the number 8 after the command name that runs the program. For example, type:

  • ./2_nqueens_annotated_debug 8

Run the Correctness Tool

To run the Intel Advisor Correctness tool, do one of the following:

  • Click the Start the Correctness toolCollect Correctness Data button on the side command toolbar. To hide or show the command toolbar, click the Hide side command toolbar or Show side command toolbar buttons in the upper-right of the Correctness Report.

  • Click the Start the Correctness toolCollect Correctness Data button in Advisor XE Workflow tab (below 4. Check Correctness).

  • In the Intel Advisor GUI, choose File > New > Start Correctness Analysis.

The Correctness tool runs with your program to collect data and analyze its run-time characteristics. A command window appears and displays text similar to the following when the nqueens program completes (the time used will be different on your system):

Starting serial recursive solver for size 8
Number of solutions: 92
Calculations took 528ms.
Correct Result!

The Correctness Report window's command toolbar appears while data is being collected or if there is no Correctness Report data for the project.

After the Correctness tool finishes collecting and finalizing the data, the following appears in the result tab's Correctness Report window:

Correctness Report window

The Correctness Report window is the starting point for viewing potential parallel problems.

The Problems and Messages pane shows the observed problems. In this case, there are two problems and one informational message, whose names are listed under the Type column.

For the currently selected Problem or Message, details appear in the Code Locations pane (lower-left corner). In this case, details appear for the Data Communication problem.

The Filter pane provides a summary of the problems. It also lets you toggle between displaying a subset of the problems found or all problems.

View Correctness Report and Correctness Source Output

The Problems and Messages pane lists the data sharing problems found. The column with the icon lists the severity of each problem, such as error , warning , or informational remark message . Click a line under the Problems and Messages column and the code locations associated with that problem or message appear in the Code Locations pane.

To further interpret the result data, do one of the following:

  • Click the or icon next to one of the Code Locations to view or hide a few lines of its source code snippet, such as to hide X3:

    Correctness Report Code Locations pane

  • Double-click one of the Code Locations (or right-click and select View Source), such as X4. This opens the Correctness Source window, which lets you view source for the Focus Code Location (red icon), Related Code Location (blue icon), their call stacks, a list of all Code Locations, and a diagram of Code Location Relationships.

    Correctness Source window

Key Terms

data race

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