OpenMP @ HPC
OpenMP (Open specifications for MultiProcessing) is an API which supports programming on shared-memory multiprocessors, mostly in C/C++ and Fortran. It has a simple and accommodating because of its portable, scalable programming model. Its three basic API elements are compiler directives, environment variables, and runtime library routines. The programming model is explicit and thread-based, mostly specified through compiler directives. It does allow nested parallelism and dynamic threading although various implementations may not support this feature.
At HPC, OpenMP is supported by the PGI compilers on Los Lobos and Azul. For C/C++ programs, use the PGCC compiler and the -mp (implies -Mreentrant) option. For example,
pgcc -mp foo.c -o foo
Make sure you have the compiler directive #include <omp.h>, which allows you to use OpenMP functions. For FORTRAN, use the PGF77/PGF90 compiler again with the -mp option.
pgf77 -mp foo.f or pgf90 -mp foo.f
Also, before running the program, you may have to set the environment variable (if its not specified within your code) that holds the number of threads allowed on a system by running
setenv OMP_NUM_THREADS <#> or setenv OMP_DYNAMIC
The <#> is the number of threads to be used during execution of a program, the maximum being the number of CPUs on each system. For LosLobos, it can be at maximum 2 while on Azul it can be up to 4. The default for each system is only to use the head/master node so be careful.
For more information on using OpenMP, you can take a look at the PGI User's Guide. To learn how to use OpenMP, this is a good tutorial with understandable examples.