2017-04-10 11:32:00 +00:00
|
|
|
extern void abort (void);
|
2022-10-27 18:55:19 +00:00
|
|
|
struct S { int e, f; };
|
2017-04-10 11:32:00 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
foo (int n)
|
|
|
|
{
|
2022-10-27 18:55:19 +00:00
|
|
|
int a[4] = { 0, 1, 2, 3 }, b[n], c = 4;
|
|
|
|
struct S d = { 5, 6 };
|
2017-04-10 11:32:00 +00:00
|
|
|
int *p = a + 1, i, err;
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
b[i] = 9 + i;
|
|
|
|
#pragma omp target data map(to:a)
|
|
|
|
#pragma omp target data use_device_ptr(p) map(from:err)
|
|
|
|
#pragma omp target is_device_ptr(p) private(i) map(from:err)
|
|
|
|
{
|
|
|
|
err = 0;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (p[i - 1] != i)
|
|
|
|
err = 1;
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
abort ();
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
a[i] = 23 + i;
|
|
|
|
#pragma omp target data map(to:a)
|
2022-10-27 18:55:19 +00:00
|
|
|
#pragma omp target data use_device_addr(a) map(from:err)
|
2017-04-10 11:32:00 +00:00
|
|
|
#pragma omp target is_device_ptr(a) private(i) map(from:err)
|
|
|
|
{
|
|
|
|
err = 0;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (a[i] != 23 + i)
|
|
|
|
err = 1;
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
abort ();
|
|
|
|
#pragma omp target data map(to:b)
|
2022-10-27 18:55:19 +00:00
|
|
|
#pragma omp target data use_device_addr(b) map(from:err)
|
2017-04-10 11:32:00 +00:00
|
|
|
#pragma omp target is_device_ptr(b) private(i) map(from:err)
|
|
|
|
{
|
|
|
|
err = 0;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
if (b[i] != 9 + i)
|
|
|
|
err = 1;
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
abort ();
|
2022-10-27 18:55:19 +00:00
|
|
|
#pragma omp target data map(to:c)
|
|
|
|
#pragma omp target data use_device_addr(c) map(from:err)
|
|
|
|
{
|
|
|
|
int *q = &c;
|
|
|
|
#pragma omp target is_device_ptr(q) map(from:err)
|
|
|
|
{
|
|
|
|
err = *q != 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
abort ();
|
|
|
|
#pragma omp target data map(to:d)
|
|
|
|
#pragma omp target data use_device_addr(d) map(from:err)
|
|
|
|
{
|
|
|
|
struct S *r = &d;
|
|
|
|
#pragma omp target is_device_ptr(r) map(from:err)
|
|
|
|
{
|
|
|
|
err = r->e != 5 || r->f != 6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (err)
|
|
|
|
abort ();
|
2017-04-10 11:32:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main ()
|
|
|
|
{
|
|
|
|
foo (9);
|
|
|
|
return 0;
|
|
|
|
}
|