1 /* { dg-additional-options "-fopenacc-dim=16:16" } */
7 #include <gomp-constants.h>
10 static int __attribute__ ((noinline
)) coord ()
14 if (acc_on_device (acc_device_not_host
))
18 g
= __builtin_goacc_parlevel_id (GOMP_DIM_GANG
);
19 w
= __builtin_goacc_parlevel_id (GOMP_DIM_WORKER
);
20 v
= __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR
);
21 res
= (1 << 24) | (g
<< 16) | (w
<< 8) | v
;
27 int check (const int *ary
, int size
, int gp
, int wp
, int vp
)
31 int *gangs
= (int *)alloca (gp
* sizeof (int));
32 int *workers
= (int *)alloca (wp
* sizeof (int));
33 int *vectors
= (int *)alloca (vp
* sizeof (int));
36 memset (gangs
, 0, gp
* sizeof (int));
37 memset (workers
, 0, wp
* sizeof (int));
38 memset (vectors
, 0, vp
* sizeof (int));
40 for (ix
= 0; ix
< size
; ix
++)
42 int g
= (ary
[ix
] >> 16) & 0xff;
43 int w
= (ary
[ix
] >> 8) & 0xff;
44 int v
= (ary
[ix
] >> 0) & 0xff;
46 if (g
>= gp
|| w
>= wp
|| v
>= vp
)
48 printf ("unexpected cpu %#x used\n", ary
[ix
]);
57 offloaded
+= ary
[ix
] >> 24;
63 if (offloaded
!= size
)
65 printf ("offloaded %d times, expected %d\n", offloaded
, size
);
69 for (ix
= 0; ix
< gp
; ix
++)
70 if (gangs
[ix
] != gangs
[0])
72 printf ("gang %d not used %d times\n", ix
, gangs
[0]);
76 for (ix
= 0; ix
< wp
; ix
++)
77 if (workers
[ix
] != workers
[0])
79 printf ("worker %d not used %d times\n", ix
, workers
[0]);
83 for (ix
= 0; ix
< vp
; ix
++)
84 if (vectors
[ix
] != vectors
[0])
86 printf ("vector %d not used %d times\n", ix
, vectors
[0]);
95 int test_1 (int gp
, int wp
, int vp
)
100 #pragma acc parallel copyout (ary)
102 #pragma acc loop gang (static:1)
103 for (int ix
= 0; ix
< N
; ix
++)
107 exit
|= check (ary
, N
, gp
, 1, 1);
109 #pragma acc parallel copyout (ary)
111 #pragma acc loop worker
112 for (int ix
= 0; ix
< N
; ix
++)
116 exit
|= check (ary
, N
, 1, wp
, 1);
118 #pragma acc parallel copyout (ary)
120 #pragma acc loop vector
121 for (int ix
= 0; ix
< N
; ix
++)
125 exit
|= check (ary
, N
, 1, 1, vp
);
132 return test_1 (16, 16, 32);