Memory Management

Christopher Cameron, Steve Lantz, Peter Vaillancourt, CAC Staff (original)
Cornell Center for Advanced Computing

Revisions: 6/2022, 3/2021, 2/2017 (original)

Since OpenMP enables shared memory parallelism, it supports a straightforward system to declare and share variables among threads automatically. It also supports more fine-grained control, where variables can be private to individual threads. As a convenience to programmers, some types of variables are always private. This topic explains which variables are automatically shared, which are automatically private, how to create private variables and how to synchronize variable values between threads.

Objectives

After you complete this segment, you should be able to:

  • Explain the concept of shared memory programming
  • List the sharing rules for variables
  • Demonstrate using the threadprivate directive
  • Explain the use of control directives
  • Describe the weak-ordering model of memory consistency
  • Explain the importance of avoiding the race condition
Prerequisites
  • A working knowledge of general programming concepts
  • A working knowledge of Linux; otherwise, try working through the Linux topic first
  • Ability to program in a high-level language such as Fortran or C
  • A basic familiarity with parallel programming concepts
 
©   Cornell University  |  Center for Advanced Computing  |  Copyright Statement  |  Inclusivity Statement