Parallel Programming in OpenMP

Chapter 5: Synchronization

5.1 Introduction

Shared memory architectures enable implicit communication between threads through references to variables in the globally shared memory. Just as in a regular uniprocessor program, multiple threads in an OpenMP program can communicate through regular read/write operations on variables in the shared address space. The underlying shared memory architecture is responsible for transparently managing all such communication and maintaining a coherent view of memory across all the processors.

Although communication in an OpenMP program is implicit, it is usually necessary to coordinate the access to shared variables by multiple threads to ensure correct execution. This chapter describes the synchronization constructs of OpenMP in detail. It introduces the various kinds of data conflicts that arise in a parallel program and describes how to write a correct OpenMP program in the presence of such data conflicts.

We first motivate the need for synchronization in shared memory parallel programs in Section 5.2. We then present the OpenMP synchronization constructs for mutual exclusion including critical sections, the atomic directive, and the runtime library lock routines, all in Section 5.3. Next we present the synchronization constructs for event synchronization such as barriers and ordered sections in Section 5.4. Finally we describe some of the issues that arise when building custom synchronization using shared memory variables, and how those are addressed in OpenMP, in Section 5.5.

5.2 Data Conflicts and the Need for Synchronization

OpenMP provides a shared memory programming model, with communication between multiple threads trivially expressed through regular read/ write operations on variables.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Network Synchronization Products
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.