This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: openacc reference reductions


On Fri, Apr 08, 2016 at 07:14:13AM -0700, Nathan Sidwell wrote:
> On 04/08/16 00:40, Jakub Jelinek wrote:
> 
> >>+/* OpenACC parallel reductions need a present_or_copy clause to ensure
> >>+   that the original variable used in the reduction gets updated on
> >>+   the host.  Scan the list of clauses for reduction so that any existing
> >>+   data clause can be adjusted if necessary.  */
> >>+  if (region_type == ORT_ACC_PARALLEL)
> >>+    {
> >>+      for (c = *list_p; c; c = OMP_CLAUSE_CHAIN (c))
> >>+	{
> >>+	  tree decl = NULL_TREE;
> >>+
> >>+	  if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_REDUCTION)
> >>+	    continue;
> >>+
> >>+	  decl = OMP_CLAUSE_DECL (c);
> >>+	  omp_add_variable (ctx, decl, GOVD_REDUCTION);
> >>+	}
> >>+    }
> >>+
> >
> >And this looks also wrong, why?
> 
> And besides, won't it break
> #pragma acc parallel firstprivate (x)  reduction(+:x)
> {...}
> 
> which the openacc guys at GTC indicated they didn't want to disallow
> (without further thinking).

Well, given that this patchset is supposed to fix one of the last few P1
blockers, I think we shouldn't be changing the FEs now to allow the above,
just get working what is already allowed, and defer the rest for GCC 7.

Yes, acc reductions are just very weird and to me they look insufficiently
well defined.  In OpenMP, reduction is a data sharing clause like
private/firstprivate etc., so one can use either private, or firstprivate,
or reduction, but not multiple of them on the same decl; the exception is
firstprivate and lastprivate on the same decl is allowed.  Furthermore,
reduction is not allowed at all on target construct, it can be only on
teams, parallel, for, simd, sections constructs, so the data sharing or
mapping on target is orthogonal on if you reduce on the inner constructs or
not.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]