Reducing Task Overhead

Task overhead is the time spent creating a task and getting it assigned to a thread, and also the time spent stopping or pausing the thread when the task is complete.

Task overhead is proportional to the number of times a task is executed. If you have a task that is executed too frequently or where the average time per task instance is too small, modify your task so it encloses a larger amount of computation. Alternatively, consider using the task chunking feature, which is supported by several parallel frameworks. In this case, the parallel framework groups multiple task executions at run-time.

If the Suitability tool recommends that you reduce task overhead, the parallel task is probably too small. Often this is because you have chosen an inner loop in a leaf function as the location of your parallel site, where you instead should have chosen a function farther up the call tree.

There are two ways to reduce task overhead:

  • Restructure your program to reduce the number of tasks you create. For example, restructure your task annotations and/or code to increase the amount of work that occurs during each task's execution.

  • If available for the selected parallel framework, enable the task chunking feature.

You can reduce task overhead by combining multiple task executions into a single task execution. For example, by merging two tasks into one.

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