[PR fortran/63865] OpenACC cache directive: match Fortran support with C/C++
authorThomas Schwinge <thomas@codesourcery.com>
Tue, 27 Oct 2015 16:54:52 +0000 (17:54 +0100)
committerThomas Schwinge <tschwinge@gcc.gnu.org>
Tue, 27 Oct 2015 16:54:52 +0000 (17:54 +0100)
gcc/fortran/
PR fortran/63865
* openmp.c (resolve_oacc_cache): Remove function.
(gfc_match_oacc_cache): Enable array sections.
(resolve_omp_clauses, gfc_resolve_oacc_directive): Change
accordingly.
* trans-openmp.c (gfc_trans_omp_clauses): Likewise.
gcc/testsuite/
PR fortran/63865
* gfortran.dg/goacc/coarray.f95: Expect the OpenACC cache
directive to work.
* gfortran.dg/goacc/loop-1.f95: Likewise.
* gfortran.dg/goacc/cache-1.f95: Likewise, and extend testing.
* gfortran.dg/goacc/cray.f95: Likewise.
* gfortran.dg/goacc/parameter.f95: Likewise.

Co-Authored-By: James Norris <jnorris@codesourcery.com>
From-SVN: r229448

gcc/fortran/ChangeLog
gcc/fortran/openmp.c
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/cache-1.f95
gcc/testsuite/gfortran.dg/goacc/coarray.f95
gcc/testsuite/gfortran.dg/goacc/cray.f95
gcc/testsuite/gfortran.dg/goacc/loop-1.f95
gcc/testsuite/gfortran.dg/goacc/parameter.f95

index 37956ce444a567ef81c9db1384cbeff1b469c0a7..02564cebeab8d3501024d8991135cc2997fd4e13 100644 (file)
@@ -1,3 +1,13 @@
+2015-10-27  Thomas Schwinge  <thomas@codesourcery.com>
+           James Norris  <jnorris@codesourcery.com>
+
+       PR fortran/63865
+       * openmp.c (resolve_oacc_cache): Remove function.
+       (gfc_match_oacc_cache): Enable array sections.
+       (resolve_omp_clauses, gfc_resolve_oacc_directive): Change
+       accordingly.
+       * trans-openmp.c (gfc_trans_omp_clauses): Likewise.
+
 2015-10-27  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/68108
index 3c12d8e67f6cef3a70f3b4e3ffeb60903bc8c6f5..6c78c97288b248dcf577d39856aca652f63943ce 100644 (file)
@@ -1387,7 +1387,8 @@ gfc_match_oacc_cache (void)
 {
   gfc_omp_clauses *c = gfc_get_omp_clauses ();
   match m = gfc_match_omp_variable_list (" (",
-                                        &c->lists[OMP_LIST_CACHE], true);
+                                        &c->lists[OMP_LIST_CACHE], true,
+                                        NULL, NULL, true);
   if (m != MATCH_YES)
     {
       gfc_free_omp_clauses(c);
@@ -3107,6 +3108,7 @@ resolve_omp_clauses (gfc_code *code, locus *where,
          case OMP_LIST_MAP:
          case OMP_LIST_TO:
          case OMP_LIST_FROM:
+         case OMP_LIST_CACHE:
            for (; n != NULL; n = n->next)
              {
                if (n->expr)
@@ -3380,7 +3382,6 @@ resolve_omp_clauses (gfc_code *code, locus *where,
                                   n->sym->name, name, where);
                      /* FALLTHRU */
                  case OMP_LIST_DEVICE_RESIDENT:
-                 case OMP_LIST_CACHE:
                    check_symbol_not_pointer (n->sym, *where, name);
                    check_array_not_assumed (n->sym, *where, name);
                    break;
@@ -4597,13 +4598,6 @@ resolve_oacc_loop (gfc_code *code)
 }
 
 
-static void
-resolve_oacc_cache (gfc_code *code ATTRIBUTE_UNUSED)
-{
-  sorry ("Sorry, !$ACC cache unimplemented yet");
-}
-
-
 void
 gfc_resolve_oacc_declare (gfc_namespace *ns)
 {
@@ -4657,6 +4651,7 @@ gfc_resolve_oacc_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED)
     case EXEC_OACC_ENTER_DATA:
     case EXEC_OACC_EXIT_DATA:
     case EXEC_OACC_WAIT:
+    case EXEC_OACC_CACHE:
       resolve_omp_clauses (code, &code->loc, code->ext.omp_clauses, NULL,
                           true);
       break;
@@ -4665,9 +4660,6 @@ gfc_resolve_oacc_directive (gfc_code *code, gfc_namespace *ns ATTRIBUTE_UNUSED)
     case EXEC_OACC_LOOP:
       resolve_oacc_loop (code);
       break;
-    case EXEC_OACC_CACHE:
-      resolve_oacc_cache (code);
-      break;
     default:
       break;
     }
index def8afb4d6d6b5037331de9d8f797add361c88b6..3be9f516e583619e01fdc52f8b5e4952ac21e7b1 100644 (file)
@@ -1778,9 +1778,6 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
        case OMP_LIST_DEVICE_RESIDENT:
          clause_code = OMP_CLAUSE_DEVICE_RESIDENT;
          goto add_clause;
-       case OMP_LIST_CACHE:
-         clause_code = OMP_CLAUSE__CACHE_;
-         goto add_clause;
 
        add_clause:
          omp_clauses
@@ -2159,14 +2156,27 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
          break;
        case OMP_LIST_TO:
        case OMP_LIST_FROM:
+       case OMP_LIST_CACHE:
          for (; n != NULL; n = n->next)
            {
              if (!n->sym->attr.referenced)
                continue;
 
-             tree node = build_omp_clause (input_location,
-                                           list == OMP_LIST_TO
-                                           ? OMP_CLAUSE_TO : OMP_CLAUSE_FROM);
+             switch (list)
+               {
+               case OMP_LIST_TO:
+                 clause_code = OMP_CLAUSE_TO;
+                 break;
+               case OMP_LIST_FROM:
+                 clause_code = OMP_CLAUSE_FROM;
+                 break;
+               case OMP_LIST_CACHE:
+                 clause_code = OMP_CLAUSE__CACHE_;
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+             tree node = build_omp_clause (input_location, clause_code);
              if (n->expr == NULL || n->expr->ref->u.ar.type == AR_FULL)
                {
                  tree decl = gfc_get_symbol_decl (n->sym);
index ab53bc1ff3c7ad5ce5159863e6976cb249d700ce..1185917c9131a647999d2234ed16fa40a16927f7 100644 (file)
@@ -1,3 +1,14 @@
+2015-10-27  Thomas Schwinge  <thomas@codesourcery.com>
+           James Norris  <jnorris@codesourcery.com>
+
+       PR fortran/63865
+       * gfortran.dg/goacc/coarray.f95: Expect the OpenACC cache
+       directive to work.
+       * gfortran.dg/goacc/loop-1.f95: Likewise.
+       * gfortran.dg/goacc/cache-1.f95: Likewise, and extend testing.
+       * gfortran.dg/goacc/cray.f95: Likewise.
+       * gfortran.dg/goacc/parameter.f95: Likewise.
+
  2015-10-27  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/68108
index 746cf02f688f66a28b311d614dad217893d6da8a..2aa9e05362703d622cc21ada4442c78644cdcad2 100644 (file)
@@ -3,10 +3,15 @@
 
 program test
   implicit none
-  integer :: i, d(10)
+  integer :: i, d(10), e(5,13)
 
   do concurrent (i=1:5)
     !$acc cache (d)
+    !$acc cache (d(1:3))
+    !$acc cache (d(i:i+2))
+
+    !$acc cache (e)
+    !$acc cache (e(1:3,2:4))
+    !$acc cache (e(i:i+2,i+1:i+3))
   enddo
 end
-! { dg-prune-output "unimplemented" }
index 4f1224edc2a901d68497b1281d45c18cdc4d21d7..130ffc3ce9dbcffb81ccc05adc79961a37a86362 100644 (file)
@@ -9,6 +9,7 @@ contains
     implicit none
     integer :: i
     integer, codimension[*] :: a
+    ! { dg-excess-errors "sorry, unimplemented: directive not yet implemented" }
     !$acc declare device_resident (a)
     !$acc data copy (a)
     !$acc end data
@@ -16,6 +17,7 @@ contains
     !$acc end data
     !$acc parallel private (a)
     !$acc end parallel
+    ! { dg-excess-errors "sorry, unimplemented: directive not yet implemented" }
     !$acc host_data use_device (a)
     !$acc end host_data
     !$acc parallel loop reduction(+:a)
@@ -32,4 +34,3 @@ contains
     !$acc update self (a)
   end subroutine oacc1
 end module test
-! { dg-prune-output "ACC cache unimplemented" }
index 52789fe2998dc7db3efc3f6a39c690c8c5f555f7..a35ab0dc995e4f8ef859d79c9e100d3bf51ee582 100644 (file)
@@ -24,8 +24,7 @@ contains
     !$acc end parallel loop
     !$acc parallel loop
     do i = 1,5
-      ! Subarrays are not implemented yet
-      !$acc cache (pointee) ! TODO: This must fail, as in openacc-1_0-branch
+      !$acc cache (pointee) ! { dg-error "Cray pointee" }
     enddo
     !$acc end parallel loop
     !$acc update device (pointee) ! { dg-error "Cray pointee" }
@@ -53,4 +52,3 @@ contains
     !$acc update self (ptr)
   end subroutine oacc1
 end module test
-! { dg-prune-output "ACC cache unimplemented" }
index e1b2dfd5d6ef83fe62e450b8e019c0cd34688817..817039f5ac590d6710ae7d049b0612fa3acec1c0 100644 (file)
@@ -168,4 +168,3 @@ subroutine test1
 end subroutine test1
 end module test
 ! { dg-prune-output "Deleted" }
-! { dg-prune-output "ACC cache unimplemented" }
index 454924aed3d1f091bc8f098a86c595f58d2eedec..84274611915c0613c149160504e358fc16a2a950 100644 (file)
@@ -21,7 +21,7 @@ contains
     !$acc end parallel loop
     !$acc parallel loop
     do i = 1,5
-      !$acc cache (a) ! TODO: This must fail, as in openacc-1_0-branch
+      !$acc cache (a) ! { dg-error "not a variable" }
     enddo
     !$acc end parallel loop
     !$acc update device (a) ! { dg-error "not a variable" }
@@ -29,4 +29,3 @@ contains
     !$acc update self (a) ! { dg-error "not a variable" }
   end subroutine oacc1
 end module test
-! { dg-prune-output "ACC cache unimplemented" }