aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/broadcast-1.c
blob: ca0d37bf88a55c3a0d23c3502715f92b77dd36e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* Ensure that worker-vector state conditional expressions are
   properly handled by the nvptx backend.  */

#include <assert.h>
#include <math.h>


#define N 1024

int A[N][N] ;

void test(int x)
{
#pragma acc parallel  num_gangs(16) num_workers(4) vector_length(32) copyout(A)
  {
#pragma acc loop gang
    for(int j=0;j<N;j++)
      {
	if (x==1)
	  {
#pragma acc loop worker vector
	    for(int i=0;i<N;i++)
	      A[i][j] = 1;
	  }
	else
	  {
#pragma acc loop worker vector
	    for(int i=0;i<N;i++)
	      A[i][j] = -1;
	  }
      }
  }
}


int main(void)
{
  test (0);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      assert (A[i][j] == -1);

  test (1);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++)
      assert (A[i][j] == 1);

  return 0;
}