Set num_threads to 50 on 32-bit hppa in two libgomp loop tests
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / routine-w-1.c
blob4521cb911437d14e0d343764a5794a4402c49e38
1 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
2 aspects of that functionality. */
4 #include <stdio.h>
5 #include <openacc.h>
6 #include <gomp-constants.h>
8 #define N (32*32*32+17)
10 #pragma acc routine worker
11 void __attribute__ ((noinline)) worker (int ary[N])
12 /* { dg-warning "region is vector partitioned but does not contain vector partitioned code" "" { target *-*-* } .-1 } */
14 #pragma acc loop worker
15 for (unsigned ix = 0; ix < N; ix++)
17 if (acc_on_device (acc_device_not_host))
19 int g, w, v;
21 g = __builtin_goacc_parlevel_id (GOMP_DIM_GANG);
22 w = __builtin_goacc_parlevel_id (GOMP_DIM_WORKER);
23 v = __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR);
24 ary[ix] = (g << 16) | (w << 8) | v;
26 else
27 ary[ix] = ix;
31 int main ()
33 int ary[N];
34 int ix;
35 int exit = 0;
36 int ondev = 0;
37 int workersize;
39 for (ix = 0; ix < N;ix++)
40 ary[ix] = -1;
42 #define NW 32
43 #define VL 32
44 #pragma acc parallel num_workers(NW) vector_length(VL) \
45 copy(ary) copy(ondev)
47 ondev = acc_on_device (acc_device_not_host);
48 worker (ary);
50 workersize = NW;
51 #ifdef ACC_DEVICE_TYPE_radeon
52 /* AMD GCN has an upper limit of 'num_workers(16)'. */
53 if (workersize > 16)
54 workersize = 16;
55 #endif
57 for (ix = 0; ix < N; ix++)
59 int expected = ix;
60 if(ondev)
62 int g = 0;
63 int w = ix % workersize;
64 int v = 0;
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;