-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[mlir][OpenMP] - MLIR to LLVMIR translation support for delayed privatization in omp.target ops.
#109668
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
bhandarkar-pranav
merged 5 commits into
llvm:main
from
bhandarkar-pranav:mlir/target_private_2
Oct 1, 2024
Merged
[mlir][OpenMP] - MLIR to LLVMIR translation support for delayed privatization in omp.target ops.
#109668
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8810596
[mlir][OpenMP] - Implement lowering from MLIR to LLVMIR for private c…
bhandarkar-pranav c690d86
Address review comments
bhandarkar-pranav ee20ced
Address review comments
bhandarkar-pranav 3f4ddcd
Remove some debug prints
bhandarkar-pranav da04f27
Make check for offloaded function name portable across user platforms
bhandarkar-pranav 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
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Please ensure that the IR is properly formatted and is stripped to the absolute minimum to test this feature. |
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,70 @@ | ||
| // RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
|
||
| omp.private {type = private} @simple_var.privatizer : !llvm.ptr alloc { | ||
| ^bb0(%arg0: !llvm.ptr): | ||
| %0 = llvm.mlir.constant(1 : i64) : i64 | ||
| %1 = llvm.alloca %0 x i32 {bindc_name = "simple_var", pinned} : (i64) -> !llvm.ptr | ||
| omp.yield(%1 : !llvm.ptr) | ||
| } | ||
| llvm.func @target_map_single_private() attributes {fir.internal_name = "_QPtarget_map_single_private"} { | ||
| %0 = llvm.mlir.constant(1 : i64) : i64 | ||
| %1 = llvm.alloca %0 x i32 {bindc_name = "simple_var"} : (i64) -> !llvm.ptr | ||
| %3 = llvm.alloca %0 x i32 {bindc_name = "a"} : (i64) -> !llvm.ptr | ||
| %4 = llvm.mlir.constant(2 : i32) : i32 | ||
| llvm.store %4, %3 : i32, !llvm.ptr | ||
| %5 = omp.map.info var_ptr(%3 : !llvm.ptr, i32) map_clauses(to) capture(ByRef) -> !llvm.ptr {name = "a"} | ||
| omp.target map_entries(%5 -> %arg0 : !llvm.ptr) private(@simple_var.privatizer %1 -> %arg1 : !llvm.ptr) { | ||
| ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr): | ||
| %6 = llvm.mlir.constant(10 : i32) : i32 | ||
| %7 = llvm.load %arg0 : !llvm.ptr -> i32 | ||
| %8 = llvm.add %7, %6 : i32 | ||
| llvm.store %8, %arg1 : i32, !llvm.ptr | ||
| omp.terminator | ||
| } | ||
| llvm.return | ||
| } | ||
| // CHECK: define internal void @__omp_offloading_fd00 | ||
| // CHECK-NOT: define {{.*}} | ||
| // CHECK: %[[PRIV_ALLOC:.*]] = alloca i32, i64 1, align 4 | ||
| // CHECK: %[[ADD:.*]] = add i32 {{.*}}, 10 | ||
| // CHECK: store i32 %[[ADD]], ptr %[[PRIV_ALLOC]], align 4 | ||
|
|
||
| omp.private {type = private} @n.privatizer : !llvm.ptr alloc { | ||
| ^bb0(%arg0: !llvm.ptr): | ||
| %0 = llvm.mlir.constant(1 : i64) : i64 | ||
| %1 = llvm.alloca %0 x f32 {bindc_name = "n", pinned} : (i64) -> !llvm.ptr | ||
| omp.yield(%1 : !llvm.ptr) | ||
| } | ||
| llvm.func @target_map_2_privates() attributes {fir.internal_name = "_QPtarget_map_2_privates"} { | ||
| %0 = llvm.mlir.constant(1 : i64) : i64 | ||
| %1 = llvm.alloca %0 x i32 {bindc_name = "simple_var"} : (i64) -> !llvm.ptr | ||
| %3 = llvm.alloca %0 x f32 {bindc_name = "n"} : (i64) -> !llvm.ptr | ||
| %5 = llvm.alloca %0 x i32 {bindc_name = "a"} : (i64) -> !llvm.ptr | ||
| %6 = llvm.mlir.constant(2 : i32) : i32 | ||
| llvm.store %6, %5 : i32, !llvm.ptr | ||
| %7 = omp.map.info var_ptr(%5 : !llvm.ptr, i32) map_clauses(to) capture(ByRef) -> !llvm.ptr {name = "a"} | ||
| omp.target map_entries(%7 -> %arg0 : !llvm.ptr) private(@simple_var.privatizer %1 -> %arg1 : !llvm.ptr, @n.privatizer %3 -> %arg2 : !llvm.ptr) { | ||
| ^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr, %arg2: !llvm.ptr): | ||
| %8 = llvm.mlir.constant(1.100000e+01 : f32) : f32 | ||
| %9 = llvm.mlir.constant(10 : i32) : i32 | ||
| %10 = llvm.load %arg0 : !llvm.ptr -> i32 | ||
| %11 = llvm.add %10, %9 : i32 | ||
| llvm.store %11, %arg1 : i32, !llvm.ptr | ||
| %12 = llvm.load %arg1 : !llvm.ptr -> i32 | ||
| %13 = llvm.sitofp %12 : i32 to f32 | ||
| %14 = llvm.fadd %13, %8 {fastmathFlags = #llvm.fastmath<contract>} : f32 | ||
| llvm.store %14, %arg2 : f32, !llvm.ptr | ||
| omp.terminator | ||
| } | ||
| llvm.return | ||
| } | ||
|
|
||
| // CHECK: define internal void @__omp_offloading_fd00 | ||
| // CHECK: %[[PRIV_I32_ALLOC:.*]] = alloca i32, i64 1, align 4 | ||
| // CHECK: %[[PRIV_FLOAT_ALLOC:.*]] = alloca float, i64 1, align 4 | ||
| // CHECK: %[[ADD_I32:.*]] = add i32 {{.*}}, 10 | ||
| // CHECK: store i32 %[[ADD_I32]], ptr %[[PRIV_I32_ALLOC]], align 4 | ||
| // CHECK: %[[LOAD_I32_AGAIN:.*]] = load i32, ptr %[[PRIV_I32_ALLOC]], align 4 | ||
| // CHECK: %[[CAST_TO_FLOAT:.*]] = sitofp i32 %[[LOAD_I32_AGAIN]] to float | ||
| // CHECK: %[[ADD_FLOAT:.*]] = fadd contract float %[[CAST_TO_FLOAT]], 1.100000e+01 | ||
| // CHECK: store float %[[ADD_FLOAT]], ptr %[[PRIV_FLOAT_ALLOC]], align 4 |
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.