Hi Thomas,

> the attached patch fixes the PR by removing common function elimination
> in FORALL statements.

I think that part is OK. However, you do more - you also avoid the handling
for DO CONCURRENT.

However, I do not see why it could fail for DO CONCURRENT or rather: I do
not see a case where it would be possible to fail for DO CONCURRENT but
still work for a "normal" DO loop.

In case of the FORALL "assignment", the RHS needs to be evaluated before
the LHS and thus the compiler needs to insert temporaries if needed. That
will potentially also lead to wrong code if there is an interdependence
and one adds some other temporary variable. Additionally, essentially only
assignment is allowed in the FORALL body. The idea was to allow parallel
execution but due to the requirement to evalute first the RHS, parallel
executions are in the general case not possible and the compiler needs to
insert temporaries if it is unsure about the interdependence.

That different to the DO CONTIGUOUS construct. Here, one has essentially
a normal loop, where one may, for instance, allocate variables, do I/O etc.
The only thing *the programmer* guarantees is that the result remains the
same independent which order the loop is executed. (There are a few
constrains to avoid some obvious constraint violations.) Hence, the
compiler could parallelize the loop without doing further analysis.
(That's currently not done - for the ME it is a normal loop. One could
either give hints to the ME - for which one either needs to code something
or wait/port some patch from the CILK++ branch. Or one could insert OMP
statements.)

However, in terms of the front-end optimization, I do not see how that's
different to a normal loop: Also a normal loop can be parallelized using
OpenMP or different means and thus run out of order and the statements
which are allowed in a loop are essentially the same.

In conclusion: I am fine with the FORALL part, but not with the
DO CONCURRENT part.

Tobias

--- frontend-passes.c   (Revision 179709)
+++ frontend-passes.c
...
            case EXEC_FORALL:
            case EXEC_DO_CONCURRENT:
              {
                gfc_forall_iterator *fa;
                for (fa = co->ext.forall_iterator; fa; fa = fa->next)
                  {
                    WALK_SUBEXPR (fa->var);
                    WALK_SUBEXPR (fa->start);
                    WALK_SUBEXPR (fa->end);
                    WALK_SUBEXPR (fa->stride);
                  }
+               forall_level ++;
                break;
              }


Reply via email to