This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Re: OpenACC middle end changes
- From: Cesar Philippidis <cesar_philippidis at mentor dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, Thomas Schwinge <thomas at codesourcery dot com>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 Nov 2014 11:03:47 -0800
- Subject: Re: Re: OpenACC middle end changes
- Authentication-results: sourceware.org; auth=none
- References: <20141113180949 dot GX5026 at tucnak dot redhat dot com>
I'll try to respond to the reduction stuff. It's been a while since I
started working on it, so I may have lost some state.
On 11/13/2014 10:09 AM, Jakub Jelinek wrote:
>> @@ -233,6 +242,90 @@ static tree scan_omp_1_op (tree *, int *, void *);
>> *handled_ops_p = false; \
>> break;
>>
>> +/* Helper function to get the reduction array name */
>> +static const char *
>> +omp_get_id (tree node)
>
> Be more specific in the function name what it is for?
It's the name of the array containing the partial reductions for
original reduction variable.
>> +{
>> + const char *id = IDENTIFIER_POINTER (DECL_NAME (node));
>> + int len = strlen ("omp$") + strlen (id);
>> + char *temp_name = (char *)alloca (len+1);
>> + snprintf (temp_name, len+1, "gfc$%s", id);
>
> gfc$ ?
It's just a semi-random prefix I used to make the partial reduction
array identifier unique to aid with debugging. I was working on the
fortran front end at the time. Maybe s/gfc/oacc/?
> Use
> char *temp_name = XALLOCAVEC (char, len + 1);
> instead?
>
>> + return IDENTIFIER_POINTER(get_identifier (temp_name));
>
> Formatting (missing space before ( ).
>
>> @@ -868,6 +981,25 @@ maybe_lookup_field (tree var, omp_context *ctx)
>> return n ? (tree) n->value : NULL_TREE;
>> }
>>
>> +static inline tree
>> +lookup_reduction (const char *id, omp_context *ctx)
>
> Can't you use oacc_ in the name of OpenACC specific functions?
Sure.
[snip]
>> @@ -8834,6 +9492,397 @@ make_pass_expand_omp (gcc::context *ctxt)
>>
>> /* Routines to lower OpenMP directives into OMP-GIMPLE. */
>>
>> +/* Helper function to preform, potentially COMPLEX_TYPE, operation and
>> + convert it to gimple. */
>> +static void
>> +omp_gimple_assign_with_ops (tree_code op, tree dest, tree src, gimple_seq *seq)
>
> Makes me wonder why don't you put the reduction code earlier into reduction
> clause GENERIC and then lower into clauses' GIMPLE seq.
> If there is some reason, please name it oacc at least.
I probably was trying to reuse as much of the existing code as possible.
I've swapped out too much state on this. This can be renamed too.
>> +static void
>> +initialize_reduction_data (tree clauses, tree nthreads, gimple_seq *stmt_seqp,
>> + omp_context *ctx)
>
> Likewise.
>
>> +/* Helper function to process the array of partial reductions. Nthreads
>> + indicates the number of threads. Unfortunately, GOACC_GET_NUM_THREADS
>> + cannot be used here, because nthreads on the host may be different than
>> + on the accelerator. */
>> +
>> +static void
>> +finalize_reduction_data (tree clauses, tree nthreads, gimple_seq *stmt_seqp,
>> + omp_context *ctx)
>
> Likewise.
>
>> +/* Scan through all of the gimple stmts searching for an OMP_FOR_EXPR, and
>> + scan that for reductions. */
>> +
>> +static void
>> +process_reduction_data (gimple_seq *body, gimple_seq *in_stmt_seqp,
>> + gimple_seq *out_stmt_seqp, omp_context *ctx)
>
> Likewise.
Thomas, would you like me to handle the renaming, or will you? I could
make those changes to gomp-4_0-branch if you like.
Cesar