Retro68/gcc/libgomp/testsuite/libgomp.fortran/lib1.f90

78 lines
2.1 KiB
Fortran
Raw Normal View History

2012-03-27 23:13:14 +00:00
! { dg-do run }
use omp_lib
double precision :: d, e
logical :: l
integer (kind = omp_lock_kind) :: lck
integer (kind = omp_nest_lock_kind) :: nlck
d = omp_get_wtime ()
call omp_init_lock (lck)
call omp_set_lock (lck)
2018-12-28 15:30:48 +00:00
if (omp_test_lock (lck)) STOP 1
2012-03-27 23:13:14 +00:00
call omp_unset_lock (lck)
2018-12-28 15:30:48 +00:00
if (.not. omp_test_lock (lck)) STOP 2
if (omp_test_lock (lck)) STOP 3
2012-03-27 23:13:14 +00:00
call omp_unset_lock (lck)
call omp_destroy_lock (lck)
call omp_init_nest_lock (nlck)
2018-12-28 15:30:48 +00:00
if (omp_test_nest_lock (nlck) .ne. 1) STOP 4
2012-03-27 23:13:14 +00:00
call omp_set_nest_lock (nlck)
2018-12-28 15:30:48 +00:00
if (omp_test_nest_lock (nlck) .ne. 3) STOP 5
2012-03-27 23:13:14 +00:00
call omp_unset_nest_lock (nlck)
call omp_unset_nest_lock (nlck)
2018-12-28 15:30:48 +00:00
if (omp_test_nest_lock (nlck) .ne. 2) STOP 6
2012-03-27 23:13:14 +00:00
call omp_unset_nest_lock (nlck)
call omp_unset_nest_lock (nlck)
call omp_destroy_nest_lock (nlck)
call omp_set_dynamic (.true.)
2018-12-28 15:30:48 +00:00
if (.not. omp_get_dynamic ()) STOP 7
2012-03-27 23:13:14 +00:00
call omp_set_dynamic (.false.)
2018-12-28 15:30:48 +00:00
if (omp_get_dynamic ()) STOP 8
2012-03-27 23:13:14 +00:00
call omp_set_nested (.true.)
2018-12-28 15:30:48 +00:00
if (.not. omp_get_nested ()) STOP 9
2012-03-27 23:13:14 +00:00
call omp_set_nested (.false.)
2018-12-28 15:30:48 +00:00
if (omp_get_nested ()) STOP 10
2012-03-27 23:13:14 +00:00
call omp_set_num_threads (5)
2018-12-28 15:30:48 +00:00
if (omp_get_num_threads () .ne. 1) STOP 11
if (omp_get_max_threads () .ne. 5) STOP 12
if (omp_get_thread_num () .ne. 0) STOP 13
2012-03-27 23:13:14 +00:00
call omp_set_num_threads (3)
2018-12-28 15:30:48 +00:00
if (omp_get_num_threads () .ne. 1) STOP 14
if (omp_get_max_threads () .ne. 3) STOP 15
if (omp_get_thread_num () .ne. 0) STOP 16
2012-03-27 23:13:14 +00:00
l = .false.
!$omp parallel reduction (.or.:l)
l = omp_get_num_threads () .ne. 3
l = l .or. (omp_get_thread_num () .lt. 0)
l = l .or. (omp_get_thread_num () .ge. 3)
!$omp master
l = l .or. (omp_get_thread_num () .ne. 0)
!$omp end master
!$omp end parallel
2018-12-28 15:30:48 +00:00
if (l) STOP 17
2012-03-27 23:13:14 +00:00
2018-12-28 15:30:48 +00:00
if (omp_get_num_procs () .le. 0) STOP 18
if (omp_in_parallel ()) STOP 19
2012-03-27 23:13:14 +00:00
!$omp parallel reduction (.or.:l)
l = .not. omp_in_parallel ()
!$omp end parallel
!$omp parallel reduction (.or.:l) if (.true.)
l = .not. omp_in_parallel ()
!$omp end parallel
2018-12-28 15:30:48 +00:00
if (l) STOP 20
2012-03-27 23:13:14 +00:00
e = omp_get_wtime ()
2018-12-28 15:30:48 +00:00
if (d .gt. e) STOP 21
2012-03-27 23:13:14 +00:00
d = omp_get_wtick ()
! Negative precision is definitely wrong,
! bigger than 1s clock resolution is also strange
2018-12-28 15:30:48 +00:00
if (d .le. 0 .or. d .gt. 1.) STOP 22
2012-03-27 23:13:14 +00:00
end