1! RUN: %S/test_errors.sh %s %t %flang_fc1 -fopenmp 2! REQUIRES: shell 3! OpenMP Version 4.5 4! Various checks with the nesting of BARRIER construct 5 6program omp_nest_barrier 7 integer i, k, j 8 k = 0; 9 10 !$omp do 11 do i = 1, 10 12 k = k + 1 13 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 14 !$omp barrier 15 j = j -1 16 end do 17 18 !$omp do simd 19 do i = 1, 10 20 k = k + 1 21 !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause. 22 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 23 !$omp barrier 24 j = j -1 25 end do 26 27 !$omp parallel do 28 do i = 1, 10 29 k = k + 1 30 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 31 !$omp barrier 32 j = j -1 33 end do 34 35 !$omp parallel do simd 36 do i = 1, 10 37 k = k + 1 38 !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct and the `ORDERED` construct with the `SIMD` clause. 39 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 40 !$omp barrier 41 j = j -1 42 end do 43 44 !$omp parallel 45 do i = 1, 10 46 k = k + 1 47 !$omp barrier 48 j = j -1 49 end do 50 !$omp end parallel 51 52 !$omp task 53 do i = 1, 10 54 k = k + 1 55 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 56 !$omp barrier 57 j = j -1 58 end do 59 !$omp end task 60 61 !$omp taskloop 62 do i = 1, 10 63 k = k + 1 64 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 65 !$omp barrier 66 j = j -1 67 end do 68 !$omp end taskloop 69 70 !$omp critical 71 do i = 1, 10 72 k = k + 1 73 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 74 !$omp barrier 75 j = j -1 76 end do 77 !$omp end critical 78 79 !$omp master 80 do i = 1, 10 81 k = k + 1 82 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 83 !$omp barrier 84 j = j -1 85 end do 86 !$omp end master 87 88 !$omp ordered 89 do i = 1, 10 90 k = k + 1 91 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 92 !$omp barrier 93 j = j -1 94 end do 95 !$omp end ordered 96 97 !$omp ordered 98 do i = 1, 10 99 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 100 !$omp distribute 101 do k =1, 10 102 print *, "hello" 103 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 104 !$omp barrier 105 j = j -1 106 end do 107 !$omp end distribute 108 end do 109 !$omp end ordered 110 111 !$omp master 112 do i = 1, 10 113 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 114 !$omp distribute 115 do k =1, 10 116 print *, "hello" 117 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 118 !$omp barrier 119 j = j -1 120 end do 121 !$omp end distribute 122 end do 123 !$omp end master 124 125 !$omp critical 126 do i = 1, 10 127 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 128 !$omp distribute 129 do k =1, 10 130 print *, "hello" 131 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 132 !$omp barrier 133 j = j -1 134 end do 135 !$omp end distribute 136 end do 137 !$omp end critical 138 139 !$omp taskloop 140 do i = 1, 10 141 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 142 !$omp distribute 143 do k =1, 10 144 print *, "hello" 145 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 146 !$omp barrier 147 j = j -1 148 end do 149 !$omp end distribute 150 end do 151 !$omp end taskloop 152 153 !$omp task 154 do i = 1, 10 155 !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region. 156 !$omp distribute 157 do k =1, 10 158 print *, "hello" 159 !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region. 160 !$omp barrier 161 j = j -1 162 end do 163 !$omp end distribute 164 end do 165 !$omp end task 166 167end program omp_nest_barrier 168