ARCHIVED: On Libra, how do I compile an OpenMP program?
Note: UITS will retire Libra in spring 2009. Accounts are available on Quarry, a general-purpose Unix computing environment. For more, see About the Libra retirement.
You can compile OpenMP programs on the SMP nodes of the
Libra Cluster (libra43, libra47,
libra48, libra49, and libra50)
with the -qsmp=omp option using the threaded compiler
mode. For example, you would compile a Fortran 90 program
without a link to the library myprog.f using the
following command:
Here is a sample program, omparallel.f:
Output from this program looks like:
Hello World from thread = 0 Hello World from thread = 1 Hello, world I am 1 and I am working Hello World from thread = 4 Hello, world I am 4 and I am working Hello World from thread = 2 Hello, world I am 2 and I am working Hello World from thread = 3 Hello, world I am 3 and I am working Hello World from thread = 6 Hello, world I am 6 and I am working Hello World from thread = 5 Hello, world I am 5 and I am working Hello, world I am 0 and I am working 7 Is the number of threads in omp_get_num_threadsYou would compile a C program using this command:
xlf90_r -qfixed -qsmp=omp -o omp_test omparallel.cNote: If the program links to any library, usually the library must be thread-safe (i.e., it must guarantee to shared memory processes that use threads an independent function for each thread that makes the call), at least to use OpenMP to perform parallelization.
Also see:
Last modified on June 30, 2009.






