public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Alexander Monakov <amonakov@ispras.ru>
Cc: gcc-patches@gcc.gnu.org, Dmitry Melnik <dm@ispras.ru>
Subject: Re: [gomp4 06/14] omp-low: copy omp_data_o to shared memory on NVPTX
Date: Thu, 26 Nov 2015 09:51:00 -0000	[thread overview]
Message-ID: <20151126095046.GD5675@tucnak.redhat.com> (raw)
In-Reply-To: <20151110103936.GX5675@tucnak.redhat.com>

On Tue, Nov 10, 2015 at 11:39:36AM +0100, Jakub Jelinek wrote:
> On Tue, Nov 03, 2015 at 05:25:53PM +0300, Alexander Monakov wrote:
> > Here's an alternative patch that does not depend on exposure of shared-memory
> > address space, and does not try to use pass_late_lower_omp.  It's based on
> > Bernd's suggestion to transform
> 
> FYI, I've committed a new testcase to gomp-4_5-branch that covers various
> target data sharing/team sharing/privatization parallel
> sharing/privatization offloading cases.

And another testcase, this time using only OpenMP 4.0 features, and trying
to test the behavior of addressable vars in declare target functions where
it is not clear if they are executed in teams, distribute or parallel for
contexts.

Wanted to look what LLVM generates here (tried llvm trunk), but they are
unable to parse #pragma omp distribute or #pragma omp declare target,
so it is hard to guess anything.

Tested with XeonPhi offloading as well as host fallback, committed to trunk.

2015-11-26  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/libgomp.c/target-35.c: New test.

--- libgomp/testsuite/libgomp.c/target-35.c	(revision 0)
+++ libgomp/testsuite/libgomp.c/target-35.c	(working copy)
@@ -0,0 +1,129 @@
+#include <omp.h>
+#include <stdlib.h>
+
+#pragma omp declare target
+__attribute__((noinline))
+void
+foo (int x, int y, int z, int *a, int *b)
+{
+  if (x == 0)
+    {
+      int i, j;
+      for (i = 0; i < 64; i++)
+	#pragma omp parallel for shared (a, b)
+	for (j = 0; j < 32; j++)
+	  foo (3, i, j, a, b);
+    }
+  else if (x == 1)
+    {
+      int i, j;
+      #pragma omp distribute dist_schedule (static, 1)
+      for (i = 0; i < 64; i++)
+	#pragma omp parallel for shared (a, b)
+	for (j = 0; j < 32; j++)
+	  foo (3, i, j, a, b);
+    }
+  else if (x == 2)
+    {
+      int j;
+      #pragma omp parallel for shared (a, b)
+      for (j = 0; j < 32; j++)
+	foo (3, y, j, a, b);
+    }
+  else
+    {
+      #pragma omp atomic
+      b[y] += z;
+      #pragma omp atomic
+      *a += 1;
+    }
+}
+
+__attribute__((noinline))
+int
+bar (int x, int y, int z)
+{
+  int a, b[64], i;
+  a = 8;
+  for (i = 0; i < 64; i++)
+    b[i] = i;
+  foo (x, y, z, &a, b);
+  if (x == 0)
+    {
+      if (a != 8 + 64 * 32)
+	return 1;
+      for (i = 0; i < 64; i++)
+	if (b[i] != i + 31 * 32 / 2)
+	  return 1;
+    }
+  else if (x == 1)
+    {
+      int c = omp_get_num_teams ();
+      int d = omp_get_team_num ();
+      int e = d;
+      int f = 0;
+      for (i = 0; i < 64; i++)
+	if (i == e)
+	  {
+	    if (b[i] != i + 31 * 32 / 2)
+	      return 1;
+	    f++;
+	    e = e + c;
+	  }
+	else if (b[i] != i)
+	  return 1;
+      if (a < 8 || a > 8 + f * 32)
+	return 1;
+    }
+  else if (x == 2)
+    {
+      if (a != 8 + 32)
+	return 1;
+      for (i = 0; i < 64; i++)
+	if (b[i] != i + (i == y ? 31 * 32 / 2 : 0))
+	  return 1;
+    }
+  else if (x == 3)
+    {
+      if (a != 8 + 1)
+	return 1;
+      for (i = 0; i < 64; i++)
+	if (b[i] != i + (i == y ? z : 0))
+	  return 1;
+    }
+  return 0;
+}
+#pragma omp end declare target
+
+int
+main ()
+{
+  int i, j, err = 0;
+  #pragma omp target map(tofrom:err)
+  #pragma omp teams reduction(+:err)
+  err += bar (0, 0, 0);
+  if (err)
+    abort ();
+  #pragma omp target map(tofrom:err)
+  #pragma omp teams reduction(+:err)
+  err += bar (1, 0, 0);
+  if (err)
+    abort ();
+  #pragma omp target map(tofrom:err)
+  #pragma omp teams reduction(+:err)
+  #pragma omp distribute
+  for (i = 0; i < 64; i++)
+    err += bar (2, i, 0);
+  if (err)
+    abort ();
+  #pragma omp target map(tofrom:err)
+  #pragma omp teams reduction(+:err)
+  #pragma omp distribute
+  for (i = 0; i < 64; i++)
+  #pragma omp parallel for reduction(+:err)
+    for (j = 0; j < 32; j++)
+      err += bar (3, i, j);
+  if (err)
+    abort ();
+  return 0;
+}


	Jakub

  reply	other threads:[~2015-11-26  9:50 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20 18:34 [gomp4 00/14] NVPTX: further porting Alexander Monakov
2015-10-20 18:34 ` [gomp4 12/14] libgomp: fixup error.c on nvptx Alexander Monakov
2015-10-21 10:03   ` Jakub Jelinek
2015-10-20 18:34 ` [gomp4 07/14] libgomp nvptx plugin: launch target functions via gomp_nvptx_main Alexander Monakov
2015-10-20 21:12   ` Bernd Schmidt
2015-10-20 21:19     ` Alexander Monakov
2015-10-20 21:27       ` Bernd Schmidt
2015-10-21  9:07         ` Jakub Jelinek
2015-10-20 18:34 ` [gomp4 14/14] libgomp: use more generic implementations on nvptx Alexander Monakov
2015-10-21 10:17   ` Jakub Jelinek
2015-10-20 18:34 ` [gomp4 08/14] libgomp nvptx: populate proc.c Alexander Monakov
2015-10-21  9:15   ` Jakub Jelinek
2015-10-20 18:34 ` [gomp4 06/14] omp-low: copy omp_data_o to shared memory on NVPTX Alexander Monakov
2015-10-21  0:07   ` Bernd Schmidt
2015-10-21  6:49     ` Alexander Monakov
2015-10-21  8:48   ` Jakub Jelinek
2015-10-21  9:09     ` Alexander Monakov
2015-10-21  9:24       ` Jakub Jelinek
2015-10-21 10:42       ` Bernd Schmidt
2015-10-21 14:06         ` Alexander Monakov
2015-11-03 14:25   ` Alexander Monakov
2015-11-06 14:00     ` Bernd Schmidt
2015-11-06 14:06       ` Jakub Jelinek
2015-11-10 10:39     ` Jakub Jelinek
2015-11-26  9:51       ` Jakub Jelinek [this message]
2015-10-20 18:34 ` [gomp4 11/14] libgomp: avoid variable-length stack allocation in team.c Alexander Monakov
2015-10-20 20:48   ` Bernd Schmidt
2015-10-20 21:41     ` Alexander Monakov
2015-10-20 21:46       ` Bernd Schmidt
2015-10-21  9:59   ` Jakub Jelinek
2015-10-20 18:34 ` [gomp4 05/14] omp-low: set 'omp target entrypoint' only on entypoints Alexander Monakov
2015-10-20 23:57   ` Bernd Schmidt
2015-10-21  8:20   ` Jakub Jelinek
2015-10-30 16:58     ` Alexander Monakov
2015-11-06 14:05       ` Bernd Schmidt
2015-11-06 14:08         ` Jakub Jelinek
2015-11-06 14:12           ` Bernd Schmidt
2015-11-06 17:16         ` Alexander Monakov
2015-10-20 18:34 ` [gomp4 03/14] nvptx: expand support for address spaces Alexander Monakov
2015-10-20 20:56   ` Bernd Schmidt
2015-10-20 21:06     ` Alexander Monakov
2015-10-20 21:13       ` Bernd Schmidt
2015-10-20 21:41         ` Cesar Philippidis
2015-10-20 21:51           ` Bernd Schmidt
2015-10-20 18:34 ` [gomp4 04/14] nvptx: fix output of _Bool global variables Alexander Monakov
2015-10-20 20:51   ` Bernd Schmidt
2015-10-20 21:04     ` Alexander Monakov
2015-10-28 16:56       ` Alexander Monakov
2015-10-28 17:01         ` Bernd Schmidt
2015-10-28 17:38           ` Alexander Monakov
2015-10-28 17:39             ` Bernd Schmidt
2015-10-28 17:51               ` Alexander Monakov
2015-10-28 18:06                 ` Bernd Schmidt
2015-10-28 18:07                   ` Alexander Monakov
2015-10-28 18:33                     ` Bernd Schmidt
2015-10-28 19:37                       ` Alexander Monakov
2015-10-29 11:13                         ` Bernd Schmidt
2015-10-30 13:27                           ` Alexander Monakov
2015-10-30 13:38                             ` Bernd Schmidt
2015-10-20 18:34 ` [gomp4 01/14] nvptx: emit kernels for 'omp target entrypoint' only for OpenACC Alexander Monakov
2015-10-20 23:48   ` Bernd Schmidt
2015-10-21  5:40     ` Alexander Monakov
2015-10-21  8:11   ` Jakub Jelinek
2015-10-21  8:36     ` Alexander Monakov
2015-10-20 18:52 ` [gomp4 13/14] libgomp: provide minimal GOMP_teams Alexander Monakov
2015-10-21 10:12   ` Jakub Jelinek
2015-10-20 18:52 ` [gomp4 10/14] libgomp: arrange a team of pre-started threads via gomp_nvptx_main Alexander Monakov
2015-10-21  9:49   ` Jakub Jelinek
2015-10-21 14:41     ` Alexander Monakov
2015-10-21 15:02       ` Jakub Jelinek
2015-10-20 18:53 ` [gomp4 09/14] libgomp: provide barriers on NVPTX Alexander Monakov
2015-10-20 20:56   ` Bernd Schmidt
2015-10-20 22:00     ` Alexander Monakov
2015-10-21  2:23       ` Bernd Schmidt
2015-10-21  9:39   ` Jakub Jelinek
2015-10-20 19:01 ` [gomp4 02/14] nvptx: emit pointers to OpenMP target region entry points Alexander Monakov
2015-10-21  7:55 ` [gomp4 00/14] NVPTX: further porting Martin Jambor
2015-10-21  8:56 ` Jakub Jelinek
2015-10-21  9:17   ` Alexander Monakov
2015-10-21  9:29     ` Jakub Jelinek
2015-10-28 17:22       ` Alexander Monakov
2015-10-29  8:54         ` Jakub Jelinek
2015-10-29 11:38           ` Alexander Monakov
2015-10-21 12:06 ` Bernd Schmidt
2015-10-21 15:48   ` Alexander Monakov
2015-10-21 16:10     ` Bernd Schmidt
2015-10-22  9:55     ` Jakub Jelinek
2015-10-22 16:42       ` Alexander Monakov
2015-10-22 17:16         ` Julian Brown
2015-10-22 18:19           ` Alexander Monakov
2015-10-22 17:17         ` Bernd Schmidt
2015-10-22 18:10           ` Alexander Monakov
2015-10-22 18:27             ` Bernd Schmidt
2015-10-22 19:28               ` Alexander Monakov
2015-10-23  8:23           ` Jakub Jelinek
2015-10-23  8:25           ` Jakub Jelinek
2015-10-23 10:24           ` Jakub Jelinek
2015-10-23 10:48             ` Bernd Schmidt
2015-10-23 17:36             ` Alexander Monakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151126095046.GD5675@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=amonakov@ispras.ru \
    --cc=dm@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).