* c-c++-common/Wrestrict.c (test_strcpy_range): Revert latest change.
[official-gcc.git] / libgomp / testsuite / libgomp.oacc-c-c++-common / routine-gwv-1.c
blobace2f499b1fa3d514255596149336a7bd7e24ea1
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 worker vector
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) num_workers(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 chunk_size = (N + 32*32*32 - 1) / (32*32*32);
52 int g = ix / (chunk_size * 32 * 32);
53 int w = ix / 32 % 32;
54 int v = ix % 32;
56 expected = (g << 16) | (w << 8) | v;
59 if (ary[ix] != expected)
61 exit = 1;
62 printf ("ary[%d]=%x expected %x\n", ix, ary[ix], expected);
66 return exit;