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

            Bug ID: 100669
           Summary: [OpenACC] ICE with array-reduction variable & related
                    issues
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, openacc
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: tschwinge at gcc dot gnu.org
  Target Milestone: ---

While OpenMP supports  reduction(+: sum[:10]) [→ PR99928 comment 8],
it is not quite clear to me whether OpenACC supports it.
(Admittedly, I also have not verified it in the OpenACC spec, yet).

I did not find any OpenACC testcase related to array reduction or struct
element/derived-type component reductions.


In any case, in C/C++, using an array gives the following ICE:

# gcc-trunk -fopenacc -fdump-tree-original foo.c

foo.c: In function ‘foo’:
foo.c:6:11: internal compiler error: tree check: expected tree that contains
‘decl minimal’ structure, have ‘mem_ref’ in splay_tree_compare_decl_uid, at
gimplify.c:440
    6 |   #pragma acc parallel loop reduction(+:sum)
      |           ^~~

0x788f2f tree_contains_struct_check_failed(tree_node const*,
tree_node_structure_enum, char const*, int, char const*)
        ../../repos/gcc/gcc/tree.c:8857


 * * *

On the Fortran side,  reduction(+: array) is permitted for OpenACC during
parsing
but fails during resolution time with:

  Error: Array ‘sum’ is not permitted in reduction at (1)

I also note that for a derived type, there is the odd result:

   46 |   !$acc parallel loop reduction(+:x%sum3)
      |                                  1
  Error: !$OMP DECLARE REDUCTION + not found for type TYPE(t) at (1)

with 'type t; integer :: sum3; end type'.

Namely: the error is a bit odd as the reduction variable is 'integer' which
does not need declare reduction – while the error talks about the derived type
itself ('x')

Question: Is it expected that 'x%...' should be parsed (accepted) with OpenACC?
With OpenMP it fails at parse time with:

   38 |   !$omp parallel do reduction(+:x%sum3)
      |                                  1
   Error: Syntax error in OpenMP variable list at (1)


NOTE: I have not checked what happens on the C/C++ side with struct elements.

Reply via email to