PGI Compilers (Fortran, C, C++)
Availability
The PGI compilers are the default compilers at NERSC.
Source Files and Language Dialects
The Portland Group Fortran compiler supports the following file extensions
.f, .F, .for, .fpp, .f90, .F90, .f95, and .F95
By default, the compilers with Fortran 77 defaults require fixed form Fortran source. Compilers with Fortran 90 defaults require free form Fortran source. To change the defaults use the following flags:
- -Mextend
- -Mfixed Indicates source code uses fixed-form syntax as in Fortran 77, option is included by default for files with suffixes .f, .F, .for, and .fpp
- -Mfreeform Indicates source code written with free-form syntax as in Fortran 90, option is included by default for files with suffixes .f90, .F90, .f95, and .F95
Optimization
-fast and -fastsse
In PGI7 family, -fast and -fastsee are the same They both contain the common optimizations and also include SSE hardware and vectorization. The -fast and -fastsse arguments are equal to "-O2 -Munroll=c:1 -Mnoframe -Mlre -Mvect=sse -Mscalarsse -Mcache_align -Mflushz"
- -Munroll
- For -Munroll=c specifies completely unroll loops with this loop count or less
- For -Munroll=n:(m) says unroll other loops m times
- -Mnoframe does not set up a stack frame
- -Mlre is loop-carried redundancy elimination
- -Mcache_align aligns the top level arrays and objects on cache-line boundaries
- -Mflushz flushes SSE denormal numbers to zero
Note: In PGI6 family, -fast and -fastsse are different. Please use "pgf95 -help -fast" or "pgf95 -help -fastsse" to see the details.
-On
The compilers allow you to select a general level of optimization by specifying a numeric optimization level with the -O flag. The higher the number the greater the amount of optimization the compiler does, the longer the compile takes, and the more memory the compile uses. The current default optimization -O2.
- -O0
- -O1
- -O2 (default)
- -O3 more aggressive hoisting and scalar replacement; not part of -fastsse.
- -O4 (currently no different than -03)
-Mipa
The -Mipa option enables interprocedural analysis (IPA) by the compiler. This enables the compiler to identify optimization opportunities across procedural boundaries. It does this by extending the area that is examined during optimization and inlining from a single procedure to multiple procedures (possibly in different source files) and the linkage between them. This option should be included in both the compile and link phases.
Additionally the -Mipa flag can do the following
- Interprocedural constant propagation
- Pointer disambiguation
- Alignment detection and propagation
- F90 shape propagation
- Function inlining
- IPA optimization of libraries, including inlining
-Mipa options
- -Mipa=fast
- -Mipa=fast,inline
- -Mipa=safe:(name) It is safe to optimize functions which call or are called from unknown function or library 'name'
- -Mipa=libopt Perform IPA optimizations on libraries
- -Mipa=libinline Perform IPA inlining from libraries
-Minfo and -Mneginfo
- -Minfo provides feedback on optimations made by the compiler
- -Mneginfo provides feedback on what the compiler was unable to optimize
- -v gives verbose output, useful for debugging system or build problems
Debugging Options
- -g generates symbolic debug information used by a debugger
- -gopt generates debug information in the presence of optimization
- -Mbounds adds array bounds checking
- -Mchkptr checks for unintended de-referencing of null pointers
- -v gives verbose output, useful for debugging system or build problems
- -Mlist will generate a listing
- -Minfo provides feedback on optimations made by the compiler
- -S or -Mkeepasm to see exact assembly generated
Explicit Function Inlining with -Minline
Particularly important for C and C++ codes
syntax: -Minline=[=[lib:]<inlib> | [name:]<func> | except:<func>: | size:<n> | levels:<n>]
- [lib:]<inlib> Inline extracted functions from inlib
- [name:]<func> Inline function func
- except:<func> Do not inline function func
- size:<n> Inline only functions smaller than n statements (approximate)
- levels:<n> Inline n levels of functions
For C++ Codes, PGI recommends IPA=based inlining or -Minling=levels:10
-Msafeptr for C and C++ Codes
syntax: -M[no]safeptr[=all | arg | auto | dummy | local | static | global]
- all All pointers are safe
- arg Argument pointers are safe
- local Local pointers are safe
- static Static local pointers are safe
- global Global pointers are safe
Pathscale vs PGI Fortran Compiler Flags Comparison
| pathf90 | pgif90 | Meaning |
|---|---|---|
| File Handling Options | ||
| -c | -c | compile to .o files but do not link to build an executable |
| -o | -o | name executable output file |
| -S | -S | produce assembler source output file |
| -module | -module | specify directory to search for module files (.mod) |
| -I | -I | specify directory to search for #include files |
| -L, -l | -L, -l | specify directory to search for libraries |
| Source File Options | ||
| default for free form | default for free form | Use .f90 filename extension for Fortran source code files |
| default for fixed form | default for fixed form | Use .f filename extension for Fortran source code files |
| -ansi | -Mstandard | warn of nonstandard language usage |
| -freeform | -Mfree[form] | expect free-form (fortran 90) source input |
| -fixedform | -Mfixed | expect fixed-form (fortran 77) source input |
| -col72 | -Mfixed | specifies 72 column fixed source input form |
| -col80 | No ftn equivalent | specifies 80 column fixed source input form |
| -extend-source | -Mextend | specifies 132 column fixed source input form |
| No Pathscale equivalent | -Mdclchk | specifies no implicit data typing ("implicit none") |
| Source Preprocessing | ||
| default for free form | default for free form | Invoke preprocessor first on .F90 filename extension for Fortran source code files |
| default for fixed form | default for fixed form | Invoke preprocessor first on .F filename extension for Fortran source code files |
| -Dname[=def] | -Dname[=def] | Define variables used for source preprocessing |
| Message Output Options | ||
| -version, -dumpversion | -V, -show | print the version number of the compiler |
| -w | -Minform=severe, -silent | suppress all compiler messages except errors |
| -flist | -Mlist | produce source code listing |
| No Pathscale equivalent | -Minform=level | specify level of message output (level can be fatal, severe, warn, or inform) |
| -v | -v | verbose output from compiler, showing progress of each phase |
| No Pathscale equivalent | -Minfo=mp | feedback from parallelization process |
| Runtime Checking Options | ||
| -C, -ffortran-bounds-check | -C, -Mbounds | run-time checking of array bounds |
| No Pathscale equivalent | No ftn equivalent | argument or procedure interface checking (runtime, for f90) |
| Code Generation Options | ||
| -g | -g | compile for debugging |
| -static-data | -Msave | make all local storage static |
| No Pathscale equivalent | -Monetrip | execute all do-loops at least once (Fortran-IV compatibility) |
| -zerouv | No ftn equivalent | initialize all local variables to zero |
| -LANG:recursive=ON | -Mrecursive | compile for recursive subroutine calling |
| -OPT:IEEE_arithmetic=1 | -Kieee | compile for IEEE-conformant arithmetic |
| Profiling Options | ||
| -pg | -pg | compile with support for profiling |
| Optimization Options | ||
| -O{0-3} | -O{0-4} | specifies optimization level |
| -Ofast | -fastsse | specifies a very high level of optimizatio |


