Compiling OpenACC code on the HPC Cluster
On the HPC we use the pgi accelerator compilers. This requires loading a cuda module. You can load the pgi module using
module load cuda/4.2.9 module load pgi/13.7
Loading this module will allow you to compile c code with the pgcc command, fortran 90 with pgf90, and c++ with pgc++. Many of the compiler flags for openacc are as you would expect; you can use -l<library> to link a library, -o to specify the output file, and so on. On the HPC you will most likely want to use the following command line flags to compile your code.
pgcc -acc -ta=nvidia <file>.c -o <outfile>
The -acc flag tells the compiler to enable OpenACC pragmas and the -ta specifies the target architecture. You can use -Minfo=accel to print additional OpenACC debugging information.
Running OpenACC code
Once you have compiled your binary you will want to submit the code to the gpu queue. You can submit this with the submission script via sbatch:
$ cat openacc.sh #!/bin/bash #SBATCH --gres=gpu:8 #SBATCH -n1 ./<outfile> $ sbatch openacc.sh
You do not need to load a cuda module to use OpenACC. You can read more about the GPU Guide.