PGI Compilers

Overview

The Portland Compiler Suite (now owned by Nvidia) contains Fortran 95, Fortran 90, Fortran 77, C, C++, HPF and CUDA Accelerator compilers for machines running 64bit Linux.

Versions 16.5, 18.10 and 20.1 are installed on the CSF.

Please note that PGI has been acquired by Nvidia and that the PGI compiler suite is now supplied as part of the Nvidia HPC SDK. The version of the PGI compiler given below will continue to run, but if you are developing GPU code you may wish to try the Nvidia HPC SDK on the CSF (documentation to appear soon).

Note: the PGI CUDA Accelerator supports OpenACC compiler directives.

The PGI compiler can be used to compile for Intel (Haswell, Broadwell, Skylake) and Nvidia CUDA GPU architectures.

Restrictions on use

There are only two network licenses available site wide for each of Fortran and C/C++. If you get a license related error, it is almost certainly because all of our licenses are in use and you should try again at a later time. For further licensing information see the following webpage:

Set up procedure

To gain access to these compilers, run one of the following command after logging into the login node.

module load compilers/pgi/20.1
module load compilers/pgi/18.10
module load compilers/pgi/16.5

Please note that if you require any functionality from a GCC compiler newer than the system-wide GCC 4.8.5 while using the PGI compilers, you should load the gcc compiler modulefile before the PGI modulefile. For example, you may need to do this to allow cmake or configure to pass certain configuration tests.

Basic compilation commands

Basic compilation commands are as follows:

# C
pgcc hello.c -o hello

# C++ (note: use pgc++ if link compatibility with the GNU C++ compiler is required)
pgCC hello.cpp -o hello
pgcpp hello.cpp -o hello

# Fortran
pgf90 hello.f90 -o hello
pgf95 hello.f90 -o hello
pgfortran hello.f90 -o hello

# High performance fortran
pghpf hello.hpf -o hello

Target Architectures

To compile specifically for architectures such as Intel Haswell/Broadwell and Skylake use the -tp=architecture flag. For example:

pgcc -tp=haswell hello.c -o hello_hw
pgcc -tp=haswell hello.c -o hello_bw
pgcc -tp=skylake hello.c -o hello_sky

See below for compiling for Nvidia GPUs using OpenACC. Note that this version of the PGI compiler only supports up to CUDA 8.0.

Sample code

Sample code can be found in the subfolders of the $PGIEXAMPLES directory

AutoPar  CUDA-Fortran  CUDA-Libraries  CUDA-x86-SDK  F2003  MPI  OpenACC  OpenMP

Each subfolder contains makefiles to compile the sample code. If you copy these folders and see an errors like /usr/bin/ld: cannot open output file c1.exe: Permission denied when compiling ensure you have the necessary permissions to write files to your folders.

Compiling and submitting OpenACC C code

Copy one of the samples to your current working directory:

cd ~/scratch
cp -r $PGIEXAMPLES/OpenACC/samples/acc_c1/ .
cd acc_c1

# Compile using the makefile found in the source directory using the 'make' command.
# This will also run the app on the login node.
make

# Alternatively compile manually by supplying the correct flags to the PGI C compiler
pgcc -fast -Minfo -acc -o acc_c1.out acc_c1.c

Compile it either using the makefile provided in /openacc or use the following command:

The following SGE script, pgi.sge, is suitable for submitting the above executable:

#!/bin/bash --login
#$ -cwd
#$ -l nvidia_v100=1               # You must have been granted access to the GPU nodes

# Load the required version of the compiler modulefile
module load compilers/pgi/16.5

./acc_c1.exe

Submit this as a batch job using:

qsub pgi.sge

If successful, the job output file will contain the following:

100000 iterations completed

Further information

Once you have loaded the PGI module (see set up procedure), basic documentation is available as a manpage:

man pgcc
man pgf90
man pgc++

Further Info

Last modified on November 1, 2022 at 11:25 am by Pen Richardson