Pattern Name: DataSharing

FindingConcurrency Design Space


Intent:

This pattern addresses the question "Given a way of decomposing a problem into tasks, how is data shared among the tasks?"

Motivation:

This pattern constitutes the third step in analyzing dependencies among the tasks of a problem decomposition. The first and second steps, addressed in the GroupTasks and OrderTasks patterns, are to group tasks based on constraints among them and then determine what ordering constraints apply to groups of tasks. The next step, discussed here, is to analyze how data is shared among groups of tasks, so that access to shared data can be managed correctly.

The first two steps of the dependency analysis have focused on how the original problem's computation was divided into tasks (the task decomposition). This step also takes into consideration the associated data decomposition, that is, the division of the problem's data into chunks that can be updated independently, each associated with one or more tasks that handle the update of that chunk. This chunk of data is sometimes called "task-local" data (or just "local" data), since it is tightly coupled to the task(s) responsible for its update.

It is rare, however, that each task can operate using only its own local data; data may need to be shared among tasks in many ways. Two of the most common situations are the following:

This pattern discusses data sharing in parallel algorithms and how to deal with typical forms of shared data.

Applicability:

Use this pattern when

Implementation:

The goal of this pattern is to identify what data is shared among groups of tasks and how to manage access to shared data in a way that is both correct and efficient.

Data sharing can have major implications for both the correctness and the efficiency of your program:

The goal, therefore, is to manage shared data enough to ensure correctness but not so much as to interfere with efficiency. We suggest the following approach to determining what data is shared and how to manage it:

Examples:

Molecular dynamics.

In the Examples section of the DependencyAnalysis pattern we described the problem of designing a parallel molecular dynamics program. We then identified the task groups (in the GroupTasks pattern) and considered temporal constraints between the task groups (in the OrderTasks pattern). We will ignore the temporal constraints for now and just focus on data sharing for the problem's final task groups:

When you analyze the computations taking place with each of these groups, you find the following shared data: