Hi Thomas,
this version of the wait-clause-with-no-args patch revises the following:

(1) The way the Fortran FE parts are implemented, which essentially is your 
code.
(I'll reflect that in the final ChangeLog)

(2) Instead of trying to encode ACC_ASYNC_NOVAL into num_waits, I've followed
your suggestion to just treat it as a normal async. This means the 
gcc/omp-expand.c
parts in the last patch are discarded.

(3) Things in oacc-parallel.c have been mostly adjusted to only handle the 
wait(ACC_ASYNC_NOVAL)
case inside goacc_wait().

Hope this is now okay for trunk when appropriate.

Thanks,
Chung-Lin
Index: gcc/c/c-parser.c
===================================================================
--- gcc/c/c-parser.c    (revision 267913)
+++ gcc/c/c-parser.c    (working copy)
@@ -13410,7 +13410,7 @@ c_parser_oacc_clause_tile (c_parser *parser, tree
 }
 
 /* OpenACC:
-   wait ( int-expr-list ) */
+   wait [( int-expr-list )] */
 
 static tree
 c_parser_oacc_clause_wait (c_parser *parser, tree list)
@@ -13419,7 +13419,15 @@ c_parser_oacc_clause_wait (c_parser *parser, tree
 
   if (c_parser_peek_token (parser)->type == CPP_OPEN_PAREN)
     list = c_parser_oacc_wait_list (parser, clause_loc, list);
+  else
+    {
+      tree c = build_omp_clause (clause_loc, OMP_CLAUSE_WAIT);
 
+      OMP_CLAUSE_DECL (c) = build_int_cst (integer_type_node, 
GOMP_ASYNC_NOVAL);
+      OMP_CLAUSE_CHAIN (c) = list;
+      list = c;
+    }
+
   return list;
 }
 
Index: gcc/cp/parser.c
===================================================================
--- gcc/cp/parser.c     (revision 267913)
+++ gcc/cp/parser.c     (working copy)
@@ -32815,7 +32815,7 @@ cp_parser_oacc_wait_list (cp_parser *parser, locat
 }
 
 /* OpenACC:
-   wait ( int-expr-list ) */
+   wait [( int-expr-list )] */
 
 static tree
 cp_parser_oacc_clause_wait (cp_parser *parser, tree list)
@@ -32822,10 +32822,16 @@ cp_parser_oacc_clause_wait (cp_parser *parser, tre
 {
   location_t location = cp_lexer_peek_token (parser->lexer)->location;
 
-  if (cp_lexer_peek_token (parser->lexer)->type != CPP_OPEN_PAREN)
-    return list;
+  if (cp_lexer_peek_token (parser->lexer)->type == CPP_OPEN_PAREN)
+    list = cp_parser_oacc_wait_list (parser, location, list);
+  else
+    {
+      tree c = build_omp_clause (location, OMP_CLAUSE_WAIT);
 
-  list = cp_parser_oacc_wait_list (parser, location, list);
+      OMP_CLAUSE_DECL (c) = build_int_cst (integer_type_node, 
GOMP_ASYNC_NOVAL);
+      OMP_CLAUSE_CHAIN (c) = list;
+      list = c;
+    }
 
   return list;
 }
Index: gcc/fortran/openmp.c
===================================================================
--- gcc/fortran/openmp.c        (revision 267913)
+++ gcc/fortran/openmp.c        (working copy)
@@ -1885,7 +1885,19 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const
                  break;
                }
              else if (m == MATCH_NO)
-               needs_space = true;
+               {
+                 gfc_expr *expr
+                   = gfc_get_constant_expr (BT_INTEGER,
+                                            gfc_default_integer_kind,
+                                            &gfc_current_locus);
+                 mpz_set_si (expr->value.integer, GOMP_ASYNC_NOVAL);
+                 gfc_expr_list **expr_list = &c->wait_list;
+                 while (*expr_list)
+                   expr_list = &(*expr_list)->next;
+                 *expr_list = gfc_get_expr_list ();
+                 (*expr_list)->expr = expr;
+                 needs_space = true;
+               }
              continue;
            }
          if ((mask & OMP_CLAUSE_WORKER)
Index: libgomp/oacc-parallel.c
===================================================================
--- libgomp/oacc-parallel.c     (revision 267913)
+++ libgomp/oacc-parallel.c     (working copy)
@@ -206,9 +206,7 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (voi
        case GOMP_LAUNCH_WAIT:
          {
            unsigned num_waits = GOMP_LAUNCH_OP (tag);
-
-           if (num_waits)
-             goacc_wait (async, num_waits, &ap);
+           goacc_wait (async, num_waits, &ap);
            break;
          }
 
@@ -514,13 +512,20 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum,
 static void
 goacc_wait (int async, int num_waits, va_list *ap)
 {
-  struct goacc_thread *thr = goacc_thread ();
-  struct gomp_device_descr *acc_dev = thr->dev;
-
   while (num_waits--)
     {
       int qid = va_arg (*ap, int);
-      
+
+      /* Waiting on ACC_ASYNC_NOVAL maps to 'wait all'.  */
+      if (qid == acc_async_noval)
+       {
+         if (async == acc_async_sync)
+           acc_wait_all ();
+         else
+           acc_wait_all_async (async);
+         break;
+       }
+
       if (acc_async_test (qid))
        continue;
 
@@ -531,7 +536,7 @@ goacc_wait (int async, int num_waits, va_list *ap)
            launching on, the queue itself will order work as
            required, so there's no need to wait explicitly.  */
       else
-       acc_dev->openacc.async_wait_async_func (qid, async);
+       acc_wait_async (qid, async);
     }
 }
 

Reply via email to