lib1.f90 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ! { dg-do run }
  2. use omp_lib
  3. double precision :: d, e
  4. logical :: l
  5. integer (kind = omp_lock_kind) :: lck
  6. integer (kind = omp_nest_lock_kind) :: nlck
  7. d = omp_get_wtime ()
  8. call omp_init_lock (lck)
  9. call omp_set_lock (lck)
  10. if (omp_test_lock (lck)) call abort
  11. call omp_unset_lock (lck)
  12. if (.not. omp_test_lock (lck)) call abort
  13. if (omp_test_lock (lck)) call abort
  14. call omp_unset_lock (lck)
  15. call omp_destroy_lock (lck)
  16. call omp_init_nest_lock (nlck)
  17. if (omp_test_nest_lock (nlck) .ne. 1) call abort
  18. call omp_set_nest_lock (nlck)
  19. if (omp_test_nest_lock (nlck) .ne. 3) call abort
  20. call omp_unset_nest_lock (nlck)
  21. call omp_unset_nest_lock (nlck)
  22. if (omp_test_nest_lock (nlck) .ne. 2) call abort
  23. call omp_unset_nest_lock (nlck)
  24. call omp_unset_nest_lock (nlck)
  25. call omp_destroy_nest_lock (nlck)
  26. call omp_set_dynamic (.true.)
  27. if (.not. omp_get_dynamic ()) call abort
  28. call omp_set_dynamic (.false.)
  29. if (omp_get_dynamic ()) call abort
  30. call omp_set_nested (.true.)
  31. if (.not. omp_get_nested ()) call abort
  32. call omp_set_nested (.false.)
  33. if (omp_get_nested ()) call abort
  34. call omp_set_num_threads (5)
  35. if (omp_get_num_threads () .ne. 1) call abort
  36. if (omp_get_max_threads () .ne. 5) call abort
  37. if (omp_get_thread_num () .ne. 0) call abort
  38. call omp_set_num_threads (3)
  39. if (omp_get_num_threads () .ne. 1) call abort
  40. if (omp_get_max_threads () .ne. 3) call abort
  41. if (omp_get_thread_num () .ne. 0) call abort
  42. l = .false.
  43. !$omp parallel reduction (.or.:l)
  44. l = omp_get_num_threads () .ne. 3
  45. l = l .or. (omp_get_thread_num () .lt. 0)
  46. l = l .or. (omp_get_thread_num () .ge. 3)
  47. !$omp master
  48. l = l .or. (omp_get_thread_num () .ne. 0)
  49. !$omp end master
  50. !$omp end parallel
  51. if (l) call abort
  52. if (omp_get_num_procs () .le. 0) call abort
  53. if (omp_in_parallel ()) call abort
  54. !$omp parallel reduction (.or.:l)
  55. l = .not. omp_in_parallel ()
  56. !$omp end parallel
  57. !$omp parallel reduction (.or.:l) if (.true.)
  58. l = .not. omp_in_parallel ()
  59. !$omp end parallel
  60. if (l) call abort
  61. e = omp_get_wtime ()
  62. if (d .gt. e) call abort
  63. d = omp_get_wtick ()
  64. ! Negative precision is definitely wrong,
  65. ! bigger than 1s clock resolution is also strange
  66. if (d .le. 0 .or. d .gt. 1.) call abort
  67. end