Compiling and Running CUDA Programs
Last modified: Wednesday April 10, 2013 10:39 AM
A Brief Introduction to CUDAFour Eos compute nodes are equipped with NVIDIA Graphic Processing Unit (GPU) cards: two nodes with two Tesla M2050s each and the other two nodes with one Tesla M2070 each. The four nodes support GPU accelerated computing using CUDA, a general purpose parallel platform and programming model for offloading computational intensive parts of a program to NVIDIA GPUs. Figure 1 shows a block diagram of a GPU node with two M2050s.
The CUDA programming model is a heterogeneous model in which both the CPU and GPU are used. In CUDA, the host refers to the CPU and its memory, while the device refers to the GPU and its memory. Code running on the CPU manages memory on both host and device, controls data transfers between the host memory and the device memory, and launches kernels, which are functions running on the devices. Given the heterogeneous nature of the CUDA programming model, a typical sequence of operations for a CUDA program is:
- Declare and allocate host and device memory.
- Initialize host data.
- Transfer data from the host memory to the device memory.
- Execute one or more kernels.
- Transfer results from the device memory to the host memory.
On Eos, users can develop CUDA-enabled applications through one of three methods:
- Programming NVIDIA GPUs using the NVIDIA CUDA C/C++ programming interface.
- Programming NVIDIA GPUs using the PGI CUDA Fortran.
- Automatically parallelize loops in C/C++/Fortran code using OpenACC directives.