-
Notifications
You must be signed in to change notification settings - Fork 15.9k
[flang][OpenMP] Lower target .. private(..) to omp.private ops
#94195
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 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
75291f1
[flang][OpenMP] Lower `target .. private(..)` to `omp.private` ops
ergawy 9e73ff4
add test descriptions
ergawy 02c4c39
Merge remote-tracking branch 'upstream/main' into target_private_delayed
ergawy 8ce67bb
abstract and comment shared code
ergawy 7d326f5
Merge remote-tracking branch 'upstream/main' into target_private_delayed
ergawy 52ebe3e
add more extensive test
ergawy 591a341
add more check lines
ergawy e8a754b
Merge remote-tracking branch 'upstream/main' into target_private_delayed
ergawy 6ab5849
Merge remote-tracking branch 'upstream/main' into target_private_delayed
ergawy 0d2a3df
fix typo
ergawy 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
71 changes: 71 additions & 0 deletions
71
flang/test/Lower/OpenMP/DelayedPrivatization/target-private-allocatable.f90
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,71 @@ | ||
| ! Tests delayed privatization for `targets ... private(..)` for allocatables. | ||
|
|
||
| ! RUN: %flang_fc1 -emit-hlfir -fopenmp -mmlir --openmp-enable-delayed-privatization \ | ||
| ! RUN: -o - %s 2>&1 | FileCheck %s | ||
| ! RUN: bbc -emit-hlfir -fopenmp --openmp-enable-delayed-privatization -o - %s 2>&1 \ | ||
| ! RUN: | FileCheck %s | ||
|
|
||
| subroutine target_allocatable | ||
| implicit none | ||
| integer, allocatable :: alloc_var | ||
|
|
||
| !$omp target private(alloc_var) | ||
| alloc_var = 10 | ||
| !$omp end target | ||
| end subroutine target_allocatable | ||
|
|
||
| ! CHECK-LABEL: omp.private {type = private} | ||
| ! CHECK-SAME: @[[VAR_PRIVATIZER_SYM:.*]] : | ||
| ! CHECK-SAME: [[TYPE:!fir.ref<!fir.box<!fir.heap<i32>>>]] alloc { | ||
| ! CHECK: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]): | ||
| ! CHECK: %[[PRIV_ALLOC:.*]] = fir.alloca !fir.box<!fir.heap<i32>> {bindc_name = "alloc_var", {{.*}}} | ||
|
|
||
| ! CHECK-NEXT: %[[PRIV_ARG_VAL:.*]] = fir.load %[[PRIV_ARG]] : !fir.ref<!fir.box<!fir.heap<i32>>> | ||
| ! CHECK-NEXT: %[[PRIV_ARG_BOX:.*]] = fir.box_addr %[[PRIV_ARG_VAL]] : (!fir.box<!fir.heap<i32>>) -> !fir.heap<i32> | ||
| ! CHECK-NEXT: %[[PRIV_ARG_ADDR:.*]] = fir.convert %[[PRIV_ARG_BOX]] : (!fir.heap<i32>) -> i64 | ||
| ! CHECK-NEXT: %[[C0:.*]] = arith.constant 0 : i64 | ||
| ! CHECK-NEXT: %[[ALLOC_COND:.*]] = arith.cmpi ne, %[[PRIV_ARG_ADDR]], %[[C0]] : i64 | ||
|
|
||
| ! CHECK-NEXT: fir.if %[[ALLOC_COND]] { | ||
| ! CHECK: %[[PRIV_ALLOCMEM:.*]] = fir.allocmem i32 {fir.must_be_heap = true, {{.*}}} | ||
| ! CHECK-NEXT: %[[PRIV_ALLOCMEM_BOX:.*]] = fir.embox %[[PRIV_ALLOCMEM]] : (!fir.heap<i32>) -> !fir.box<!fir.heap<i32>> | ||
| ! CHECK-NEXT: fir.store %[[PRIV_ALLOCMEM_BOX]] to %[[PRIV_ALLOC]] : !fir.ref<!fir.box<!fir.heap<i32>>> | ||
| ! CHECK-NEXT: } else { | ||
| ! CHECK-NEXT: %[[ZERO_BITS:.*]] = fir.zero_bits !fir.heap<i32> | ||
| ! CHECK-NEXT: %[[ZERO_BOX:.*]] = fir.embox %[[ZERO_BITS]] : (!fir.heap<i32>) -> !fir.box<!fir.heap<i32>> | ||
| ! CHECK-NEXT: fir.store %[[ZERO_BOX]] to %[[PRIV_ALLOC]] : !fir.ref<!fir.box<!fir.heap<i32>>> | ||
| ! CHECK-NEXT: } | ||
|
|
||
| ! CHECK-NEXT: %[[PRIV_DECL:.*]]:2 = hlfir.declare %[[PRIV_ALLOC]] | ||
| ! CHECK-NEXT: omp.yield(%[[PRIV_DECL]]#0 : [[TYPE]]) | ||
|
|
||
| ! CHECK-NEXT: } dealloc { | ||
| ! CHECK-NEXT: ^bb0(%[[PRIV_ARG:.*]]: [[TYPE]]): | ||
|
|
||
| ! CHECK-NEXT: %[[PRIV_VAL:.*]] = fir.load %[[PRIV_ARG]] | ||
| ! CHECK-NEXT: %[[PRIV_ADDR:.*]] = fir.box_addr %[[PRIV_VAL]] | ||
| ! CHECK-NEXT: %[[PRIV_ADDR_I64:.*]] = fir.convert %[[PRIV_ADDR]] | ||
| ! CHECK-NEXT: %[[C0:.*]] = arith.constant 0 : i64 | ||
| ! CHECK-NEXT: %[[PRIV_NULL_COND:.*]] = arith.cmpi ne, %[[PRIV_ADDR_I64]], %[[C0]] : i64 | ||
|
|
||
| ! CHECK-NEXT: fir.if %[[PRIV_NULL_COND]] { | ||
| ! CHECK: %[[PRIV_VAL_2:.*]] = fir.load %[[PRIV_ARG]] | ||
| ! CHECK-NEXT: %[[PRIV_ADDR_2:.*]] = fir.box_addr %[[PRIV_VAL_2]] | ||
| ! CHECK-NEXT: fir.freemem %[[PRIV_ADDR_2]] | ||
| ! CHECK-NEXT: %[[ZEROS:.*]] = fir.zero_bits | ||
| ! CHECK-NEXT: %[[ZEROS_BOX:.*]] = fir.embox %[[ZEROS]] | ||
| ! CHECK-NEXT: fir.store %[[ZEROS_BOX]] to %[[PRIV_ARG]] | ||
| ! CHECK-NEXT: } | ||
|
|
||
| ! CHECK-NEXT: omp.yield | ||
| ! CHECK-NEXT: } | ||
|
|
||
|
|
||
| ! CHECK-LABEL: func.func @_QPtarget_allocatable() { | ||
|
|
||
| ! CHECK: %[[VAR_ALLOC:.*]] = fir.alloca !fir.box<!fir.heap<i32>> | ||
| ! CHECK-SAME: {bindc_name = "alloc_var", {{.*}}} | ||
| ! CHECK: %[[VAR_DECL:.*]]:2 = hlfir.declare %[[VAR_ALLOC]] | ||
|
|
||
| ! CHECK: omp.target private( | ||
| ! CHECK-SAME: @[[VAR_PRIVATIZER_SYM]] %[[VAR_DECL]]#0 -> %{{.*}} : [[TYPE]]) { |
Oops, something went wrong.
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.