]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Support nowait with Fortran [PR105378]
authorTobias Burnus <tobias@codesourcery.com>
Tue, 24 May 2022 08:41:43 +0000 (10:41 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 24 May 2022 08:45:26 +0000 (10:45 +0200)
Fortran part to C/C++/libgomp
commit r13-724-gb43836914bdc2a37563cf31359b2c4803bfe4374

gcc/fortran/

PR c/105378
* openmp.cc (gfc_match_omp_taskwait): Accept nowait.

gcc/testsuite/

PR c/105378
* gfortran.dg/gomp/taskwait-depend-nowait-1.f90: New.

libgomp/

PR c/105378
* libgomp.texi (OpenMP 5.1): Set 'taskwait nowait' to 'Y'.
* testsuite/libgomp.fortran/taskwait-depend-nowait-1.f90: New.

gcc/fortran/openmp.cc
gcc/testsuite/gfortran.dg/gomp/taskwait-depend-nowait-1.f90 [new file with mode: 0644]
libgomp/libgomp.texi
libgomp/testsuite/libgomp.fortran/taskwait-depend-nowait-1.f90 [new file with mode: 0644]

index 63fd4dd2767ad64b15a3473b8d166cb2dfbb0205..6172ec27687708c6e263868c3a439da3ba544835 100644 (file)
@@ -5701,7 +5701,8 @@ gfc_match_omp_taskwait (void)
       new_st.ext.omp_clauses = NULL;
       return MATCH_YES;
     }
-  return match_omp (EXEC_OMP_TASKWAIT, omp_mask (OMP_CLAUSE_DEPEND));
+  return match_omp (EXEC_OMP_TASKWAIT,
+                   omp_mask (OMP_CLAUSE_DEPEND) | OMP_CLAUSE_NOWAIT);
 }
 
 
diff --git a/gcc/testsuite/gfortran.dg/gomp/taskwait-depend-nowait-1.f90 b/gcc/testsuite/gfortran.dg/gomp/taskwait-depend-nowait-1.f90
new file mode 100644 (file)
index 0000000..cd2f1d2
--- /dev/null
@@ -0,0 +1,14 @@
+subroutine foo (p)
+  integer :: p(*)
+  !$omp taskwait depend(iterator(i = 1:17) , in : p(i)) nowait depend(out : p(32))
+end
+
+subroutine bar (p)
+  implicit none
+  integer :: p(*)
+  !$omp taskwait depend(mutexinoutset : p(1)) nowait   ! { dg-error "'mutexinoutset' kind in 'depend' clause on a 'taskwait' construct" }
+end
+
+subroutine baz
+  !$omp taskwait nowait        ! { dg-error "'taskwait' construct with 'nowait' clause but no 'depend' clauses" }
+end
index b54555d0ccbfefd2122d07f0718f0f20db316374..56724687fb48848d19bf71424f01beb49db1777f 100644 (file)
@@ -303,7 +303,7 @@ The OpenMP 4.5 specification is fully supported.
       @code{target} regions @tab N @tab
 @item @code{interop} directive @tab N @tab
 @item @code{omp_interop_t} object support in runtime routines @tab N @tab
-@item @code{nowait} clause in @code{taskwait} directive @tab N @tab
+@item @code{nowait} clause in @code{taskwait} directive @tab Y @tab
 @item Extensions to the @code{atomic} directive @tab Y @tab
 @item @code{seq_cst} clause on a @code{flush} construct @tab Y @tab
 @item @code{inoutset} argument to the @code{depend} clause @tab Y @tab
diff --git a/libgomp/testsuite/libgomp.fortran/taskwait-depend-nowait-1.f90 b/libgomp/testsuite/libgomp.fortran/taskwait-depend-nowait-1.f90
new file mode 100644 (file)
index 0000000..a5b058d
--- /dev/null
@@ -0,0 +1,42 @@
+program main
+  implicit none
+  integer :: a(0:63), b = 1
+  !$omp parallel num_threads (4)
+  block
+    !$omp single
+    block
+      integer :: i
+      !$omp taskwait depend(in: a) nowait
+      !$omp taskwait depend(in: a) nowait
+      !$omp taskwait
+      !$omp taskgroup
+      block
+        !$omp taskwait depend(in: a) nowait
+        !$omp taskwait depend(in: a) nowait
+      end block
+      do i = 0, 63
+        !$omp task depend(in: a) shared(a)
+        block
+          a(i) = i
+        end block
+      end do
+      !$omp taskwait depend(inout: a) nowait
+      do i = 0, 63
+        !$omp task depend(inoutset: a) shared(a)
+        block
+          if (a(i) /= i) then
+            error stop
+          else
+            a(i) = 2 * i + 1
+          end if
+        end block
+      end do
+      !$omp taskwait nowait depend(out: a) depend(in: b)
+      !$omp taskwait depend(inout: b)
+      do i = 0, 63
+        if (a(i) /= 2 * i + 1) &
+          error stop
+      end do
+    end block
+  end block
+end program