[OG10] [committed 0/2]

Sandra Loosemore sandra@codesourcery.com
Sun Aug 30 19:46:09 GMT 2020


This set of patches addresses some deficiencies in the way the OpenACC
kernels loop annotator parses the loop end test in C/C++ "for" loops
to ensure the loop bound can safely be hoisted outside of the loop.
The Fortran front end does not have these problems because the normal
semantics of DO loops is already to evaluate the loop bound only once.

The problem addressed by the first patch is that the C/C++ front ends
sometimes end up reversing the sense of the comparison, so that (for
instance) in a comparison involving two local variables, it was
mis-identifying the loop variable and loop bound.  This is solved by
rearranging the code to find the loop variable from the initializer
first.

The second patch generalizes the test for hoist-ability of the loop
bound expression to allow not just constants and loop-invariant local
variables, but also most expressions involving only constants and
loop-invariant local variables, including calls to functions with
constant semantics.  We could do a better job of this later in the
compilation process when we have dataflow and alias information
available, but at present, the compilation of "acc loop" constructs
simply assumes that the loop bound is always hoistable even when the
"auto" or "seq" clauses are present.  So the annotator needs to be
conservatively correct rather than rely on such problems being
diagnosed later.

There is no one available to review patches to the kernels loop
annotator at present so I have committed this to the OG10 branch.
When this functionality is resubmitted for mainline, a proper review
will be required.

-Sandra

Sandra Loosemore (2):
  Clean up loop variable extraction in OpenACC kernels loop annotation.
  Relax some restrictions on the loop bound in kernels loop annotation.

 gcc/c-family/ChangeLog.omp                         |  12 +
 gcc/c-family/c-omp.c                               | 306 ++++++++++++++-------
 gcc/testsuite/ChangeLog.omp                        |   5 +
 .../goacc/kernels-loop-annotation-21.c             |  42 +++
 .../goacc/kernels-loop-annotation-22.c             |  41 +++
 5 files changed, 304 insertions(+), 102 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-loop-annotation-21.c
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-loop-annotation-22.c

-- 
2.8.1



More information about the Gcc-patches mailing list