A C++ "Stub" Library for OpenMP

OPENMP_STUBS is a C++ library which constitute a "stub" implementation of the OpenMP 2.5 standard.

A stub library is useful when you want to try out a program on a system that does not have OpenMP, or when you need to have a formally complete program to analyze, or in other cases where you want to ignore the actual OpenMP library. A stub library can also help to understand the structure of the actual library.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


OPENMP_STUBS is available in a C version and a C++ version and a FORTRAN90 version.

Related Data and Programs:

DIJKSTRA_OPENMP, a C++ program which uses OpenMP to parallelize a simple example of Dijkstra's minimum distance algorithm for graphs.

FFT_OPENMP, a C++ program which demonstrates the computation of a Fast Fourier Transform in parallel, using OpenMP.

HEATED_PLATE_OPENMP, a C++ program which solves the steady (time independent) heat equation in a 2D rectangular region, using OpenMP to run in parallel.

HELLO_OPENMP, a C++ program which prints out "Hello, world!" using the OpenMP parallel programming environment.

MD_OPENMP, a C++ program which carries out a molecular dynamics simulation using OpenMP.

MULTITASK_OPENMP, a C++ program which demonstrates how to "multitask", that is, to execute several unrelated and distinct tasks simultaneously, using OpenMP for parallel execution.

MXM_OPENMP, a C++ program which computes a dense matrix product C=A*B, using OpenMP for parallel execution.

OPENMP, C++ programs which illustrate the use of OpenMP directives and function calls to solve problems in parallel.

PRIME_OPENMP, a C++ program which counts the number of primes between 1 and N, using OpenMP for parallel execution.

QUAD_OPENMP, a C++ program which approximates an integral using a quadrature rule, and carries out the computation in parallel using OpenMP.

SATISFY_OPENMP, a C++ program which demonstrates, for a particular circuit, an exhaustive search for solutions of the circuit satisfiability problem, using OpenMP for parallel execution.

SCHEDULE_OPENMP, a C++ program which demonstrates the default, static, and dynamic methods of "scheduling" loop iterations in OpenMP to avoid work imbalance.

SGEFA_OPENMP, a C++ program which reimplements the SGEFA/SGESL linear algebra routines from LINPACK for use with OpenMP.

ZIGGURAT_OPENMP, a C++ program which demonstrates how the ZIGGURAT library can be used to generate random numbers in an OpenMP parallel program.


  1. Rohit Chandra, Leonardo Dagum, Dave Kohr, Dror Maydan, Jeff McDonald, Ramesh Menon,
    Parallel Programming in OpenMP,
    Morgan Kaufmann, 2001,
    ISBN: 1-55860-671-8,
    LC: QA76.642.P32.
  2. Barbara Chapman, Gabriele Jost, Ruud vanderPas, David Kuck,
    Using OpenMP: Portable Shared Memory Parallel Processing,
    MIT Press, 2007,
    ISBN13: 978-0262533027.
  3. The OpenMP web site
  4. OpenMP Architecture Review Board,
    OpenMP Application Program Interface,
    Version 3.0,
    May 2008.

Source Code:

Examples and Tests:

Note that these examples are normally run in parallel with OpenMP. The point being made here is that such programs can be run sequentially, as though OpenMP were available, by calling the OPENMP_STUBS library. They don't run well (fast) - it's just remarkable that they run at all.

COMPUTE_PI shows how information can be shared. Several processors need to compute pieces of a sum that will approximate pi.

HELLO is a very simple program which calls an OpenMP subroutine to set the number of threads, and then has each thread say hello;

HELMHOLTZ is a program that solves the Helmholtz equation on a rectangular grid, using Jacobi iteration with overrelaxation;

List of Routines:

Again, please don't be confused. These routines have the same names as the real OpenMP library; they just don't do anything. Well, not much, anyway. They do just enough to let a program run in sequential mode.

You can go up one level to the C++ source codes.

Last revised on 20 November 2007.