#include #include int main(){ int i,j,it; // set the size of our test arrays int numel = 2000; // allocate and initialize test arrays float A[numel][numel]; float Anew[numel][numel]; for (i = 0; i < numel; i++){ for ( j = 0; j < numel; j++){ A[i][j] = drand48(); } } // apply stencil 1000 times #pragma acc data copy(A), create(Anew) for (it = 0; it < 1000; it++){ #pragma acc parallel loop for (i = 1; i < numel-1; i++){ for (j = 1; j < numel-1; j++){ Anew[i][j] = 0.25f * (A[i][j-1] + A[i][j+1] + A[i-1][j] + A[i+1][j]); } } #pragma acc parallel loop for (i = 1; i < numel-1; i++){ for (j = 1; j < numel-1; j++){ A[i][j] = Anew[i][j]; } } } // do something with A[][] return 0; }