[gomp4.5] Handle #pragma omp declare target link
Thomas Schwinge
thomas@codesourcery.com
Wed Jun 26 16:23:00 GMT 2019
Hi!
On Mon, 14 Dec 2015 20:17:33 +0300, Ilya Verbin <iverbin@gmail.com> wrote:
> Here is an updated patch [for "#pragma omp declare target link"]
..., that got committed long ago (trunk r231655), with additional changes
later on.
As has later been filed in PR81689, the test case added
"libgomp.c/target-link-1.c fails for nvptx: #pragma omp target link not
implemented". Curious, has anybody ever looked into what's going
on/wrong?
Grüße
Thomas
> --- /dev/null
> +++ b/libgomp/testsuite/libgomp.c/target-link-1.c
> @@ -0,0 +1,63 @@
> +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;
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 658 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20190626/e42df920/attachment.sig>
More information about the Gcc-patches
mailing list