On 04/05/2017 01:22 PM, Thomas Schwinge wrote:
>> --- a/gcc/gimplify.c
>> +++ b/gcc/gimplify.c
>> @@ -6102,14 +6102,19 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx,
>> tree decl, unsigned flags)
>> {
>> const char *rkind;
>> bool on_device = false;
>> + bool is_private = false;
>
> So the intention here is that by default everything stays the same as
> before; "is_private == false". This property is satisfied in the
> following code.
Yes.
>> tree type = TREE_TYPE (decl);
>>
>> if (lang_hooks.decls.omp_privatize_by_reference (decl))
>> type = TREE_TYPE (type);
>>
>> + if (RECORD_OR_UNION_TYPE_P (type))
>> + is_private = lang_hooks.decls.omp_disregard_value_expr (decl, false);
>> +
>> if ((ctx->region_type & (ORT_ACC_PARALLEL | ORT_ACC_KERNELS)) != 0
>> && is_global_var (decl)
>> - && device_resident_p (decl))
>> + && device_resident_p (decl)
>> + && !is_private)
>> {
>> on_device = true;
>> flags |= GOVD_MAP_TO_ONLY;
> | }
>
> For "is_private == true" we will not possibly enter this block.
>
> | [ORT_ACC_KERNELS]
>> /* Scalars are default 'copy' under kernels, non-scalars are default
>> 'present_or_copy'. */
>> flags |= GOVD_MAP;
>> - if (!AGGREGATE_TYPE_P (type))
>> + if (!AGGREGATE_TYPE_P (type) && !is_private)
>> flags |= GOVD_MAP_FORCE;
>
> For "is_private == true" we will not possibly enter this block, which
> means in this case we will map both scalars and aggregates as
> "present_or_copy".
Yes. Inside kernels regions, everything is pcopy, unless it's private.
Some private variables include, e.g., fortran array descriptors.
>> case ORT_ACC_PARALLEL:
>> {
>> - if (on_device || AGGREGATE_TYPE_P (type))
>> + if (!is_private && (on_device || AGGREGATE_TYPE_P (type)))
>> /* Aggregates default to 'present_or_copy'. */
>> flags |= GOVD_MAP;
>> else
> | /* Scalars default to 'firstprivate'. */
> | flags |= GOVD_FIRSTPRIVATE;
>
> For "is_private == true" we will not possibly enter the "if" block, so we
> will always enter the "else" block, which means in this case we will map
> both scalars and aggregates as "firstprivate".
>
> Is that all correct?
Yes. Is there something wrong with that behavior or is it just unclear?
Cesar