aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/gomp/allocate-1.c
blob: 5630dac333427228bd3d7c0d80a9cd5301a1ad64 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
typedef enum omp_allocator_handle_t
#if __cplusplus >= 201103L
: __UINTPTR_TYPE__
#endif
{
  omp_null_allocator = 0,
  omp_default_mem_alloc = 1,
  omp_large_cap_mem_alloc = 2,
  omp_const_mem_alloc = 3,
  omp_high_bw_mem_alloc = 4,
  omp_low_lat_mem_alloc = 5,
  omp_cgroup_mem_alloc = 6,
  omp_pteam_mem_alloc = 7,
  omp_thread_mem_alloc = 8,
  __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
} omp_allocator_handle_t;

int bar (int, int *, int);
omp_allocator_handle_t baz (void);

void
foo (int x, int z)
{
  int y[16] = { 0 }, r = 0, i;
  omp_allocator_handle_t h = baz ();
  #pragma omp parallel allocate (x) allocate (omp_default_mem_alloc : y) \
	      allocate ((omp_allocator_handle_t) omp_default_mem_alloc:z) firstprivate (x, y, z)
  bar (x, y, z);
  #pragma omp task private (x) firstprivate (z) allocate (omp_low_lat_mem_alloc:x,z)
  bar (0, &x, z);
  #pragma omp taskwait
  #pragma omp target teams distribute parallel for private (x) firstprivate (y) \
	      allocate ((omp_allocator_handle_t)(omp_default_mem_alloc + 0):z) \
	      allocate (omp_default_mem_alloc: x, y) allocate (omp_low_lat_mem_alloc: r) \
	      lastprivate (z) reduction(+:r)
  for (i = 0; i < 64; i++)
    {
      z = bar (0, &x, 0);
      r += bar (1, y, 0);
    }
  #pragma omp single private (x) allocate (h:x)
  ;
  #pragma omp single allocate (*&h : x) private (x)
  ;
  #pragma omp parallel shared (r, x, z)
  #pragma omp single firstprivate (r) allocate (x, r, z) private (x, z)
  ;
  #pragma omp for allocate (x) private (x)
  for (i = 0; i < 64; i++)
    x = 1;
  #pragma omp sections private (x) allocate (omp_low_lat_mem_alloc: x)
  {
    x = 1;
    #pragma omp section
    x = 2;
    #pragma omp section
    x = 3;
  }
  #pragma omp taskgroup task_reduction(+:r) allocate (omp_default_mem_alloc : r)
  #pragma omp task in_reduction(+:r) allocate (omp_default_mem_alloc : r)
  r += bar (r, &r, 0);
  #pragma omp teams private (x) firstprivate (y) allocate (h : x, y)
  bar (x, y, 0);
  #pragma omp taskloop lastprivate (x) reduction (+:r) allocate (h : x, r)
  for (i = 0; i < 16; i++)
    {
      r += bar (0, &r, 0);
      x = i;
    }
  #pragma omp taskgroup task_reduction(+:r) allocate (omp_default_mem_alloc : r)
  #pragma omp taskloop firstprivate (x) in_reduction (+:r) \
		       allocate (omp_default_mem_alloc : x, r)
  for (i = 0; i < 16; i++)
    r += bar (x, &r, 0);
  #pragma omp taskwait
}

void
qux (const omp_allocator_handle_t h)
{
  int x = 0;
  #pragma omp parallel firstprivate (x) allocate (h: x)
  x = 1;
}