Hi Ilmir,

thanks for the update.

Ilmir Usmanov wrote:
I'd use "integer" instead of "INTEGER" as it is not a 'reserved' word
OpenMP implementation uses capital letters, so, perhaps, we also should do this, for consistency?

Fine with me - I don't feel strong about it.

OpenACC 1.0 support to fortran FE -- core.

--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -2595,6 +2595,33 @@ match_exit_cycle (gfc_statement st, gfc_exec_op op)
    if (cnt > 0
        && o != NULL
        && o->state == COMP_OMP_STRUCTURED_BLOCK
+      && (o->head->op == EXEC_OACC_LOOP
+          || o->head->op == EXEC_OACC_PARALLEL_LOOP))
+    {
+      int collapse = 1;
+      gcc_assert (o->head->next != NULL
+                  && (o->head->next->op == EXEC_DO
+                      || o->head->next->op == EXEC_DO_WHILE)
+                  && o->previous != NULL
+                  && o->previous->tail->op == o->head->op);
+      if (o->previous->tail->ext.omp_clauses != NULL
+          && o->previous->tail->ext.omp_clauses->collapse > 1)
+        collapse = o->previous->tail->ext.omp_clauses->collapse;
+      if (st == ST_EXIT && cnt <= collapse)
+        {
+          gfc_error ("EXIT statement at %C terminating !$ACC LOOP loop");
+          return MATCH_ERROR;
+        }
+      if (st == ST_CYCLE && cnt < collapse)
+        {
+          gfc_error ("CYCLE statement at %C to non-innermost collapsed"
+                     " !$ACC LOOP loop");
+          return MATCH_ERROR;
+        }
+    }

Can you - if you want as follow up patch - also handle the following for both your OpenACC code and for the existing OpenMP code:

!$acc loop
outer_loop: do i = 1, n
   inner_loop: do j = 1,m
      ! ...
      cycle outer_loop
      exit outer_loop
   end do inner_loop
end do outer_loop

That's a new Fortran 2008 feature that CYCLE and EXIT can leave the inner DO loop.


For DO CONCURRENT, that's already handled via the code in "match_exit_cycle". If you want to try the do-concurrent code, replace "inner_loop: do j = 1,m" by "inner_loop: do_concurrent(j=1:m)".


Otherwise, it looks good do me. I don't know whether Thomas has additional comments.

Tobias

Reply via email to