OpenACC

Pragma-based programming model for the use of GPGPU. Much like OpenMP. Sounds open, but is only supported by NVIDIA and a spot of other members (CAPS, CRAY and PGI). At the moment no support in GCC, planned in GCC 4.8 4.9.

Sometime OpenACC will be merged into OpenMP 4.0, but at the moment OpenACC prevents the use of OpenMP

Introduction and excersices

Examples

Example in C

pragma acc kernels 
 
for (int i = 0; i &< n; ++i) { 
    yi = a*xi + yi; } ...

#pragma acc directive [clause , clause] …] Often followed by a structured code block

Example in Fortran

      subroutine saxpy(n, a, x, y) 
      real x, y, a 
      integer n, i 
 
      $!acc kernels 
        do i=1,n 
          y(i) = a*x(i)+y(i) 
        enddo 
      $!acc end kernels 
      end subroutine 
      saxpy ... $ Perform SAXPY on 1M elements 
      call saxpy (2**20, 2.0, x_d, y_d) ...

!$acc directive [clause , clause] …]

Often paired with a matching end directive surrounding a structured code block !$ acc end directive

Compiler and parameters

PGI-Compiler

Check ACC-code parts:

pgcc -acc -Minfo=accel exercise14.c

Compile code including ACC-pragmas:

pgcc -acc exercise14.c -o exercise14
Log In