Add support for ARMv8-R architecture
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / routine-g-1.c
blob9d14c3bd3130ddab83c8223583999b5b3420f3ef
1 /* This code uses nvptx inline assembly guarded with acc_on_device, which is
2 not optimized away at -O0, and then confuses the target assembler.
3 { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
5 #include <stdio.h>
7 #define N (32*32*32+17)
9 #pragma acc routine gang
10 void __attribute__ ((noinline)) gang (int ary[N])
12 #pragma acc loop gang
13 for (unsigned ix = 0; ix < N; ix++)
15 if (__builtin_acc_on_device (5))
17 int g = 0, w = 0, v = 0;
19 __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
20 __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
21 __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
22 ary[ix] = (g << 16) | (w << 8) | v;
24 else
25 ary[ix] = ix;
29 int main ()
31 int ary[N];
32 int ix;
33 int exit = 0;
34 int ondev = 0;
36 for (ix = 0; ix < N;ix++)
37 ary[ix] = -1;
39 #pragma acc parallel num_gangs(32) vector_length(32) copy(ary) copy(ondev)
41 ondev = __builtin_acc_on_device (5);
42 gang (ary);
45 for (ix = 0; ix < N; ix++)
47 int expected = ix;
48 if(ondev)
50 int g = ix / ((N + 31) / 32);
51 int w = 0;
52 int v = 0;
54 expected = (g << 16) | (w << 8) | v;
57 if (ary[ix] != expected)
59 exit = 1;
60 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
64 return exit;