| 1 |
/* Ensure that worker-vector state conditional expressions are |
| 2 |
properly handled by the nvptx backend. */ |
| 3 |
|
| 4 |
#include <assert.h> |
| 5 |
#include <math.h> |
| 6 |
|
| 7 |
|
| 8 |
#define N 1024 |
| 9 |
|
| 10 |
int A[N][N] ; |
| 11 |
|
| 12 |
void test(int x) |
| 13 |
{ |
| 14 |
#pragma acc parallel num_gangs(16) num_workers(4) vector_length(32) copyout(A) |
| 15 |
{ |
| 16 |
#pragma acc loop gang |
| 17 |
for(int j=0;j<N;j++) |
| 18 |
{ |
| 19 |
if (x==1) |
| 20 |
{ |
| 21 |
#pragma acc loop worker vector |
| 22 |
for(int i=0;i<N;i++) |
| 23 |
A[i][j] = 1; |
| 24 |
} |
| 25 |
else |
| 26 |
{ |
| 27 |
#pragma acc loop worker vector |
| 28 |
for(int i=0;i<N;i++) |
| 29 |
A[i][j] = -1; |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
int main(void) |
| 37 |
{ |
| 38 |
test (0); |
| 39 |
for (int i = 0; i < N; i++) |
| 40 |
for (int j = 0; j < N; j++) |
| 41 |
assert (A[i][j] == -1); |
| 42 |
|
| 43 |
test (1); |
| 44 |
for (int i = 0; i < N; i++) |
| 45 |
for (int j = 0; j < N; j++) |
| 46 |
assert (A[i][j] == 1); |
| 47 |
|
| 48 |
return 0; |
| 49 |
} |