aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.c-c++-common/struct-elem-1.c
blob: 5f40fd7830c59f837e22aa4b9a8772415eba227d (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
#include <omp.h>
#include <stdlib.h>

struct S
{
  int a, b;
};
typedef struct S S;

int main (void)
{
  int d = omp_get_default_device ();
  int id = omp_get_initial_device ();

  if (d < 0 || d >= omp_get_num_devices ())
    d = id;

  S s;
  #pragma omp target enter data map (alloc: s.a, s.b)
  #pragma omp target exit data map (release: s.b)

  /* OpenMP 5.0 structure element mapping rules describe that elements of same
     structure variable should allocate/deallocate in a uniform fashion, so
     "s.a" should be removed together by above 'exit data'.  */
  if (d != id && omp_target_is_present (&s.a, d))
    abort ();

  return 0;
}