OPENMP_STUBS
A C++ "Stub" Library for OpenMP {#openmp_stubs-a-c-stub-library-for-openmp align="center"}
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 FORTRAN77 version and a FORTRAN90 version.
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.
- 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. - Barbara Chapman, Gabriele Jost, Ruud vanderPas, David Kuck,
Using OpenMP: Portable Shared Memory Parallel Processing,
MIT Press, 2007,
ISBN13: 978-0262533027. - The OpenMP web site
- OpenMP Architecture Review Board,
OpenMP Application Program Interface,
Version 3.0,
May 2008.
- openmp_stubs.cpp, the source code.
- openmp_stubs.hpp, a simple "include" file that declares the type of the functions that are part of the library. An OpenMP code will probably be looking for a file called "omp.h" instead.
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.
- compute_pi.cpp, the source code;
- compute_pi_output.txt, the output file;
HELLO is a very simple program which calls an OpenMP subroutine to set the number of threads, and then has each thread say hello;
- hello.cpp, the source code;
- hello_output.txt, the output file;
HELMHOLTZ is a program that solves the Helmholtz equation on a rectangular grid, using Jacobi iteration with overrelaxation;
- helmholtz.cpp, the source code;
- helmholtz_output.txt, the output file;
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.
- OMP_DESTROY_LOCK destroys a simple lock.
- OMP_DESTROY_NEST_LOCK destroys a nestable lock.
- OMP_GET_DYNAMIC reports if dynamic adjustment of thread number is allowed.
- OMP_GET_MAX_THREADS returns the default number of threads.
- OMP_GET_NESTED reports if nested parallelism has been enabled.
- OMP_GET_NUM_PROCS returns the number of processors available to the program.
- OMP_GET_NUM_THREADS returns the number of threads in the current team.
- OMP_GET_THREAD_NUM returns the thread number of a thread in a team.
- OMP_GET_WTICK returns the precision of the timer used by OMP_GET_WTIME.
- OMP_GET_WTIME returns elapsed wall clock time in seconds.
- OMP_IN_PARALLEL returns TRUE if the call is made from a parallel region.
- OMP_INIT_LOCK initializes a simple lock.
- OMP_INIT_NEST_LOCK initializes a nestable lock.
- OMP_SET_DYNAMIC enables dynamic adjustment of the number of threads.
- OMP_SET_LOCK sets a simple lock.
- OMP_SET_NEST_LOCK sets a nestable lock.
- OMP_SET_NESTED controls the use of nested parallelism.
- OMP_SET_NUM_THREADS sets the number of threads.
- OMP_TEST_LOCK tests a simple lock.
- OMP_TEST_NEST_LOCK tests a nestable lock.
- OMP_UNSET_LOCK unsets a simple lock.
- OMP_UNSET_NEST_LOCK unsets a nestable lock.
You can go up one level to the C++ source codes.
Last revised on 20 November 2007.