public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Schmidt <bernds@codesourcery.com>
To: <gcc-patches@gnu.org>
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [gomp4] Initialize some extra variables at the entry to an OpenACC offloaded region
Date: Fri, 29 May 2015 17:20:00 -0000	[thread overview]
Message-ID: <55689592.6000203@codesourcery.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 212 bytes --]

This initializes worker count and worker id variables; these will be 
used in a followup patch to allocate arrays in gang-local memory to be 
used for synchronizing threads. Committed to gomp-4_0-branch.


Bernd

[-- Attachment #2: initvars.diff --]
[-- Type: text/x-patch, Size: 2677 bytes --]

Index: gcc/ChangeLog.gomp
===================================================================
--- gcc/ChangeLog.gomp	(revision 223870)
+++ gcc/ChangeLog.gomp	(working copy)
@@ -1,5 +1,10 @@
 2015-05-29  Bernd Schmidt  <bernds@codesourcery.com>
 
+	* omp-low.c (struct omp_context): Add worker_var and worker_count
+	fields.
+	(oacc_init_count_vars): New function.
+	(lower_omp_target): Call it.
+
 	* config/nvptx/nvptx.md (UNSPECV_BARSYNC): New constant.
 	(oacc_threadbarrier): New expander.
 	(threadbarrier_insn): New pattern.
Index: gcc/omp-low.c
===================================================================
--- gcc/omp-low.c	(revision 223869)
+++ gcc/omp-low.c	(working copy)
@@ -243,6 +243,11 @@ typedef struct omp_context
   tree ganglocal_ptr;
   tree ganglocal_size;
   tree ganglocal_size_host;
+
+  /* For OpenACC offloaded regions, variables holding the worker id and count
+     of workers.  */
+  tree worker_var;
+  tree worker_count;
 } omp_context;
 
 /* A structure holding the elements of:
@@ -12300,6 +12305,35 @@ lower_omp_taskreg (gimple_stmt_iterator
     }
 }
 
+/* A subroutine of lower_omp_target.  Build variables holding the
+   worker count and index for use inside in ganglocal memory allocations.  */
+
+static void
+oacc_init_count_vars (omp_context *ctx, tree clauses ATTRIBUTE_UNUSED)
+{
+  tree gettid = builtin_decl_explicit (BUILT_IN_GOACC_TID);
+  tree getntid = builtin_decl_explicit (BUILT_IN_GOACC_NTID);
+  tree worker_var, worker_count;
+  tree u1 = fold_convert (unsigned_type_node, integer_one_node);
+  tree u0 = fold_convert (unsigned_type_node, integer_zero_node);
+  if (ctx->gwv_this & MASK_WORKER)
+    {
+      worker_var = create_tmp_var (unsigned_type_node, ".worker");
+      worker_count = create_tmp_var (unsigned_type_node, ".workercount");
+      gimple call1 = gimple_build_call (gettid, 1, u1);
+      gimple_call_set_lhs (call1, worker_var);
+      gimple_seq_add_stmt (&ctx->ganglocal_init, call1);
+      gimple call2 = gimple_build_call (getntid, 1, u1);
+      gimple_call_set_lhs (call2, worker_count);
+      gimple_seq_add_stmt (&ctx->ganglocal_init, call2);
+    }
+  else
+    worker_var = u0, worker_count = u1;
+
+  ctx->worker_var = worker_var;
+  ctx->worker_count = worker_count;
+}
+
 /* Lower the GIMPLE_OMP_TARGET in the current statement
    in GSI_P.  CTX holds context information for the directive.  */
 
@@ -12465,6 +12499,9 @@ lower_omp_target (gimple_stmt_iterator *
   irlist = NULL;
   orlist = NULL;
 
+  if (is_gimple_omp_oacc (stmt))
+    oacc_init_count_vars (ctx, clauses);
+
   if (has_reduction)
     {
       lower_rec_input_clauses (clauses, &irlist, &orlist, ctx, NULL);

                 reply	other threads:[~2015-05-29 16:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=55689592.6000203@codesourcery.com \
    --to=bernds@codesourcery.com \
    --cc=gcc-patches@gnu.org \
    --cc=jakub@redhat.com \
    /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).