Regression: ICE with do concurrent and internal subprogram
Tobias Burnus
tobias.burnus@physik.fu-berlin.de
Tue Jan 7 13:11:00 GMT 2014
Hi Damian,
Damian Rouson wrote:
> Interestingly, the ICE disappears if I switch to a regular do loop
> instead of âdo concurrent.â That surprises me a bit because I
> didnât realize gfortran was doing anything special with âdo concurrentâ
Well, GCC 4.9 gained support for OpenMP 4's "omp simd", which is used for
vectorization. [gfortran still lacks the front-end support of OpenMP 4,
only gcc/g++ current have it.]
To utilize it outside of OpenMP, I added ANNOTATE_EXPR which gets
translated into a vectorization safe length (cf. OpenMP simd safelen=...)
of 'infinity' (INT_MAX). The ANNOTATE_EXPR is used in C/C++ with the new
#pragma ivdep
and in Fortran with DO CONCURRENT. For a description what it does, see
http://gcc.gnu.org/onlinedocs/gcc/Loop-Specific-Pragmas.html
For a Fortran example, see the following link. That loop wouldn't get
vectorized otherwise as the pointers could alias. But with do concurrent,
the user guarantees that it doesn't happen and, hence, the loop can get
vectorized.
http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/testsuite/gfortran.dg/vect/vect-do-concurrent-1.f90?view=co&content-type=text%2Fplain
[Actually, GCC also vectorizes the loop without concurrent, but only via
versioning, i.e. choosing at run time between the vectorized loop and
(with aliasing) a regular loop. Using a nonpointer, nontarget variable in
the loop has the same effect in this case.]
* * *
One could also think of turning DO LOOPS into thread parallelization, e.g.
using OpenMP [or Cilk] internally. But that's currently not yet done.
Tobias
PS: To fine tune vectorization, one can use OpenMP's simd without turning
on thread parallelization via -fopenmp-simd [and -fsimd-cost-model=]. However,
without gfortran FE support, this currently doen't work in Fortran. The
hope was that GCC 4.9 will have also OpenMP 4 support for Fortran, but it
seems to be unlikely that it can be still added before the release.
More information about the Fortran
mailing list