c2211a60ff
PR libgomp/81689 * lto.c (offload_handle_link_vars): Propagate TREE_PUBLIC state. PR libgomp/81689 * omp-offload.c (omp_finish_file): Fix target-link handling if targetm_common.have_named_sections is false. PR libgomp/81689 * testsuite/libgomp.c/target-link-1.c: Remove xfail.
64 lines
1.1 KiB
C
64 lines
1.1 KiB
C
struct S { int s, t; };
|
|
|
|
int a = 1, b = 1;
|
|
double c[27];
|
|
struct S d = { 8888, 8888 };
|
|
#pragma omp declare target link (a) to (b) link (c, d)
|
|
|
|
int
|
|
foo (void)
|
|
{
|
|
return a++ + b++;
|
|
}
|
|
|
|
int
|
|
bar (int n)
|
|
{
|
|
int *p1 = &a;
|
|
int *p2 = &b;
|
|
c[n] += 2.0;
|
|
d.s -= 2;
|
|
d.t -= 2;
|
|
return *p1 + *p2 + d.s + d.t;
|
|
}
|
|
|
|
#pragma omp declare target (foo, bar)
|
|
|
|
int
|
|
main ()
|
|
{
|
|
a = b = 2;
|
|
d.s = 17;
|
|
d.t = 18;
|
|
|
|
int res, n = 10;
|
|
#pragma omp target map (to: a, b, c, d) map (from: res)
|
|
{
|
|
res = foo () + foo ();
|
|
c[n] = 3.0;
|
|
res += bar (n);
|
|
}
|
|
|
|
int shared_mem = 0;
|
|
#pragma omp target map (alloc: shared_mem)
|
|
shared_mem = 1;
|
|
|
|
if ((shared_mem && res != (2 + 2) + (3 + 3) + (4 + 4 + 15 + 16))
|
|
|| (!shared_mem && res != (2 + 1) + (3 + 2) + (4 + 3 + 15 + 16)))
|
|
__builtin_abort ();
|
|
|
|
#pragma omp target enter data map (to: c)
|
|
#pragma omp target update from (c)
|
|
res = (int) (c[n] + 0.5);
|
|
if ((shared_mem && res != 5) || (!shared_mem && res != 0))
|
|
__builtin_abort ();
|
|
|
|
#pragma omp target map (to: a, b) map (from: res)
|
|
res = foo ();
|
|
|
|
if ((shared_mem && res != 4 + 4) || (!shared_mem && res != 2 + 3))
|
|
__builtin_abort ();
|
|
|
|
return 0;
|
|
}
|