-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Utils][mlir] Fix interaction between CodeExtractor and OpenMPIRBuilder #145051
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 all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
de6e916
[Utils][mlir] Fix interaction between CodeExtractor and OpenMPIRBuilder
mrkajetanp 10ed535
Run OMPIRBuilder->finalize() in the destructor if it has not already run
mrkajetanp 53eab2c
Move same function check to findAllocaInsertPoint, add assert in Code…
mrkajetanp 70dad6d
Merge branch 'main' into fix-nested-code-extractor
mrkajetanp 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
2 changes: 1 addition & 1 deletion
2
llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
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
62 changes: 62 additions & 0 deletions
62
mlir/test/Target/LLVMIR/openmp-nested-task-target-parallel.mlir
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,62 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
// This tests the fix for https://github.com/llvm/llvm-project/issues/138102 | ||
// We are only interested in ensuring that the -mlir-to-llvmir pass doesn't crash | ||
|
||
// CHECK-LABEL: define internal void @_QQmain..omp_par | ||
|
||
omp.private {type = private} @_QFEi_private_i32 : i32 | ||
omp.private {type = firstprivate} @_QFEc_firstprivate_i32 : i32 copy { | ||
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): | ||
%0 = llvm.load %arg0 : !llvm.ptr -> i32 | ||
llvm.store %0, %arg1 : i32, !llvm.ptr | ||
omp.yield(%arg1 : !llvm.ptr) | ||
} | ||
llvm.func @_QQmain() { | ||
%0 = llvm.mlir.constant(1 : i64) : i64 | ||
%1 = llvm.alloca %0 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr | ||
%2 = llvm.mlir.constant(1 : i64) : i64 | ||
%3 = llvm.alloca %2 x i32 {bindc_name = "c"} : (i64) -> !llvm.ptr | ||
%4 = llvm.mlir.constant(10 : index) : i64 | ||
%5 = llvm.mlir.constant(0 : index) : i64 | ||
%6 = llvm.mlir.constant(10000 : index) : i64 | ||
%7 = llvm.mlir.constant(1 : index) : i64 | ||
%8 = llvm.mlir.constant(1 : i64) : i64 | ||
%9 = llvm.mlir.addressof @_QFECchunksz : !llvm.ptr | ||
%10 = llvm.mlir.constant(1 : i64) : i64 | ||
%11 = llvm.trunc %7 : i64 to i32 | ||
llvm.br ^bb1(%11, %4 : i32, i64) | ||
^bb1(%12: i32, %13: i64): // 2 preds: ^bb0, ^bb2 | ||
%14 = llvm.icmp "sgt" %13, %5 : i64 | ||
llvm.store %12, %3 : i32, !llvm.ptr | ||
omp.task private(@_QFEc_firstprivate_i32 %3 -> %arg0 : !llvm.ptr) { | ||
%19 = omp.map.info var_ptr(%1 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "i"} | ||
%20 = omp.map.info var_ptr(%arg0 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "c"} | ||
%21 = omp.map.info var_ptr(%9 : !llvm.ptr, i32) map_clauses(implicit, exit_release_or_enter_alloc) capture(ByCopy) -> !llvm.ptr {name = "chunksz"} | ||
omp.target map_entries(%19 -> %arg1, %20 -> %arg2, %21 -> %arg3 : !llvm.ptr, !llvm.ptr, !llvm.ptr) { | ||
%22 = llvm.mlir.constant(9999 : i32) : i32 | ||
%23 = llvm.mlir.constant(1 : i32) : i32 | ||
omp.parallel { | ||
%24 = llvm.load %arg2 : !llvm.ptr -> i32 | ||
%25 = llvm.add %24, %22 : i32 | ||
omp.wsloop private(@_QFEi_private_i32 %arg1 -> %arg4 : !llvm.ptr) { | ||
omp.loop_nest (%arg5) : i32 = (%24) to (%25) inclusive step (%23) { | ||
llvm.store %arg5, %arg4 : i32, !llvm.ptr | ||
omp.yield | ||
} | ||
} | ||
omp.terminator | ||
} | ||
omp.terminator | ||
} | ||
omp.terminator | ||
} | ||
llvm.return | ||
} | ||
llvm.mlir.global internal constant @_QFECchunksz() {addr_space = 0 : i32} : i32 { | ||
%0 = llvm.mlir.constant(10000 : i32) : i32 | ||
llvm.return %0 : i32 | ||
} | ||
llvm.mlir.global internal constant @_QFECn() {addr_space = 0 : i32} : i32 { | ||
%0 = llvm.mlir.constant(100000 : i32) : i32 | ||
llvm.return %0 : i32 | ||
} |
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.
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.
I think we can move module verification to
~ModuleTranslation
instead. This way we both make sure that verification happens after finalization and we do not need to add theisFinalized
bool.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.
We could do this, but then we'd have to change the signature of
mlir::translateModuleToLLVMIR
to remove thedisableVerification
option as it would no longer be possible to run the translation without verification, because verification would always happen in the destructor. Is this desirable?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.
I think leaving it here makes more sense indeed. Thanks for looking into it.