[gomp] 3 new testcases

Jakub Jelinek jakub@redhat.com
Mon Oct 24 14:52:00 GMT 2005


Hi!

All are currently failing (nestedfn* is the same problem, just in two
languages and reduction6 is first waiting for VLA type remapping fixes),
nevertheless I think it is better to put them in now.  Ok?

2005-10-24  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/libgomp.dg/nestedfn-1.c: New test.
	* testsuite/libgomp.fortran/reduction6.f90: New test.
	* testsuite/libgomp.fortran/nestedfn1.f90: New test.

--- libgomp/testsuite/libgomp.dg/nestedfn-1.c.jj	2005-10-24 16:18:58.000000000 +0200
+++ libgomp/testsuite/libgomp.dg/nestedfn-1.c	2005-10-24 16:20:47.000000000 +0200
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+  int a = 1, b = 2, c = 3;
+  void
+  foo (void)
+  {
+    int l = 0;
+#pragma omp parallel shared (a) private (b) firstprivate (c) \
+		     num_threads (2) reduction (||:l)
+    {
+      if (a != 1 || c != 3) l = 1;
+#pragma omp barrier
+      if (omp_get_thread_num () == 0)
+	{
+	  a = 4;
+	  b = 5;
+	  c = 6;
+	}
+#pragma omp barrier
+      if (omp_get_thread_num () == 1)
+	{
+	  if (a != 4 || c != 3) l = 1;
+	  a = 7;
+	  b = 8;
+	  c = 9;
+	}
+      else if (omp_get_num_threads () == 1)
+	a = 7;
+#pragma omp barrier
+      if (omp_get_thread_num () == 0)
+	if (a != 7 || b != 5 || c != 6) l = 1;
+#pragma omp barrier
+      if (omp_get_thread_num () == 1)
+	if (a != 7 || b != 8 || c != 9) l = 1;
+    }
+    if (l)
+      abort ();
+  }
+  foo ();
+  if (a != 7)
+    abort ();
+  return 0;
+}
--- libgomp/testsuite/libgomp.fortran/reduction6.f90.jj	2005-10-24 16:09:42.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/reduction6.f90	2005-10-24 16:14:41.000000000 +0200
@@ -0,0 +1,32 @@
+! { dg-do run }
+
+  integer, dimension (6, 6) :: a
+  character (36) :: c
+  integer nthreads
+  a = 9
+  nthreads = -1
+  call foo (a (2:4, 3:5), nthreads)
+  if (nthreads .eq. 3) then
+    write (c, '(36i1)') a
+    if (c .ne. '999999999999966699966699966699999999') call abort
+  end if
+contains
+  subroutine foo (b, nthreads)
+    use omp_lib
+    integer, dimension (3:, 5:) :: b
+    integer :: err, nthreads
+    b = 0
+    err = 0
+!$omp parallel num_threads (3) reduction (+:b)
+    if (any (b .ne. 0)) then
+!$omp atomic
+      err = err + 1
+    end if
+!$omp master
+    nthreads = omp_get_num_threads ()
+!$omp end master
+    b = 2
+!$omp end parallel
+    if (err .gt. 0) call abort
+  end subroutine foo
+end
--- libgomp/testsuite/libgomp.fortran/nestedfn1.f90.jj	2005-10-24 16:10:50.000000000 +0200
+++ libgomp/testsuite/libgomp.fortran/nestedfn1.f90	2005-10-24 16:09:13.000000000 +0200
@@ -0,0 +1,43 @@
+! { dg-do run }
+
+  integer :: a, b, c
+  a = 1
+  b = 2
+  c = 3
+  call foo
+  if (a .ne. 7) call abort
+contains
+  subroutine foo
+    use omp_lib
+    logical :: l
+    l = .false.
+!$omp parallel shared (a) private (b) firstprivate (c) &
+!$omp num_threads (2) reduction (.or.:l)
+    if (a .ne. 1 .or. c .ne. 3) l = .true.
+!$omp barrier
+    if (omp_get_thread_num () .eq. 0) then
+      a = 4
+      b = 5
+      c = 6
+    end if
+!$omp barrier
+    if (omp_get_thread_num () .eq. 1) then
+      if (a .ne. 4 .or. c .ne. 3) l = .true.
+      a = 7
+      b = 8
+      c = 9
+    else if (omp_get_num_threads () .eq. 1) then
+      a = 7
+    end if
+!$omp barrier
+    if (omp_get_thread_num () .eq. 0) then
+      if (a .ne. 7 .or. b .ne. 5 .or. c .ne. 6) l = .true.
+    end if
+!$omp barrier
+    if (omp_get_thread_num () .eq. 1) then
+      if (a .ne. 7 .or. b .ne. 8 .or. c .ne. 9) l = .true.
+    end if
+!$omp end parallel
+    if (l) call abort
+  end subroutine foo
+end

	Jakub



More information about the Gcc-patches mailing list