-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[OpenMP] Add PointerAssociateScalar to Cray Pointer used in the DSA #133232
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2033cea
[OpenMP] Add PointerAssociateScalar to Cray Pointer used in the DSA
Thirumalai-Shaktivel 1cf40a0
Fix clang format
Thirumalai-Shaktivel bd64bc8
GetUltimate for CrayPointee
Thirumalai-Shaktivel c54ea08
Add tests
Thirumalai-Shaktivel b0d1885
Fix clang format
Thirumalai-Shaktivel b993f61
Update flang/test/Lower/OpenMP/cray-pointers02.f90
mjklemm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| ! Test lowering of Cray pointee references. | ||
| ! RUN: flang -fc1 -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s | ||
|
|
||
| module test_host_assoc_cray_pointer | ||
| ! CHECK-LABEL: fir.global @_QMtest_host_assoc_cray_pointerEivar : i64 | ||
| real*8 var(*) | ||
| ! CHECK-LABEL: fir.global @_QMtest_host_assoc_cray_pointerEvar : !fir.array<?xf64> | ||
| pointer(ivar,var) | ||
|
|
||
| contains | ||
|
|
||
| ! CHECK-LABEL: func.func @_QMtest_host_assoc_cray_pointerPset_cray_pointer() | ||
| subroutine set_cray_pointer | ||
| ! CHECK: %[[ALLOCA:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xf64>>> | ||
| ! CHECK: %[[IVAR_ADDR:.*]] = fir.address_of(@_QMtest_host_assoc_cray_pointerEivar) : !fir.ref<i64> | ||
| ! CHECK: %[[IVAR_DECL:.*]]:2 = hlfir.declare %[[IVAR_ADDR]] {uniq_name = "_QMtest_host_assoc_cray_pointerEivar"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>) | ||
| ! CHECK: %[[VAR_DECL:.*]]:2 = hlfir.declare %[[ALLOCA]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QMtest_host_assoc_cray_pointerEvar"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) | ||
| real*8 pointee(2) | ||
| pointee(1) = 42.0 | ||
|
|
||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel default(none) shared(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: %[[I_01:.*]] = fir.convert %[[IVAR_DECL]]#0 : (!fir.ref<i64>) -> !fir.ref<!fir.ptr<i64>> | ||
| ! CHECK: %[[I_02:.*]] = fir.load %[[I_01]] : !fir.ref<!fir.ptr<i64>> | ||
| ! CHECK: %[[I_03:.*]] = fir.convert %[[VAR_DECL]]#0 : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) -> !fir.ref<!fir.box<none>> | ||
| ! CHECK: %[[I_04:.*]] = fir.convert %[[I_02]] : (!fir.ptr<i64>) -> !fir.llvm_ptr<i8> | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar(%[[I_03]], %[[I_04]]) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| print *, var(1) | ||
| !$omp end parallel | ||
| end subroutine | ||
| end module | ||
|
|
||
| program test_cray_pointers_01 | ||
| real*8, save :: var(*) | ||
| ! CHECK: %[[BOX_ALLOCA:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xf64>>> | ||
| ! CHECK: %[[IVAR_ALLOCA:.*]] = fir.alloca i64 {bindc_name = "ivar", uniq_name = "_QFEivar"} | ||
| ! CHECK: %[[IVAR_DECL_01:.*]]:2 = hlfir.declare %[[IVAR_ALLOCA]] {uniq_name = "_QFEivar"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>) | ||
| pointer(ivar,var) | ||
| ! CHECK: %[[VAR_DECL_02:.*]]:2 = hlfir.declare %[[BOX_ALLOCA]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFEvar"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) -> (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf64>>>>) | ||
|
|
||
| real*8 pointee(2) | ||
| pointee(1) = 42.0 | ||
|
|
||
| !$omp parallel default(none) private(ivar) shared(pointee) | ||
| ! CHECK: omp.parallel private({{.*}} %[[IVAR_DECL_01]]#0 -> %[[ARG0:.*]] : !fir.ref<i64>) { | ||
| ! CHECK: %[[IVAR_DECL_02:.*]]:2 = hlfir.declare %[[ARG0]] {uniq_name = "_QFEivar"} : (!fir.ref<i64>) -> (!fir.ref<i64>, !fir.ref<i64>) | ||
| ! CHECK: hlfir.assign %{{.*}} to %[[IVAR_DECL_02]]#0 : i64, !fir.ref<i64> | ||
| ivar = loc(pointee) | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: %[[CONST_2:.*]] = arith.constant 2 : i32 | ||
| ! CHECK: {{.*}} = math.fpowi {{.*}}, %[[CONST_2]] fastmath<contract> : f64, i32 | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) ** 2 | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| print *, var(1) | ||
| ! CHECK: omp.terminator | ||
| ! CHECK: } | ||
| !$omp end parallel | ||
| end program test_cray_pointers_01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,180 @@ | ||
| ! Test lowering of Cray pointee references. | ||
| ! RUN: flang -fc1 -emit-hlfir -fopenmp %s -o - 2>&1 | FileCheck %s | ||
|
|
||
| ! CHECK-LABEL: func.func @_QQmain() attributes {fir.bindc_name = "test_cray_pointers_02"} | ||
| program test_cray_pointers_02 | ||
| implicit none | ||
|
|
||
| ! CHECK: fir.call @_QPnone_shared() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPnone_private() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPnone_firstprivate() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPprivate_shared() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPprivate_firstprivate() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPfirstprivate_shared() fastmath<contract> : () -> () | ||
| ! CHECK: fir.call @_QPfirstprivate_private() fastmath<contract> : () -> () | ||
| call none_shared() | ||
| call none_private() | ||
| call none_firstprivate() | ||
| call private_shared() | ||
| call private_firstprivate() | ||
| call firstprivate_shared() | ||
| call firstprivate_private() | ||
| ! CHECK: return | ||
| ! CHECK: } | ||
| end program test_cray_pointers_02 | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPnone_shared() | ||
| subroutine none_shared() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(none) shared(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = arith.divsi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) / 2 | ||
| print '(A24,I6)', 'none_shared', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPnone_private() | ||
| subroutine none_private() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(none) private(ivar) shared(pointee) | ||
| ! CHECK: omp.parallel | ||
| ivar = loc(pointee) | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = arith.addi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) + 2 | ||
| print '(A24,I6)', 'none_private', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPnone_firstprivate() | ||
| subroutine none_firstprivate() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(none) firstprivate(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = arith.muli | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) * 2 | ||
| print '(A24,I6)', 'none_firstprivate', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPprivate_shared() | ||
| subroutine private_shared() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(private) shared(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = math.ipowi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) ** 2 | ||
| print '(A24,I6)', 'private_shared', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPprivate_firstprivate() | ||
| subroutine private_firstprivate() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(private) firstprivate(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = arith.subi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) - 2 | ||
| print '(A24,I6)', 'private_firstprivate', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPfirstprivate_shared() | ||
| subroutine firstprivate_shared() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(firstprivate) shared(ivar) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = arith.divsi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| var(1) = var(1) / 2 | ||
| print '(A24,I6)', 'firstprivate_shared', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
|
|
||
| ! CHECK-LABEL: func.func @_QPfirstprivate_private() | ||
| subroutine firstprivate_private() | ||
| implicit none | ||
| integer var(*) | ||
| pointer(ivar,var) | ||
| integer pointee(8) | ||
|
|
||
| pointee(1) = 42 | ||
| ivar = loc(pointee) | ||
|
|
||
| !$omp parallel num_threads(1) default(firstprivate) private(ivar) shared(pointee) | ||
| ! CHECK: omp.parallel | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: {{.*}} = math.ipowi | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ! CHECK: fir.call @_FortranAPointerAssociateScalar({{.*}}) fastmath<contract> : (!fir.ref<!fir.box<none>>, !fir.llvm_ptr<i8>) -> () | ||
| ivar = loc(pointee) | ||
| var(1) = var(1) ** 2 | ||
| print '(A24,I6)', 'firstprivate_private', var(1) | ||
| !$omp end parallel | ||
| ! CHECK: return | ||
| end subroutine | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.