brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · fd5498f Raw
54 lines · cpp
1// RUN: %libomptarget-compilexx-run-and-check-aarch64-unknown-linux-gnu2// RUN: %libomptarget-compilexx-run-and-check-powerpc64-ibm-linux-gnu3// RUN: %libomptarget-compilexx-run-and-check-powerpc64le-ibm-linux-gnu4// RUN: %libomptarget-compilexx-run-and-check-x86_64-unknown-linux-gnu5// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda6 7#include <cstdio>8#include <cstdlib>9 10typedef struct {11  short *a;12  long d1, d2;13} DV_A;14 15typedef struct {16  DV_A b;17  long d3;18} C;19 20typedef struct {21  C *c;22  long d4, d5;23} DV_B;24 25int main() {26 27  short arr1[10] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};28  short arr2[10] = {20, 31, 22, 23, 24, 25, 26, 27, 28, 29};29 30  C c1[2];31  c1[0].b.a = (short *)arr1;32  c1[1].b.a = (short *)arr2;33  c1[0].b.d1 = 111;34 35  DV_B dvb1;36  dvb1.c = (C *)&c1;37 38  // CHECK: 10 11139  printf("%d %ld %p %p %p %p\n", dvb1.c[0].b.a[0], dvb1.c[0].b.d1, &dvb1,40         &dvb1.c[0], &dvb1.c[0].b, &dvb1.c[0].b.a[0]);41#pragma omp target map(to : dvb1, dvb1.c[0 : 2])                               \42    map(tofrom : dvb1.c[0].b.a[0 : 10], dvb1.c[1].b.a[0 : 10])43  {44    // CHECK: 10 11145    printf("%d %ld %p %p %p %p\n", dvb1.c[0].b.a[0], dvb1.c[0].b.d1, &dvb1,46           &dvb1.c[0], &dvb1.c[0].b, &dvb1.c[0].b.a[0]);47    dvb1.c[0].b.a[0] = 333;48    dvb1.c[0].b.d1 = 444;49  }50  // CHECK: 333 11151  printf("%d %ld %p %p %p %p\n", dvb1.c[0].b.a[0], dvb1.c[0].b.d1, &dvb1,52         &dvb1.c[0], &dvb1.c[0].b, &dvb1.c[0].b.a[0]);53}54