(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
gomp/
allocate-6.c
       1  typedef enum omp_allocator_handle_t
       2  #if __cplusplus >= 201103L
       3  : __UINTPTR_TYPE__
       4  #endif
       5  {
       6    omp_null_allocator = 0,
       7    omp_default_mem_alloc = 1,
       8    omp_large_cap_mem_alloc = 2,
       9    omp_const_mem_alloc = 3,
      10    omp_high_bw_mem_alloc = 4,
      11    omp_low_lat_mem_alloc = 5,
      12    omp_cgroup_mem_alloc = 6,
      13    omp_pteam_mem_alloc = 7,
      14    omp_thread_mem_alloc = 8,
      15    __omp_allocator_handle_t_max__ = __UINTPTR_MAX__
      16  } omp_allocator_handle_t;
      17  
      18  int bar (int, int *, int);
      19  omp_allocator_handle_t baz (void);
      20  
      21  void
      22  foo (int x, int z)
      23  {
      24    int y[16] = { 0 }, r = 0, i;
      25    omp_allocator_handle_t h = baz ();
      26    #pragma omp parallel allocate (align (sizeof (int)) : x) allocate (allocator (omp_default_mem_alloc) : y) \
      27  	      allocate (align (8), allocator ((omp_allocator_handle_t) omp_default_mem_alloc):z) firstprivate (x, y, z)
      28    bar (x, y, z);
      29    #pragma omp task private (x) firstprivate (z) allocate (allocator (omp_low_lat_mem_alloc) :x,z)
      30    bar (0, &x, z);
      31    #pragma omp taskwait
      32    #pragma omp target teams distribute parallel for private (x) firstprivate (y) \
      33  	      allocate (allocator ((omp_allocator_handle_t)(omp_default_mem_alloc + 0)), align (16) : z) \
      34  	      allocate (allocator (omp_default_mem_alloc) : x, y) allocate (align (32), allocator (omp_low_lat_mem_alloc): r) \
      35  	      lastprivate (z) reduction(+:r)
      36    for (i = 0; i < 64; i++)
      37      {
      38        z = bar (0, &x, 0);
      39        r += bar (1, y, 0);
      40      }
      41    #pragma omp single private (x) allocate (allocator (h):x)
      42    ;
      43    #pragma omp single allocate (align (2 * sizeof (int)), allocator (*&h) : x) private (x)
      44    ;
      45    #pragma omp parallel shared (r, x, z)
      46    #pragma omp single firstprivate (r) allocate (align (4) : x, r, z) private (x, z)
      47    ;
      48    #pragma omp for allocate (align (2 * 2 * 2) : x) private (x)
      49    for (i = 0; i < 64; i++)
      50      x = 1;
      51    #pragma omp sections private (x) allocate (allocator (omp_low_lat_mem_alloc), align (8): x)
      52    {
      53      x = 1;
      54      #pragma omp section
      55      x = 2;
      56      #pragma omp section
      57      x = 3;
      58    }
      59    #pragma omp taskgroup task_reduction(+:r) allocate (allocator (omp_default_mem_alloc), align (__alignof (r)) : r)
      60    #pragma omp task in_reduction(+:r) allocate (align (2 * sizeof (r)), allocator (omp_default_mem_alloc) : r)
      61    r += bar (r, &r, 0);
      62    #pragma omp teams private (x) firstprivate (y) allocate (allocator (h), align (8) : x, y)
      63    bar (x, y, 0);
      64    #pragma omp taskloop lastprivate (x) reduction (+:r) allocate (align (16), allocator (h) : x, r)
      65    for (i = 0; i < 16; i++)
      66      {
      67        r += bar (0, &r, 0);
      68        x = i;
      69      }
      70    #pragma omp taskgroup task_reduction(+:r) allocate (allocator (omp_default_mem_alloc), align (64) : r)
      71    #pragma omp taskloop firstprivate (x) in_reduction (+:r) \
      72  		       allocate (allocator (omp_default_mem_alloc), align (128) : x, r)
      73    for (i = 0; i < 16; i++)
      74      r += bar (x, &r, 0);
      75    #pragma omp taskwait
      76  }
      77  
      78  void
      79  qux (const omp_allocator_handle_t h)
      80  {
      81    int x = 0;
      82    #pragma omp parallel firstprivate (x) allocate (align (16), allocator (h): x)
      83    x = 1;
      84  }