Add support for ARMv8-R architecture
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / loop-g-2.c
blob92b82a01eb06e33d5152e66171d6ad275e98eb1e
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)
8 int main ()
10 int ary[N];
11 int ix;
12 int exit = 0;
13 int ondev = 0;
15 for (ix = 0; ix < N;ix++)
16 ary[ix] = -1;
18 #pragma acc parallel num_gangs(32) vector_length(32) copy(ary) copy(ondev)
20 #pragma acc loop gang (static:1)
21 for (unsigned ix = 0; ix < N; ix++)
23 if (__builtin_acc_on_device (5))
25 int g = 0, w = 0, v = 0;
27 __asm__ volatile ("mov.u32 %0,%%ctaid.x;" : "=r" (g));
28 __asm__ volatile ("mov.u32 %0,%%tid.y;" : "=r" (w));
29 __asm__ volatile ("mov.u32 %0,%%tid.x;" : "=r" (v));
30 ary[ix] = (g << 16) | (w << 8) | v;
31 ondev = 1;
33 else
34 ary[ix] = ix;
38 for (ix = 0; ix < N; ix++)
40 int expected = ix;
41 if(ondev)
43 int g = ix % 32;
44 int w = 0;
45 int v = 0;
47 expected = (g << 16) | (w << 8) | v;
50 if (ary[ix] != expected)
52 exit = 1;
53 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
57 return exit;