=====Portland Group C/C++=====

The C/C++ compiler on Tiger is Portland Group C/C++. Tiger will most likely have several versions of the PGI compilers installed at any given time. A "''module avail''" will show what is available. A "''module default''" will show what is loaded (if anything.)

The PGI 6.0 and 5.2-4 C compilers have two commands:
* ''pgcc'': C compiler, ANSI (89) and K&R C
* ''pgCC'': C++ compiler, ANSI C++ with "''cfront''" features

Portland Group provides a graphical debugger, ''pgdbg''. Note that ''pgcc'' does not currently support the ANSI 99 standard for C. For complex numbers, use ''pgCC''.

===== Important Notes =====

Upon login, your environment does not have any compilers loaded. You will need to do a "''module load <compiler>''". After that, you can use the compiler and read its man page.

When you load a compiler module, a related mpich module will be loaded as well. This module contains header files and libraries for MPI. In addition, it contains the mpicc and mpicxx commands. To compile an MPI program, you will need to use mpicc or mpicxx instead of the pgcc or pgCC. Using mpicc/mpicxx will call the appropriate compiler, and it will set up the appropriate header and library paths for MPI. It will also automatically link in any necessary libraries for MPI. Thus, there is no need to add "''-lmpi''" to your command line.

=====Options=====

The following options control the amount of debugging information generated by the compiler. They can adversely affect optimization.

''-g''

Generate symbolic debug information. Turns off optimization.

''-Mbounds''

Add (don't add) array bound checking.

----

The following option controls the memory model used by the resulting executable. It can be critical for applications that use more than 2 GB of memory per process.

'-mcmodel=medium''

Use the memory model that allows data sections to be larger than 2 GB. (Implies "''-Mlarge_arrays''".) **Applications using more then 2 GB that don't use this option can produce incorrect results!**

----

For most cases, the usual levels of optimization are appropriate (-O0, -O1, -O2 (default), -O3). Here are a few exceptions.

''-fast''

Chooses generally optimal flags for the target platform. Use pgcc -fast -help to see the equivalent switches. Note this sets the optimization level to a minimum of 2; see -O.

''-fastsse''

Chooses generally optimal flags for a processor that supports the SSE (Pentium 3/4, AthlonXP/MP, Opteron) and SSE2 (Pentium 4, Opteron) instructions. Use pgcc -fastsse -help to see the equivalent switches.

'-tp k8-64''

Target optimization to the 64-bit Opteron processor.

''-Mflushz''

Set SSE to flush-to-zero mode.

''-pg''
''-ql''
''-Mprof''

Instrument program for profiling. These flags imply different types of profiling. Please check the pgcc or pgCC man page.

''-Minfo''**

Generate an optimization report to stderr. This has several suboptions, so check the man page.

''-mp''**

Enable the compiler to generate multi-threaded code based on the OpenMP directives.

=====Documentation=====

See ''man pgcc'' or ''man pgCC'' for a full list of compiler options. PDF and HTML documentation is also available online from Portland Group at the following URL.

http://www.pgroup.com/doc/pgiug.pdf

http://www.pgroup.com/resources/tips.htm