Pattern Name: OrderTasks

FindingConcurrency Design Space


Intent:

This pattern addresses the question "Given a way of decomposing a problem into tasks and a way of collecting these tasks into logically related groups, how must these groups of tasks be ordered to satisfy constraints among tasks?"

Motivation:

This pattern constitutes the second step in analyzing dependencies among the tasks of a problem decomposition. The first step, addressed in the GroupTasks pattern, is to group tasks based on constraints among them. The next step, discussed here, is to help the designer find and correctly account for dependencies resulting from constraints on the order of execution of a collection of tasks.

Constraints among tasks fall into a few major categories (described in more detail in the GroupTasks pattern):

The purpose of this design pattern is to help the designer find and correctly account for dependencies resulting from constraints on the order of execution of a collection of tasks.

Applicability:

Use this pattern when

Implementation:

The goal of this pattern is to identify ordering constraints among groups of tasks and use them to define a partial ordering among task groups. There are two goals to be met in defining this ordering:

To identify ordering constraints, consider the following ways tasks can depend on each other:

Regardless of the source of the constraint, your task as a designer is the same. You must define the constraints that restrict the order of execution, and make sure they are handled correctly in the resulting algorithm. At the same time, you should note when ordering constraints are absent, since this will give you valuable flexibility later in your design.

Examples:

Molecular dynamics.

In the Examples section of the DependencyAnalysis pattern we described the problem of designing a parallel molecular dynamics program. In the GroupTasks pattern, we further described how to organize the tasks in the following groups:

Now we are ready to consider ordering constraints between the groups. Clearly, the update of the atomic positions cannot occur until the force computation is complete. Also, the long-range forces cannot be computed until the neighbor list is updated. So in each time step, the groups must be ordered as shown below FIX THIS.

While it is too early in the design to consider in detail how these ordering constraints will be enforced, eventually we will need to provide some sort of synchronization primitive to ensure that they are strictly followed.