How to Implement Task Parallelism with Intel® Advisor

ID 659551
Updated 9/5/2018
Version Latest



There are many different ways to add parallelism to an application. One of the most popular techniques is to parallelize the iterations of a loop, which is sometimes referred to as Data Parallelism. This method is thoroughly covered in the Intel® Advisor documentation, but it is not the only type of parallelism that can be added with the help of Intel Advisor. Task Parallelism, sometimes referred to as function parallelism, in which multiple tasks/functions run in parallel can also be modeled by Advisor. Figure 1 shows a code snippet representing some basic statistical analysis:

Figure 1

This code is used to determine a running average and a running standard deviation on an array of values. Figure 2 shows the Survey Report created by Intel Advisor.


Figure 2

This report shows that the majority of the time is being spent in two loops, one in the runningStdDev function and the other in the runningAvg function. If the source code was available for these functions, these loops would be good targets for Advisor annotations. However, it could be the case that these functions are in library code for which the source is not available. In this case, Intel Advisor annotations can be used to model running both of these functions in parallel. Figure 3 shows how this would be done.


Figure 3

The suitability analysis of this parallel experiment is shown in Figure 4.


Figure 4

Figure 4 shows that there is substantial speedup available from running these two functions in parallel. It also shows that the speedup does not scale beyond two cores. This is understandable because there are only two tasks that will be executing at the same time.

While task parallelism may not be the most scalable form of parallelism, it can still add substantial performance improvements and may be available when data parallelism is not. Intel Advisor annotations can be used to model task parallelism in an application in addition to data parallelism. The next step is to model Correctness with Intel Advisor to make sure that no conflicts will arise from running both of these functions in parallel.