https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100753

            Bug ID: 100753
           Summary: Implement in_reduction clause on target construct
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

I think we have two cases.

One is in_reduction clause on synchronous target (i.e. without nowait clause),
I think that is implementable just by calling GOMP_task_reduction_remap on all
map clause addresses that use the in_reduction identifier as base expression
and making sure map clause isn't thrown away for them when the original list
item is declare target to - the in_reduction clause acts as a privatization
clause on the target task.  Plus add map(always, tofrom: item) clause.

The much harder case is target with nowait clause.  Right now task reductions
are implemented by having privatized arrays with one element per thread.  But
for async target the host threads can be doing something else and can update
those private copies.
So I think for nowait in_reduction(...) we need to create new host private
copies for those (initialized with the reduction initializers), map them to
device and when the target task is over, map them back from device and at that
point combine them into the remapped private reduction var.  That will probably
mean a new callback invoked from GOMP_PLUGIN_target_task_completion ?

Reply via email to