diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libgomp/testsuite/libgomp.fortran/omp_parse2.f90 | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libgomp/testsuite/libgomp.fortran/omp_parse2.f90')
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/omp_parse2.f90 | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/omp_parse2.f90 b/libgomp/testsuite/libgomp.fortran/omp_parse2.f90 new file mode 100644 index 000000000..da54a9872 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/omp_parse2.f90 @@ -0,0 +1,102 @@ +! { dg-do run } +use omp_lib + call test_master + call test_critical + call test_barrier + call test_atomic + +contains + subroutine test_master + logical :: i, j + i = .false. + j = .false. +!$omp parallel num_threads (4) +!$omp master + i = .true. + j = omp_get_thread_num () .eq. 0 +!$omp endmaster +!$omp end parallel + if (.not. (i .or. j)) call abort + end subroutine test_master + + subroutine test_critical_1 (i, j) + integer :: i, j +!$omp critical(critical_foo) + i = i + 1 +!$omp end critical (critical_foo) +!$omp critical + j = j + 1 +!$omp end critical + end subroutine test_critical_1 + + subroutine test_critical + integer :: i, j, n + n = -1 + i = 0 + j = 0 +!$omp parallel num_threads (4) + if (omp_get_thread_num () .eq. 0) n = omp_get_num_threads () + call test_critical_1 (i, j) + call test_critical_1 (i, j) +!$omp critical + j = j + 1 +!$omp end critical +!$omp critical (critical_foo) + i = i + 1 +!$omp endcritical (critical_foo) +!$omp end parallel + if (n .lt. 1 .or. i .ne. n * 3 .or. j .ne. n * 3) call abort + end subroutine test_critical + + subroutine test_barrier + integer :: i + logical :: j + i = 23 + j = .false. +!$omp parallel num_threads (4) + if (omp_get_thread_num () .eq. 0) i = 5 +!$omp flush (i) +!$omp barrier + if (i .ne. 5) then +!$omp atomic + j = j .or. .true. + end if +!$omp end parallel + if (i .ne. 5 .or. j) call abort + end subroutine test_barrier + + subroutine test_atomic + integer :: a, b, c, d, e, f, g + a = 0 + b = 1 + c = 0 + d = 1024 + e = 1024 + f = -1 + g = -1 +!$omp parallel num_threads (8) +!$omp atomic + a = a + 2 + 4 +!$omp atomic + b = 3 * b +!$omp atomic + c = 8 - c +!$omp atomic + d = d / 2 +!$omp atomic + e = min (e, omp_get_thread_num ()) +!$omp atomic + f = max (omp_get_thread_num (), f) + if (omp_get_thread_num () .eq. 0) g = omp_get_num_threads () +!$omp end parallel + if (g .le. 0 .or. g .gt. 8) call abort + if (a .ne. 6 * g .or. b .ne. 3 ** g) call abort + if (iand (g, 1) .eq. 1) then + if (c .ne. 8) call abort + else if (c .ne. 0) then + call abort + end if + if (d .ne. 1024 / (2 ** g)) call abort + if (e .ne. 0 .or. f .ne. g - 1) call abort + end subroutine test_atomic +end |