1 /* { dg-additional-options "-Wopenacc-parallelism" } for testing/documenting
2 aspects of that functionality. */
6 #include <gomp-constants.h>
9 #ifdef ACC_DEVICE_TYPE_radeon
10 /* AMD GCN uses the autovectorizer for the vector dimension: the use
11 of a function call in vector-partitioned code in this test is not
12 currently supported. */
15 #define NUM_VECTORS 32
20 #define WORK_ID(I,N) \
21 (acc_on_device (acc_device_not_host) \
22 ? __builtin_goacc_parlevel_id (GOMP_DIM_WORKER) \
25 (acc_on_device (acc_device_not_host) \
26 ? __builtin_goacc_parlevel_id (GOMP_DIM_VECTOR) \
29 #pragma acc routine worker
30 void __attribute__ ((noinline
))
31 WorkVec (int *ptr
, int w
, int h
, int nw
, int nv
)
33 #pragma acc loop worker
34 for (int i
= 0; i
< h
; i
++)
35 #pragma acc loop vector
36 for (int j
= 0; j
< w
; j
++)
37 ptr
[i
*w
+ j
] = (WORK_ID (i
, nw
) << 8) | VEC_ID(j
, nv
);
40 int DoWorkVec (int nw
)
42 int ary
[HEIGHT
][WIDTH
];
45 for (int ix
= 0; ix
!= HEIGHT
; ix
++)
46 for (int jx
= 0; jx
!= WIDTH
; jx
++)
47 ary
[ix
][jx
] = 0xdeadbeef;
49 printf ("spawning %d ...", nw
); fflush (stdout
);
51 #pragma acc parallel num_workers(nw) vector_length (NUM_VECTORS) copy (ary)
52 /* { dg-warning "region contains vector partitioned code but is not vector partitioned" "" { target openacc_radeon_accel_selected } .-1 } */
54 WorkVec ((int *)ary
, WIDTH
, HEIGHT
, nw
, NUM_VECTORS
);
57 for (int ix
= 0; ix
!= HEIGHT
; ix
++)
58 for (int jx
= 0; jx
!= WIDTH
; jx
++)
60 int exp
= ((ix
% nw
) << 8) | (jx
% NUM_VECTORS
);
62 if (ary
[ix
][jx
] != exp
)
64 printf ("\nary[%d][%d] = %#x expected %#x", ix
, jx
,
69 printf (err
? " failed\n" : " ok\n");
78 for (int W
= 1; W
<= NUM_WORKERS
; W
<<= 1)