Intel® Advisor User Guide

ID 766448
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Fix Problems in Code Used by Multiple Parallel Sites

If the Dependencies tool reports a problem(s) in one or more common functions used by multiple parallel sites, you need to investigate and consider several options. In general, keep in mind that the performance impact for privatization is usually less than synchronization, and the performance impact for synchronization is usually less than not adding parallelism. Thus, the general approach is:

  • Evaluate whether it is possible to privatize the data causing the Dependencies problem for both sites. For example, you can often use privatization if the cause is incidental (accidental) sharing. Usually, providing each task with its own private copy of a variable provides the best performance.

  • If you cannot fix the problem by privatizing, consider using synchronization (such as using locks or mutexes). For example, synchronization is often needed if the Dependencies problem is caused by independent updates that have true dependence.

  • In some cases, it may not be feasible to add parallelism to a site. That is, after you to modify the annotations for the parallel site or its tasks and check the Suitability and Dependencies again, you might find a parallel site has negative or minimal performance gain and/or complex data sharing problems. In this case, you may need to remove the site and task annotations and add a comment that states that this code location could not be parallelized.

If you cannot eliminate a Dependencies problem for a common function called by multiple parallel sites by using the approach described above, consider adding a cloned function. That is, one of the parallel sites calls the cloned function and the other parallel site calls the original function. This allows you to implement different fixes to the Dependencies problem(s) for the original function and the cloned function. For example, this approach might allow you to privatize data in either the original function or the cloned function, which was not possible originally.

As with any program, after you modify the code within a parallel site or the annotations, you should run and analyze your program again using the Dependencies and Suitability tools.