Download User Manual - Support

Transcript
8.5 Available Tools
String decoded on GPU as: Hello World!
alloc: Relinquishing job allocation 2263
salloc: Job allocation 2263 has been revoked.
The number of characters displayed in the encoded string appear less
than expected because there are unprintable characters in the encoding
due to the cipher used being not exactly rot13.
8.5.5 OpenACC
OpenACC (http://www.openacc-standard.org) is a new open
parallel programming standard aiming at simplifying the programmability of heterogeneous CPU/GPU computing systems. OpenACC allows parallel programmers to provide OpenACC directives to the compiler,
identifying which areas of code to accelerate. This frees the programmer
from carrying out time-consuming modifications to the original code itself. By pointing out parallelism to the compiler, directives get the compiler to carry out the details of mapping the computation onto the accelerator.
Using OpenACC directives requires a compiler that supports the OpenACC standard.
In the following example, where π is calculated, adding the #pragma
directive is sufficient for the compiler to produce code for the loop that
can run on either the GPU or CPU:
Example
#include <stdio.h>
#define N 1000000
int main(void) {
double pi = 0.0f; long i;
#pragma acc parallel loop reduction(+:pi)
for (i=0; i<N; i++) {
double t= (double)((i+0.5)/N);
pi +=4.0/(1.0+t*t);
}
printf("pi=%16.15f\n",pi/N);
return 0;
}
© Bright Computing, Inc.
61