aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c
blob: 593e7d4d553bb08545ed1a8fcf592f0fc8ca63f2 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* { dg-do run } */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

/* Exercise the kernel launch argument mapping.  */

int
main (int argc, char **argv)
{
  int a[256], b[256], c[256], d[256], e[256], f[256];
  int i;
  int n;

  /* 48 is the size of the mappings for the first parallel construct.  */
  n = sysconf (_SC_PAGESIZE) / 48 - 1;

  i = 0;

  for (i = 0; i < n; i++)
    {
      #pragma acc parallel copy (a, b, c, d)
	{
	  int j;

	  for (j = 0; j < 256; j++)
	    {
	      a[j] = j;
	      b[j] = j;
	      c[j] = j;
	      d[j] = j;
	    }
	}
    }

#pragma acc parallel copy (a, b, c, d, e, f)
  {
    int j;

    for (j = 0; j < 256; j++)
      {
	a[j] = j;
	b[j] = j;
	c[j] = j;
	d[j] = j;
	e[j] = j;
	f[j] = j;
      }
  }

  for (i = 0; i < 256; i++)
   {
     if (a[i] != i) abort();
     if (b[i] != i) abort();
     if (c[i] != i) abort();
     if (d[i] != i) abort();
     if (e[i] != i) abort();
     if (f[i] != i) abort();
   }

  exit (0);
}