aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c/usm-4.c
blob: 1ac5498f73f9f50fbd43ad896c06637eb9451ad4 (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
/* { dg-do run } */
/* { dg-require-effective-target omp_usm } */

#include <omp.h>
#include <stdint.h>

int
main ()
{
  int *a = (int *) omp_alloc(sizeof(int)*2, ompx_unified_shared_mem_alloc);
  if (!a)
    __builtin_abort ();

  a[0] = 42;
  a[1] = 43;

  uintptr_t a_p = (uintptr_t)a;

#pragma omp target enter data map(to:a[0:2])

#pragma omp target
    {
      if (a[0] != 42 || a_p != (uintptr_t)a)
	__builtin_abort ();
    }

#pragma omp target
    {
      if (a[1] != 43 || a_p != (uintptr_t)a)
	__builtin_abort ();
    }

#pragma omp target exit data map(delete:a[0:2])

  omp_free(a, ompx_unified_shared_mem_alloc);
  return 0;
}