SCDzine
Spring 1999, Vol. 20, No. 1
N E W S

What you should know about OpenMP

Simple interface for parallel applications is available on SCD Origin and Cray computers . . .

Tom Parker
Tom Parker


Contents

SCDzine

Search

Article index

Subscribe

Contact us

SCD

by Tom Parker

OpenMP is an industry-wide standard for directive-based parallel programming. It gives shared-memory parallel programmers a simple and flexible interface for developing parallel applications.

Jointly defined by a group of major computer hardware and software vendors, the OpenMP API (Application Program Interface) supports multiplatform, shared-memory, parallel programming in C/C++ and Fortran on all architectures, including Unix platforms and Windows NT platforms.


How does OpenMP compare with other interfaces?

  • Message Passing Interface (MPI)

    Message passing has become accepted as a portable style of parallel programming, but has several significant weaknesses that limit its effectiveness and scalability.

    Message passing in general is difficult to program and doesn't support incremental parallelization of an existing sequential program. Message passing was initially defined for client/server applications running across a network, and so includes costly semantics (including message queuing and selection and the assumption of wholly separate memories) that are often not required by tightly-coded scientific applications running on modern scalable systems with globally addressable and cache coherent distributed memories.

  • High-Performance Fortran (HPF)

    HPF has never really gained wide acceptance among parallel application developers or hardware vendors. Some applications written in HPF perform well, but others find that limitations resulting from the HPF language itself or the compiler implementations lead to disappointing performance. HPF's focus on data parallelism has also limited its appeal.

  • Pthreads

    Pthreads have never been targeted toward the technical and high-performance computing market. This is reflected in the minimal Fortran support and in the lack of support for data parallelism. Even for C applications, pthreads requires programming at a level lower than most technical developers would prefer.

  • FORALL loops
  • FORALL loops are not rich or general enough to use as a complete parallel programming model. Their focus on loops and the rule that subroutines called by those loops can't have side effects effectively limit their scalability. FORALL loops are useful for providing information to automatic parallelizing compilers and preprocessors.

  • BSP, LINDA, SISAL and others
  • There are many parallel programming languages being researched or prototyped in the industry. These may be targeted towards a specific architecture, or focused on exploring one key requirement.


A simple example of how to use OpenMP

This example shows how to parallelize a simple loop in Fortran 90. The loop iteration variable (I) is private by default, so it is not necessary to declare it explicitly.

     !$OMP PARALLEL DO
           DO I=1,N
              B(I) = (A(I) + A(I-1)) / 2.0
           ENDDO
     !$OMP END PARALLEL DO

The END PARALLEL DO directive is optional.


Bonus tip

Here's an easy way to think about which variables are local and which are shared.

Pretend that you replace the entire DO loop with a call to a subroutine. The arguments you would place in the calling sequence are the shared variables.


Availability on SCD computers

OpenMP is available on these SCD systems:


For more information

A good source for information about OpenMP is the OpenMP website, which includes an FAQ and complete specifications (i.e., documentation).

rule
Contents || SCDzine || Search || Article index || Subscribe || Contact us || SCD