aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgomp/testsuite/libgomp.fortran/cancel-parallel-3.f90
blob: 9d5ba8ffa388aaa4e1b6fad0497d27ac651c88b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
! { dg-do run }
! { dg-options "-fno-inline -fno-ipa-sra -fno-ipa-cp -fno-ipa-cp-clone" }
! { dg-set-target-env-var OMP_CANCELLATION "true" }

  use omp_lib
  integer :: x, i, j
  common /x/ x

  call omp_set_dynamic (.false.)
  call omp_set_schedule (omp_sched_static, 1)
  !$omp parallel num_threads(16) private (i, j)
    call do_some_work
    !$omp barrier
    if (omp_get_thread_num ().eq.1) then
      call sleep (2)
      !$omp cancellation point parallel
    end if
    do j = 3, 16
      !$omp do schedule(runtime)
	do i = 0, j - 1
	  call do_some_work
	end do
      !$omp enddo nowait
    end do
    if (omp_get_thread_num ().eq.0) then
      call sleep (1)
      !$omp cancel parallel
    end if
  !$omp end parallel
contains
  subroutine do_some_work
    integer :: x
    common /x/ x
    !$omp atomic
      x = x + 1
    !$omp end atomic
  endsubroutine do_some_work
end