* [gomp4] Initialize some extra variables at the entry to an OpenACC offloaded region
@ 2015-05-29 17:20 Bernd Schmidt
0 siblings, 0 replies; only message in thread
From: Bernd Schmidt @ 2015-05-29 17:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
[-- 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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-05-29 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29 17:20 [gomp4] Initialize some extra variables at the entry to an OpenACC offloaded region Bernd Schmidt
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).