-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Flang][OpenMP] Appropriately emit present/load/store in all cases in MapInfoFinalization #150311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| !RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s | ||
|
|
||
| module mod | ||
| contains | ||
| subroutine foo(dt, switch) | ||
| implicit none | ||
| real(4), dimension(:), intent(inout) :: dt | ||
| logical, intent(in) :: switch | ||
| integer :: dim, idx | ||
|
|
||
| if (switch) then | ||
| !$omp target teams distribute parallel do | ||
| do idx = 1, 100 | ||
| dt(idx) = 20 | ||
| end do | ||
| else | ||
| !$omp target teams distribute parallel do | ||
| do idx = 1, 100 | ||
| dt(idx) = 30 | ||
| end do | ||
| end if | ||
| end subroutine foo | ||
| end module | ||
|
|
||
| ! CHECK-LABEL: func.func @{{.*}}( | ||
| ! CHECK-SAME: %[[ARG0:.*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "dt"}, | ||
| ! CHECK: %[[VAL_0:.*]] = fir.alloca !fir.box<!fir.array<?xf32>> | ||
| ! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[ARG0]] dummy_scope {{.*}} | ||
| ! CHECK: fir.if %{{.*}} { | ||
| ! CHECK: %[[VAL_2:.*]] = fir.is_present %[[VAL_1]]#1 : (!fir.box<!fir.array<?xf32>>) -> i1 | ||
| ! CHECK: fir.if %[[VAL_2]] { | ||
| ! CHECK: fir.store %[[VAL_1]]#1 to %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>> | ||
| ! CHECK: } | ||
| ! CHECK: %[[VAL_3:.*]] = fir.box_offset %[[VAL_0]] base_addr : (!fir.ref<!fir.box<!fir.array<?xf32>>>) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>> | ||
| ! CHECK: %[[VAL_4:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>>, f32) map_clauses(implicit, tofrom) capture(ByRef) var_ptr_ptr(%[[VAL_3]] : !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>>) bounds(%{{.*}}) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>> {name = ""} | ||
| ! CHECK: %[[VAL_5:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>>, !fir.box<!fir.array<?xf32>>) map_clauses(implicit, to) capture(ByRef) members(%[[VAL_4]] : [0] : !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>>) -> !fir.ref<!fir.array<?xf32>> {name = "dt"} | ||
| ! CHECK: omp.target host_eval({{.*}}) map_entries({{.*}}%[[VAL_5]] -> {{.*}}, %[[VAL_4]] -> {{.*}} : {{.*}}) { | ||
| ! CHECK: } else { | ||
| ! CHECK: %[[VAL_6:.*]] = fir.is_present %[[VAL_1]]#1 : (!fir.box<!fir.array<?xf32>>) -> i1 | ||
| ! CHECK: fir.if %[[VAL_6]] { | ||
| ! CHECK: fir.store %[[VAL_1]]#1 to %[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>> | ||
| ! CHECK: } | ||
| ! CHECK: %[[VAL_7:.*]] = fir.box_offset %[[VAL_0]] base_addr : (!fir.ref<!fir.box<!fir.array<?xf32>>>) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>> | ||
| ! CHECK: %[[VAL_8:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>>, f32) map_clauses(implicit, tofrom) capture(ByRef) var_ptr_ptr(%[[VAL_7]] : !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>>) bounds(%{{.*}}) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>> {name = ""} | ||
| ! CHECK: %[[VAL_9:.*]] = omp.map.info var_ptr(%[[VAL_0]] : !fir.ref<!fir.box<!fir.array<?xf32>>>, !fir.box<!fir.array<?xf32>>) map_clauses(implicit, to) capture(ByRef) members(%[[VAL_8]] : [0] : !fir.llvm_ptr<!fir.ref<!fir.array<?xf32>>>) -> !fir.ref<!fir.array<?xf32>> {name = "dt"} | ||
| ! CHECK: omp.target host_eval({{.*}}) map_entries({{.*}}, %[[VAL_9]] ->{{.*}}, %[[VAL_8]] -> {{.*}} : {{.*}}) { | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| ! OpenMP offloading test that checks we do not cause a segfault when mapping | ||
|
||
| ! optional function arguments (present or otherwise). No results requiring | ||
| ! checking other than that the program compiles and runs to completion with no | ||
| ! error. This particular variation checks that we're correctly emitting the | ||
| ! load/store in both branches mapping the input array. | ||
| ! REQUIRES: flang, amdgpu | ||
|
|
||
| ! RUN: %libomptarget-compile-fortran-run-and-check-generic | ||
| module reproducer_mod | ||
| contains | ||
| subroutine branching_target_call(dt, switch) | ||
| implicit none | ||
| real(4), dimension(:), intent(inout) :: dt | ||
| logical, intent(in) :: switch | ||
| integer :: dim, idx | ||
|
|
||
| dim = size(dt) | ||
| if (switch) then | ||
| !$omp target teams distribute parallel do | ||
| do idx = 1, dim | ||
| dt(idx) = 20 | ||
| end do | ||
| else | ||
| !$omp target teams distribute parallel do | ||
| do idx = 1, dim | ||
| dt(idx) = 30 | ||
| end do | ||
| end if | ||
| end subroutine branching_target_call | ||
| end module reproducer_mod | ||
|
|
||
| program reproducer | ||
| use reproducer_mod | ||
| implicit none | ||
| real(4), dimension(:), allocatable :: dt | ||
| integer :: n = 21312 | ||
| integer :: i | ||
|
|
||
| allocate (dt(n)) | ||
| call branching_target_call(dt, .FALSE.) | ||
| call branching_target_call(dt, .TRUE.) | ||
| print *, "PASSED" | ||
| end program reproducer | ||
|
|
||
| ! CHECK: PASSED | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use some more consistent formatting for the test code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, I now have the power of fprettify at my finger tips... :-)