.. index:: pair: Tutorial; Index .. _GPU_compiling: ================================ CUDA and OpenACC Compilers ================================ This page contains information about compiling GPU-based codes with NVidia's CUDA compiler and PGI's OpenACC compiler directives. For information on how to run GPU Computing jobs in Midway, see :ref:`GPU_computing` .. contents:: :local: Compiling CUDA GPU code on Midway --------------------------------- To view available CUDA versions on Midway, use the command: .. code:: bash module avail cuda At time of writing, the available CUDA versions are:: cuda/4.2(default) cuda/5.0 cuda/5.5 A very basic CUDA example code is provided below :download:`cudamemset.cu`: .. literalinclude:: cudamemset.cu :language: bash CUDA code must be compiled with Nvidia's nvcc compiler which is part of the cuda software module. To build a CUDA executable, first load the desired CUDA module and compile with: .. code:: bash nvcc source_code.cu Compiling OpenACC GPU code on Midway ------------------------------------ OpenACC is supported on Midway through the PGI 2013 compiler suite. To load the OpenACC compiler, use the command: .. code:: bash module load pgi/2013 A very basic OpenACC example code is provided below :download:`stencil.c`: .. literalinclude:: stencil.c :language: bash OpenACC code targeted at an Nvidia GPU must be compiled with the PGI compiler using at least the following options: .. code:: bash pgcc source_code.c -ta=nvidia -acc