Analyze Memory Access Patterns

Intel Advisor offers Vectorization Advisor, a vectorization optimization tool, and Threading Advisor, a threading design and prototyping tool, to help ensure your Fortran, C and C++ applications realize full performance potential on modern processors, such as Intel® Xeon Phi™ processors. This topic is part of a tutorial that shows how to use the Vectorization Advisor on a Windows* platform to add efficient SIMD parallelism to a C++ sample application.

Use a MAP-focused Refinement Report to check for various memory issues, such as non-contiguous memory accesses and unit stride vs. non-unit stride accesses. Your objective: Eliminate issues that could lead to significant vector code execution slowdown or block automatic vectorization by the compiler.

To identify and explore data structure layout in memory, do the following.

Run a Memory Access Patterns Analysis

  1. In the column in the Survey Report, select the checkbox for the loop in:

    • matvec at Multiply.c:69

    • matvec at Multiply.c:60

  2. Notice the loop in matvec at Multiply.c:60 has a better Efficiency and Gain Estimate than the loop in matvec at Multiply.c:69.

  3. In the Vectorization Workflow pane, click the Intel Advisor control: Run MAP analysis control under Check Memory Access Patterns to produce a Memory Access Patterns Report.

    If analysis time during this exercise is a consideration: After the site coverage progress bar shows 4/4 sites executed, click the Intel Advisor control: Stop analysis and display result collected thus far control under Check Memory Access Patterns to stop the current analysis and display the result collected thus far.

  4. Click the Intel Advisor control: Snapshot icon and save a snapshot_map result.

Assess Memory Issues

  1. In the top pane of the Refinement Reports window, hover your mouse over the Strides Distribution values to display explanatory tooltips for the loops matvec at Multiply.c:69 and matvec at Multiply.c:60. In the loop in matvec at Multiply.c:60, the percentage of memory instructions with stride 1 (unit stride) or stride 0 (uniform) accesses is 100%, which contributes to the better Efficiency and Gain Estimate.
    Intel Advisor: Memory Access Patterns Report

  2. Return to the Survey Report. Notice the content in Survey Report has also changed: In the Performance Issues column, the Intel Advisor reports Inefficient memory patterns present for the loop in matvec at Multiply.c:69. Click the Intel Advisor control: Recommendations icon in the Performance Issues column to display the associated recommendations in the bottom pane.

  3. Check the changes in the new Summary.

We will not fix the cause of this issue (the code is indexing the row of array a by l) in this tutorial. (In C/C++ applications, access the column index by the innermost loop; in this case, you could modify the code to access array a as follows: a[i][l].)

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