| 1 |
! REQUIRES: openmp_runtime |
| 2 |
|
| 3 |
! RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s |
| 4 |
|
| 5 |
! CHECK-LABEL: func @_QPdistribute_simple |
| 6 |
subroutine distribute_simple() |
| 7 |
! CHECK: omp.teams |
| 8 |
!$omp teams |
| 9 |
|
| 10 |
! CHECK: omp.distribute { |
| 11 |
!$omp distribute |
| 12 |
|
| 13 |
! CHECK-NEXT: omp.loop_nest |
| 14 |
do i = 1, 10 |
| 15 |
call foo() |
| 16 |
! CHECK: omp.yield |
| 17 |
end do |
| 18 |
|
| 19 |
!$omp end distribute |
| 20 |
|
| 21 |
! CHECK: omp.terminator |
| 22 |
!$omp end teams |
| 23 |
end subroutine distribute_simple |
| 24 |
|
| 25 |
!=============================================================================== |
| 26 |
! `dist_schedule` clause |
| 27 |
!=============================================================================== |
| 28 |
|
| 29 |
! CHECK-LABEL: func @_QPdistribute_dist_schedule |
| 30 |
! CHECK-SAME: %[[X_ARG:.*]]: !fir.ref<i32> |
| 31 |
subroutine distribute_dist_schedule(x) |
| 32 |
! CHECK: %[[X_REF:.*]]:2 = hlfir.declare %[[X_ARG]] |
| 33 |
integer, intent(in) :: x |
| 34 |
|
| 35 |
! CHECK: omp.teams |
| 36 |
!$omp teams |
| 37 |
|
| 38 |
! STATIC SCHEDULE, CONSTANT CHUNK SIZE |
| 39 |
|
| 40 |
! CHECK: %[[CONST_CHUNK_SIZE:.*]] = arith.constant 5 : i32 |
| 41 |
! CHECK: omp.distribute |
| 42 |
! CHECK-SAME: dist_schedule_static |
| 43 |
! CHECK-SAME: chunk_size(%[[CONST_CHUNK_SIZE]] : i32) |
| 44 |
!$omp distribute dist_schedule(static, 5) |
| 45 |
|
| 46 |
! CHECK-NEXT: omp.loop_nest |
| 47 |
do i = 1, 10 |
| 48 |
call foo() |
| 49 |
! CHECK: omp.yield |
| 50 |
end do |
| 51 |
|
| 52 |
!$omp end distribute |
| 53 |
|
| 54 |
! STATIC SCHEDULE, VARIABLE CHUNK SIZE |
| 55 |
|
| 56 |
! CHECK: %[[X:.*]] = fir.load %[[X_REF]]#0 |
| 57 |
! CHECK: omp.distribute |
| 58 |
! CHECK-SAME: dist_schedule_static |
| 59 |
! CHECK-SAME: chunk_size(%[[X]] : i32) |
| 60 |
!$omp distribute dist_schedule(static, x) |
| 61 |
|
| 62 |
! CHECK-NEXT: omp.loop_nest |
| 63 |
do i = 1, 10 |
| 64 |
call foo() |
| 65 |
! CHECK: omp.yield |
| 66 |
end do |
| 67 |
|
| 68 |
!$omp end distribute |
| 69 |
|
| 70 |
! STATIC SCHEDULE, NO CHUNK SIZE |
| 71 |
|
| 72 |
! CHECK: omp.distribute |
| 73 |
! CHECK-SAME: dist_schedule_static |
| 74 |
! CHECK-NOT: chunk_size |
| 75 |
!$omp distribute dist_schedule(static) |
| 76 |
|
| 77 |
! CHECK-NEXT: omp.loop_nest |
| 78 |
do i = 1, 10 |
| 79 |
call foo() |
| 80 |
! CHECK: omp.yield |
| 81 |
end do |
| 82 |
|
| 83 |
!$omp end distribute |
| 84 |
|
| 85 |
! CHECK: omp.terminator |
| 86 |
!$omp end teams |
| 87 |
end subroutine distribute_dist_schedule |
| 88 |
|
| 89 |
!=============================================================================== |
| 90 |
! `allocate` clause |
| 91 |
!=============================================================================== |
| 92 |
|
| 93 |
! CHECK-LABEL: func @_QPdistribute_allocate |
| 94 |
subroutine distribute_allocate() |
| 95 |
use omp_lib |
| 96 |
integer :: x |
| 97 |
! CHECK: omp.teams |
| 98 |
!$omp teams |
| 99 |
|
| 100 |
! CHECK: omp.distribute |
| 101 |
! CHECK-SAME: allocate(%{{.+}} : i64 -> %{{.+}} : !fir.ref<i32>) |
| 102 |
!$omp distribute allocate(omp_high_bw_mem_alloc: x) private(x) |
| 103 |
|
| 104 |
! CHECK-NEXT: omp.loop_nest |
| 105 |
do i = 1, 10 |
| 106 |
x = i |
| 107 |
! CHECK: omp.yield |
| 108 |
end do |
| 109 |
|
| 110 |
!$omp end distribute |
| 111 |
|
| 112 |
! CHECK: omp.terminator |
| 113 |
!$omp end teams |
| 114 |
end subroutine distribute_allocate |