How do I compile OpenMP code on the Sun?

Please note: The FAQ pages at the HPCVL website are continuously being revised. Some pages might pertain to an older configuration of the system. Please let us know if you encounter problems or inaccuracies, and we will correct the entries.

To enable the interpretation of OpenMP compiler directives, the -xopenmp compiler option has to be specified both at the compile and at the link level. This holds for the Fortran, C, and C++ compilers equally. At the compile level, it is often useful to also use the -xloopinfo option which creates a list of loops and information on whether they have been parallelized or not. For instance, in the case of a Fortran program, the compiler calls will be, for compiling:

f90 -c -xopenmp -xloopinfo test.f90

and for linking

f90 -o test.exe -xopenmp test.o

Both can of course be combined:

f90 -o test.exe -xopenmp -xloopinfo test.f90

Note that the -xopenmp option is a macro which includes several sub options. Also, if no optimization is specified (as in the above lines), the optimization level will automatically be increased to -xO3 to support multi-threading. This can not be disabled.