Improve atomic store implementation on hppa-linux.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-red-w-2.c
blobff5e4a1656bab25443498862639965fcf3f5be39
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 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
8 aspects of that functionality. */
10 #include <stdio.h>
11 #include <openacc.h>
12 #include <gomp-constants.h>
14 #define N (32*32*32+17)
15 int main ()
17 int ix;
18 int ondev = 0;
19 int q = 0, h = 0;
20 int workersize;
22 #pragma acc parallel num_workers(32) vector_length(32) copy(q) copy(ondev) \
23 copyout(workersize)
24 /* { dg-note {variable 't' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
25 /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
26 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-4 } */
28 int t = q;
30 #pragma acc loop worker reduction(+:t)
31 /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
32 /* { dg-note {variable 'val' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
33 /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
34 /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
35 /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-5 } */
36 for (unsigned ix = 0; ix < N; ix++)
38 int val = ix;
40 if (acc_on_device (acc_device_not_host))
42 int g, w, v;
44 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
45 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
46 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
47 val = (g << 16) | (w << 8) | v;
48 ondev = 1;
50 t += val;
52 q = t;
53 workersize = __builtin_goacc_parlevel_size (GOMP_DIM_WORKER);
56 for (ix = 0; ix < N; ix++)
58 int val = ix;
59 if(ondev)
61 int g = 0;
62 int w = ix % workersize;
63 int v = 0;
65 val = (g << 16) | (w << 8) | v;
67 h += val;
69 if (q != h)
71 printf ("t=%x expected %x\n", q, h);
72 return 1;
75 return 0;