Improve atomic store implementation on hppa-linux.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-gwv-1.c
blobe5ed2ab70062e3ce8f7f3cff2a4cac0dcd152553
1 /* { dg-additional-options "-fopt-info-note-omp" }
2 { dg-additional-options "--param=openacc-privatization=noisy" }
3 { dg-additional-options "-foffload=-fopt-info-note-omp" }
4 { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
5 for testing/documenting aspects of that functionality. */
7 #include <stdio.h>
8 #include <openacc.h>
9 #include <gomp-constants.h>
11 #define N (32*32*32+17)
12 int main ()
14 int ary[N];
15 int ix;
16 int exit = 0;
17 int ondev = 0;
18 int gangsize, workersize, vectorsize;
20 for (ix = 0; ix < N;ix++)
21 ary[ix] = -1;
23 #pragma acc parallel num_gangs(32) num_workers(32) vector_length(32) \
24 copy(ary) copy(ondev) copyout(gangsize, workersize, vectorsize)
25 /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
27 #pragma acc loop gang worker vector
28 /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
29 /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
30 /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
31 /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
32 for (unsigned ix = 0; ix < N; ix++)
34 if (acc_on_device (acc_device_not_host))
36 int g, w, v;
38 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
39 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
40 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
42 ary[ix] = (g << 16) | (w << 8) | v;
43 ondev = 1;
45 else
46 ary[ix] = ix;
49 gangsize = __builtin_goacc_parlevel_size (GOMP_DIM_GANG);
50 workersize = __builtin_goacc_parlevel_size (GOMP_DIM_WORKER);
51 vectorsize = __builtin_goacc_parlevel_size (GOMP_DIM_VECTOR);
54 for (ix = 0; ix < N; ix++)
56 int expected = ix;
57 if(ondev)
59 int chunk_size = (N + gangsize * workersize * vectorsize - 1)
60 / (gangsize * workersize * vectorsize);
62 int g = ix / (chunk_size * workersize * vectorsize);
63 int w = (ix / vectorsize) % workersize;
64 int v = ix % vectorsize;
66 expected = (g << 16) | (w << 8) | v;
69 if (ary[ix] != expected)
71 exit = 1;
72 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
76 return exit;