xref: /llvm-project/flang/test/Semantics/OpenMP/nested-barrier.f90 (revision e67e09a77ea1e4802c0f6bc0409c9f5e9d1fae9a)
13323a4bdSKiran Chandramohan! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
23323a4bdSKiran Chandramohan! OpenMP Version 4.5
33323a4bdSKiran Chandramohan! Various checks with the nesting of BARRIER construct
43323a4bdSKiran Chandramohan
53323a4bdSKiran Chandramohanprogram omp_nest_barrier
63323a4bdSKiran Chandramohan  integer i, k, j
73323a4bdSKiran Chandramohan  k = 0;
83323a4bdSKiran Chandramohan
93323a4bdSKiran Chandramohan  !$omp do
103323a4bdSKiran Chandramohan  do i = 1, 10
113323a4bdSKiran Chandramohan    k = k + 1
123323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
133323a4bdSKiran Chandramohan    !$omp barrier
143323a4bdSKiran Chandramohan    j = j -1
153323a4bdSKiran Chandramohan  end do
163323a4bdSKiran Chandramohan
173323a4bdSKiran Chandramohan  !$omp do simd
183323a4bdSKiran Chandramohan  do i = 1, 10
193323a4bdSKiran Chandramohan    k = k + 1
20*e67e09a7SAnchu Rajendran S    !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, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
213323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
223323a4bdSKiran Chandramohan    !$omp barrier
233323a4bdSKiran Chandramohan    j = j -1
243323a4bdSKiran Chandramohan  end do
253323a4bdSKiran Chandramohan
263323a4bdSKiran Chandramohan  !$omp parallel do
273323a4bdSKiran Chandramohan  do i = 1, 10
283323a4bdSKiran Chandramohan    k = k + 1
293323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
303323a4bdSKiran Chandramohan    !$omp barrier
313323a4bdSKiran Chandramohan    j = j -1
323323a4bdSKiran Chandramohan  end do
333323a4bdSKiran Chandramohan
343323a4bdSKiran Chandramohan  !$omp parallel do simd
353323a4bdSKiran Chandramohan  do i = 1, 10
363323a4bdSKiran Chandramohan    k = k + 1
37*e67e09a7SAnchu Rajendran S    !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, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
383323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
393323a4bdSKiran Chandramohan    !$omp barrier
403323a4bdSKiran Chandramohan    j = j -1
413323a4bdSKiran Chandramohan  end do
423323a4bdSKiran Chandramohan
433323a4bdSKiran Chandramohan  !$omp parallel
443323a4bdSKiran Chandramohan  do i = 1, 10
453323a4bdSKiran Chandramohan    k = k + 1
463323a4bdSKiran Chandramohan    !$omp barrier
473323a4bdSKiran Chandramohan    j = j -1
483323a4bdSKiran Chandramohan  end do
493323a4bdSKiran Chandramohan  !$omp end parallel
503323a4bdSKiran Chandramohan
513323a4bdSKiran Chandramohan  !$omp task
523323a4bdSKiran Chandramohan  do i = 1, 10
533323a4bdSKiran Chandramohan    k = k + 1
543323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
553323a4bdSKiran Chandramohan    !$omp barrier
563323a4bdSKiran Chandramohan    j = j -1
573323a4bdSKiran Chandramohan  end do
583323a4bdSKiran Chandramohan  !$omp end task
593323a4bdSKiran Chandramohan
603323a4bdSKiran Chandramohan  !$omp taskloop
613323a4bdSKiran Chandramohan  do i = 1, 10
623323a4bdSKiran Chandramohan    k = k + 1
633323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
643323a4bdSKiran Chandramohan    !$omp barrier
653323a4bdSKiran Chandramohan    j = j -1
663323a4bdSKiran Chandramohan  end do
673323a4bdSKiran Chandramohan  !$omp end taskloop
683323a4bdSKiran Chandramohan
693323a4bdSKiran Chandramohan  !$omp critical
703323a4bdSKiran Chandramohan  do i = 1, 10
713323a4bdSKiran Chandramohan    k = k + 1
723323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
733323a4bdSKiran Chandramohan    !$omp barrier
743323a4bdSKiran Chandramohan    j = j -1
753323a4bdSKiran Chandramohan  end do
763323a4bdSKiran Chandramohan  !$omp end critical
773323a4bdSKiran Chandramohan
78092a819eSKiran Chandramohan  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
793323a4bdSKiran Chandramohan  !$omp master
803323a4bdSKiran Chandramohan  do i = 1, 10
813323a4bdSKiran Chandramohan    k = k + 1
823323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
833323a4bdSKiran Chandramohan    !$omp barrier
843323a4bdSKiran Chandramohan    j = j -1
853323a4bdSKiran Chandramohan  end do
863323a4bdSKiran Chandramohan  !$omp end master
873323a4bdSKiran Chandramohan
883323a4bdSKiran Chandramohan  !$omp ordered
893323a4bdSKiran Chandramohan  do i = 1, 10
903323a4bdSKiran Chandramohan    k = k + 1
913323a4bdSKiran Chandramohan    !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
923323a4bdSKiran Chandramohan    !$omp barrier
933323a4bdSKiran Chandramohan    j = j -1
943323a4bdSKiran Chandramohan  end do
953323a4bdSKiran Chandramohan  !$omp end ordered
963323a4bdSKiran Chandramohan
973323a4bdSKiran Chandramohan  !$omp ordered
983323a4bdSKiran Chandramohan  do i = 1, 10
993323a4bdSKiran Chandramohan    !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
1003323a4bdSKiran Chandramohan    !$omp distribute
1013323a4bdSKiran Chandramohan    do k =1, 10
1023323a4bdSKiran Chandramohan      print *, "hello"
1033323a4bdSKiran Chandramohan      !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
1043323a4bdSKiran Chandramohan      !$omp barrier
1053323a4bdSKiran Chandramohan      j = j -1
1063323a4bdSKiran Chandramohan    end do
1073323a4bdSKiran Chandramohan    !$omp end distribute
1083323a4bdSKiran Chandramohan  end do
1093323a4bdSKiran Chandramohan  !$omp end ordered
1103323a4bdSKiran Chandramohan
111092a819eSKiran Chandramohan  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
1123323a4bdSKiran Chandramohan  !$omp master
1133323a4bdSKiran Chandramohan  do i = 1, 10
1143323a4bdSKiran Chandramohan    !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
1153323a4bdSKiran Chandramohan    !$omp distribute
1163323a4bdSKiran Chandramohan    do k =1, 10
1173323a4bdSKiran Chandramohan      print *, "hello"
1183323a4bdSKiran Chandramohan      !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
1193323a4bdSKiran Chandramohan      !$omp barrier
1203323a4bdSKiran Chandramohan      j = j -1
1213323a4bdSKiran Chandramohan    end do
1223323a4bdSKiran Chandramohan    !$omp end distribute
1233323a4bdSKiran Chandramohan  end do
1243323a4bdSKiran Chandramohan  !$omp end master
1253323a4bdSKiran Chandramohan
1263323a4bdSKiran Chandramohan  !$omp critical
1273323a4bdSKiran Chandramohan  do i = 1, 10
1283323a4bdSKiran Chandramohan    !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
1293323a4bdSKiran Chandramohan    !$omp distribute
1303323a4bdSKiran Chandramohan    do k =1, 10
1313323a4bdSKiran Chandramohan      print *, "hello"
1323323a4bdSKiran Chandramohan      !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
1333323a4bdSKiran Chandramohan      !$omp barrier
1343323a4bdSKiran Chandramohan      j = j -1
1353323a4bdSKiran Chandramohan    end do
1363323a4bdSKiran Chandramohan    !$omp end distribute
1373323a4bdSKiran Chandramohan  end do
1383323a4bdSKiran Chandramohan  !$omp end critical
1393323a4bdSKiran Chandramohan
1403323a4bdSKiran Chandramohan  !$omp taskloop
1413323a4bdSKiran Chandramohan  do i = 1, 10
1423323a4bdSKiran Chandramohan    !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
1433323a4bdSKiran Chandramohan    !$omp distribute
1443323a4bdSKiran Chandramohan    do k =1, 10
1453323a4bdSKiran Chandramohan      print *, "hello"
1463323a4bdSKiran Chandramohan      !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
1473323a4bdSKiran Chandramohan      !$omp barrier
1483323a4bdSKiran Chandramohan      j = j -1
1493323a4bdSKiran Chandramohan    end do
1503323a4bdSKiran Chandramohan    !$omp end distribute
1513323a4bdSKiran Chandramohan  end do
1523323a4bdSKiran Chandramohan  !$omp end taskloop
1533323a4bdSKiran Chandramohan
1543323a4bdSKiran Chandramohan  !$omp task
1553323a4bdSKiran Chandramohan  do i = 1, 10
1563323a4bdSKiran Chandramohan    !ERROR: `DISTRIBUTE` region has to be strictly nested inside `TEAMS` region.
1573323a4bdSKiran Chandramohan    !$omp distribute
1583323a4bdSKiran Chandramohan    do k =1, 10
1593323a4bdSKiran Chandramohan      print *, "hello"
1603323a4bdSKiran Chandramohan      !ERROR: `BARRIER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`,`CRITICAL`, `ORDERED`, `ATOMIC` or `MASTER` region.
1613323a4bdSKiran Chandramohan      !$omp barrier
1623323a4bdSKiran Chandramohan      j = j -1
1633323a4bdSKiran Chandramohan    end do
1643323a4bdSKiran Chandramohan    !$omp end distribute
1653323a4bdSKiran Chandramohan  end do
1663323a4bdSKiran Chandramohan  !$omp end task
1673323a4bdSKiran Chandramohan
1683323a4bdSKiran Chandramohanend program omp_nest_barrier
169