HPC aficionado Doug Eadline is doing a series of articles about alternative GPU programming methods over at Cluster Monkey. In this case, alternative means not CUDA or OpenCL, the two most popular frameworks for GPGPU programming today. Because of their low-level nature, both can be used to good effect to get optimal performance from the GPU — perhaps CUDA more so than OpenCL — but the languages are somewhat of a challenge for the average programmer.
Fortunately, there a number of other software development tools that have emerged to provide a higher level programming environment for the application developer. The first one Eadline tackles is PGI’s accelerator model, a directives-based approach that can be used to turn Fortran or C source into GPU-accelerated code.
In a nutshell, the advantage to PGI’s approach is that it allows programmers to instrument new or existing high-level source code using special directives that the compiler uses to generate GPU executable code. Conveniently the same source code can be used to generate vanilla CPU code if the GPU target is not available. In addition, the compiler removes some (but not all) of the data manipulation the programmer normally must do to manage separate memory spaces on the GPU and CPU.
The accelerator directives approach also has the advantage of hardware portability. The same source could theoretically be applied to NVIDIA and AMD GPUs, the upcoming Intel MIC coprocessor, or any other future accelerator. Currently PGI’s accelerator compiler supports NVIDIA CUDA-capable GPUs and also has a CUDA-based port for multicore x86 CPUs.