Center for High Performance Computing (CHPC)


A (very) Brief Introduction to OpenMP

This tutorial is designed to provide a (very) brief introduction to the OpenMP Application Program Interface (API). In a sentence, OpenMP allows programmers to parallelize their codes on shared memory computers. Users enable parallelism by providing compiler directives in their code. The compiler directives appear as comments unless the compiler is called with special flags in which case the directives allow for the creation of multiple threads which will work on separate "chunks" of the problem. These threads will be executed on different processors, but each thread will have access to the global memory space unless the user specifies otherwise.

OpenMP makes it easy to parallelize an existing single-processor code.  In this tutorial we'll provide code snippets which can be run on our cluster.

Users seeking more detailed information should see: http://openmp.org

A Toy Problem

As an example, we'll consider the 3D scalar wave equation written in Cartesian coordinates.

First, we'll break the second-order equation into two first-order equations

where f and g are the variables that we will actually evolve.
In terms of the evolved the variables, the equations become:


Fortran | C