How to Use the OMPi OpenMP Compiler

Professor Norm Matloff
University of California, Davis

What is it?

OMPi is a C (not C++ compiler for OpenMP. I find that it is easier to install, and the authors' research indicates that it produces faster code than does the Omni compiler.

Where to obtain it:

Go to the OMPi home page.

How to install it:

Unpack the source code in some directory, and choose an installation directory (or take the default, /usr/local/), say for example /a/b/. Then do

configure --prefix=/a/b/c
make
make install

Then make sure to add the bin subdirectory of your installation directory to your search path in your shell startup file, before you do anything else, as ompicc will invoke ompi, which needs to be in your path.

How to compile OMPi OpenMP programs:

To compile a C program x.c, with the resulting executable being named x, type

ompicc -g -o x x.c

How to run OMPi OpenMP programs:

To set the number of threads, say to 4, type (e.g. for the C shell)

setenv OMP_NUM_THREADS 4

Then just run the executable produced from your compilation step.

How to debug OMPi OpenMP programs:

You may find that it is easier to debug using the Omni compiler, as the executable's symbol table to a large extent uses your original source file, without the extras which the compiler inserts.

During preprocessing of your file x.c the compiler produces a file x_ompi.c, and the latter is what is actually compiled. Your function main() is renamed to _ompi_originalMain(). Your other functions and variables are not renamed, but your line numbers change. Keep this in mind as you navigate through your code in your debugging tool. It is advisable to use the -k option when compiling, as this saves the file x_ompi.c, enabling the determination of the new line numbers.

Also see my material on the Omni compiler for tips on debugging OpenMP programs.