PGI Compilers (pgcc, pgcpp, pgf90)

Overview

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

Version 15.3 is installed on the zCSF

Note: the PGI CUDA Accelerator supports OpenACC compiler directives. This is available via the PGI C compiler (pgcc) from version 12.10 and the PGI C++ and fortran compilers (pgcpp and pgf90) from version 13.6.

The PGI compiler can be used to compile for Intel (Westmere, Sandybridge, Haswell), AMD (Magny-Cours, Bulldozer) 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 the following command after logging into the login node.

module load compilers/PGI/15.3

Note that if doing OpenACC or CUDAFortran compilation targetting NVidia devices, the PGI compiler comes with its own installation of CUDA (v6.0 and v6.5 in this compiler release). There is no need to load additional CUDA modulefiles.

Basic compilation commands

Basic compilation commands are as follows:

  • C
pgcc hello.c -o hello
  • C++
pgCC hello.cpp -o hello
pgcpp hello.cpp -o hello

Note: Use pgc++ if link compatibility with the GNU C++ compiler is required (see man pgc++)

  • 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 Sandybridge or AMD Bulldozer use the -tp=architecture flag. For example:

pgcc -tp=sandybridge hello.c -o hello_sb
pgcc -tp=haswell hello.c -o hello_bd
pgcc -tp=bulldozer hello.c -o hello_bd

Further optimization flags may be appropriate for different architectures. For example, on AMD Bulldozer it is recommended to use the following:

pgcc -tp=bulldozer -O3 -fast 

To see how to compile OpenACC code for Nvidia GPUs see the OpenACC Sample Code below then the OpenACC compile command below.

Sample code

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

  • /OpenACC/samples
  • /CUDA-Fortran
  • /CUDA-x86-SDK

Each subfolder contains makefiles to compile the sample code. You can copy these folders to you home directory to work on them.

Compiling the OpenACC Samples

We will take a local copy of the OpenACC examples then compile and run them:

# We will do the OpenACC samples on an Nvidia k20 node.
# Note you can compile on the zCSF login node but you must run the
# examples on a GPU node because there is no GPU in the login node.
qrsh -l k20 bash
  #
  # Wait until we are on a K20 node (your prompt will change to kaijuN)

# Now set up your environment on the K20 node
module load compilers/PGI/15.3
mkdir ~/my_openacc_tests
cd ~/my_openacc_tests
cp -r $PGIEXAMPLES/OpenACC/samples/ .   # Notice the 'space' then 'dot' at the end!

# Now compile the examples:
cd samples
make all 2>&1 | tee make-run.log
  #
  # This will compile and run the tests, displaying the results
  # to screen and also capturing the output to a file named make-run.log

# You can review the results by looking at the make-run.log file:
less make-run.log
# or
gedit make-run.log

# We've finished with the K20 node
exit

Compiling and submitting OpenACC C code

OpenACC provides a portable method of using directives to indicate which parts of you code should run on the GPU (or other accelerator). Copy one of the samples to your current working directory:

cp $PGIEXAMPLES/OpenACC/samples/acc_c1/acc_c1.c .

Compile it either using the makefile provided in samples directory or use the following command:

pgcc -o acc_c1.exe acc_c1.c -acc -Minfo=accel -fast             # notice the additional -acc flag

The code (see below) uses an OpenACC pragma (a specially marked comment) to indicate which region should be run on the GPU.

#pragma acc kernels loop

If you are on a K20 (or other Nvidia GPU node) you can run the code immediately:

./acc_c1.exe
100000 iterations completed
Test PASSED

The following SGE script, pgi.sge, is suitable for submitting the above executable to a K20 node if you are currently on the zCSF login node:

#!/bin/bash
#$ -cwd
#$ -S /bin/bash
#$ -l k20
./acc_c1.exe > out.txt

Submit this as a batch job using:

qsub pgi.sge

If successful, the output file out.txt 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
     #
     # replace pgcc with the names of the other compilers as required
     #

Documentation in pdf files is available in directory $PGI/linux86-64/$PGIVER/doc and can be viewed using evince, e.g.

evince $PGIDOCS/pgi15ug.pdf              # User Guide
evince $PGIDOCS/pgi15ref.pdf             # Reference Guide
evince $PGIDOCS/openacc_gs.pdf           # OpenACC Getting Started Guide

The following links may be useful:

Last modified on October 20, 2016 at 9:36 am by Site Admin