c++: reduce unnecessary tree_common
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-gwv-1.c
blobd3f6ea24e7e3739733e74cf2ec0ee20258d4d925
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 #define NG 32
24 #define NW 32
25 #define VL 32
26 #pragma acc parallel num_gangs(NG) num_workers(NW) vector_length(VL) \
27 copy(ary) copy(ondev)
28 /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
30 #pragma acc loop gang worker vector
31 /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
32 /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
33 /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
34 /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
35 for (unsigned ix = 0; ix < N; ix++)
37 if (acc_on_device (acc_device_not_host))
39 int g, w, v;
41 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
42 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
43 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
45 ary[ix] = (g << 16) | (w << 8) | v;
46 ondev = 1;
48 else
49 ary[ix] = ix;
52 gangsize = NG;
53 workersize = NW;
54 vectorsize = VL;
55 #ifdef ACC_DEVICE_TYPE_radeon
56 /* AMD GCN has an upper limit of 'num_workers(16)'. */
57 if (workersize > 16)
58 workersize = 16;
59 /* AMD GCN uses the autovectorizer for the vector dimension: the use
60 of a function call in vector-partitioned code in this test is not
61 currently supported. */
62 vectorsize = 1;
63 #endif
65 for (ix = 0; ix < N; ix++)
67 int expected = ix;
68 if(ondev)
70 int chunk_size = (N + gangsize * workersize * vectorsize - 1)
71 / (gangsize * workersize * vectorsize);
73 int g = ix / (chunk_size * workersize * vectorsize);
74 int w = (ix / vectorsize) % workersize;
75 int v = ix % vectorsize;
77 expected = (g << 16) | (w << 8) | v;
80 if (ary[ix] != expected)
82 exit = 1;
83 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
87 return exit;