The default version of PGI compilers on Louhi is 7.0.5, but there is also the older version 6.2.5 (see module avail).
PGCC supports ANSI C99 (ANSI/ISO 9899-1999) in addition to ANSI C (ANSI/ISO 9899-1990). The options -c9x and -c99 are for C99 code. PGCC supports also K&R C. PGC++ supports ANSI C++ with cfront features.
The file suffix rules relevant to PGI C and C++ are given by the following table:
| Suffix |
How compiled |
|---|---|
| .c |
C and C++ source, preproces and compile |
| .C |
C++ source, preproces and compile |
| .cc |
C++ source, preproces and compile |
|
.cpp |
C++ source, preproces and compile |
| .s |
Assembler source, assemble |
| .S |
Assember sorce, preprocess and assemble |
| .o |
Object file, passed to linker |
| .a |
Library of object files, passed to linker |
By default, the compilers produce static binaries. The CNL OS does not support using shared object files, so you should alway link everything statically on Louhi. The cc and CC does this automatically.
By default, the PrgEnv-pgi module is loaded on logging to Louhi. Then you can and must use the Cray compiler wrappers cc for compiling and linking C-programs and CC for for compiling and linking C++-programs. Don't use the PGI compiler commands pgcc and pgCC, the linker ld command and the MPI wrapper scripts mpicc and mpiCC directly, because the resulting executables do not run on the compute nodes of Louhi. Examples of compiling and linking commands are given in sub-section Compilers.
Please note, that there is a name conflict between stdio.h and the C++ binding in the MPI include file mpi.h (see section Writing MPI programs).
Compiler options
The manual pages of pgcc and pgCC list all available options for these compilers
Most of the compiler and linker options are same for all PGI compilers. Compiler options common for different compilers or all PGI compilers are discussed in sub-sections Compilers and General usage of PGI compilers. There are, however some special options for C or C++ or both (see the PGI User's Guide).
As for the Fortran programs a good set of options for C and C++ programs is:
cc -fastsse cprog.c
or even
cc -fastsse -Mipa=fast cprog.c
Optimization level is -O2 here. You may try also to add -O3, which is the highest optimization level.
For C++ programs add -minline=levels:10 --no_exceptions:
CC -fastsse -Mipa=fast -Minline=levels:10 --no_exceptions Cprog.C
However, if exception handling is used, a program compilation with --no_exceptions will fail. Inlining may boost performance of C programs, too. Please, note that PGI C and C++ compilers are not able to inline functions which are not in the same source file which you are compiling. If you want this inlining to happen, you must write or move the functions to be inlined to the same file, which you are compiling.
If optimization with these options is too aggressive, you should try lower level optimization.
Other useful options are -Minfo, -Mneginfo and -dryrun, if you need information about compilation and optimization. The option -help gives information about compiler options when used with pgcc and pgCC:
pgcc -help -fastsse
Please, note that Cray XT systems does not support the option -Mconcur.
More infromation (in addition to the manual pages) is given in the PGI User's Guide, which is available on Louhi (e.g., for the major version 7.0) in the directory
/opt/pgi/7.0.5/linux86-64/7.0/doc
as the file pgi70ug.pdf. This directory contains all PGI manuals. They are available also from the PGI's documentation page
http://www.pgroup.com/resources/docs.htm
There may be manuals for a newer version, because there are always the latest ones.
C/C++ pragmas
C/C++ pragmas inserted in program source code allow you to alter the
effects of certain command-line options and control various aspects of the compilation process for a specific routine or a specific program loop.
Unsupported C++ Header Files
PGI does not provide a complete set of the old C++ Standard Library and
STL header files. PGI C++ does support some old header files (iostream.h,
exception.h, iomanip.h, ios.h, istream.h, ostream.h, new.h,
streambuf.h, strstream.h, and typeinfo.h), which include their C++
Standard Library counterpart.
To use an unsupported header file, delete the .h. For example, change <vector.h> to <vector>, or create your own vector.h file and use the -I compiler option to cause the compiler to access the header file in your directory:
#ifndef __VECTOR_H
#define __VECTOR_H
#include <vector>
using std::vector;
#endif