1 /* { dg-additional-options "-fopt-info-note-omp" }
2 { dg-additional-options "--param=openacc-privatization=noisy" }
3 { dg-additional-options "-foffload=-fopt-info-note-omp" }
4 { dg-additional-options "-foffload=--param=openacc-privatization=noisy" }
5 for testing/documenting aspects of that functionality. */
10 #include <gomp-constants.h>
14 #define DEBUG(DIM, IDX, VAL) \
15 fprintf (stderr, "%sdist[%d] = %d\n", (DIM), (IDX), (VAL))
17 #define DEBUG(DIM, IDX, VAL)
23 check (const char *dim
, int *dist
, int dimsize
)
28 for (ix
= 0; ix
< dimsize
; ix
++)
30 DEBUG(dim
, ix
, dist
[ix
]);
31 if (dist
[ix
] < (N
) / (dimsize
+ 0.5)
32 || dist
[ix
] > (N
) / (dimsize
- 0.5))
34 fprintf (stderr
, "did not distribute to %ss (%d not between %d "
35 "and %d)\n", dim
, dist
[ix
], (int) ((N
) / (dimsize
+ 0.5)),
36 (int) ((N
) / (dimsize
- 0.5)));
49 int gangsize
, workersize
, vectorsize
;
50 int *gangdist
, *workerdist
, *vectordist
;
52 for (ix
= 0; ix
< N
;ix
++)
58 #pragma acc parallel num_gangs(NG) num_workers(NW) vector_length(VL) \
60 /* { dg-note {variable 'ix' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
62 #pragma acc loop gang worker vector
63 /* { dg-note {variable 'ix' in 'private' clause isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-1 } */
64 /* { dg-note {variable 'g' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-2 } */
65 /* { dg-note {variable 'w' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-3 } */
66 /* { dg-note {variable 'v' declared in block isn't candidate for adjusting OpenACC privatization level: not addressable} "" { target *-*-* } .-4 } */
67 for (unsigned ix
= 0; ix
< N
; ix
++)
71 g
= __builtin_goacc_parlevel_id (GOMP_DIM_GANG
);
72 w
= __builtin_goacc_parlevel_id (GOMP_DIM_WORKER
);
73 v
= __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR
);
75 ary
[ix
] = (g
<< 16) | (w
<< 8) | v
;
81 #if defined ACC_DEVICE_TYPE_host
85 #elif defined ACC_DEVICE_TYPE_radeon
86 /* AMD GCN has an upper limit of 'num_workers(16)'. */
89 /* AMD GCN uses the autovectorizer for the vector dimension: the use
90 of a function call in vector-partitioned code in this test is not
91 currently supported. */
95 gangdist
= (int *) __builtin_alloca (gangsize
* sizeof (int));
96 workerdist
= (int *) __builtin_alloca (workersize
* sizeof (int));
97 vectordist
= (int *) __builtin_alloca (vectorsize
* sizeof (int));
98 memset (gangdist
, 0, gangsize
* sizeof (int));
99 memset (workerdist
, 0, workersize
* sizeof (int));
100 memset (vectordist
, 0, vectorsize
* sizeof (int));
102 /* Test that work is shared approximately equally amongst each active
103 gang/worker/vector. */
104 for (ix
= 0; ix
< N
; ix
++)
106 int g
= (ary
[ix
] >> 16) & 255;
107 int w
= (ary
[ix
] >> 8) & 255;
108 int v
= ary
[ix
] & 255;
120 exit
= check ("gang", gangdist
, gangsize
);
121 exit
|= check ("worker", workerdist
, workersize
);
122 exit
|= check ("vector", vectordist
, vectorsize
);