-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give it a proper signature for value-semantics and reference-semantics. It now needs to return values if taking values in, and need only an in-place operand if reference-semantics. Update the distribution pass, to replace the loaded values by the swapped values, building a consistent def-use chain. --------- Co-authored-by: n-io <[email protected]>
- Loading branch information
1 parent
5c4bcf4
commit 4704025
Showing
10 changed files
with
120 additions
and
53 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,28 +1,30 @@ | ||
// RUN: xdsl-opt -p canonicalize-dmp %s | filecheck %s | ||
|
||
builtin.module { | ||
%ref = "test.op"() : () -> (memref<1024x1024xf32>) | ||
%ref = "test.op"() : () -> (!stencil.field<[0,1024]x[0,1024]xf32>) | ||
%val = "test.op"() : () -> (!stencil.temp<[0,1024]x[0,1024]xf32>) | ||
|
||
"dmp.swap"(%ref) { | ||
strategy = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, | ||
swaps = [ | ||
#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>, | ||
#dmp.exchange<at [4, 104] size [100, 0] source offset [0, -4] to [1, 0]> | ||
] | ||
} : (memref<1024x1024xf32>) -> () | ||
} : (!stencil.field<[0,1024]x[0,1024]xf32>) -> () | ||
|
||
// CHECK: "dmp.swap"(%ref) {"strategy" = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, "swaps" = [#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>]} : (memref<1024x1024xf32>) -> () | ||
// CHECK: "dmp.swap"(%ref) {"strategy" = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, "swaps" = [#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>]} : (!stencil.field<[0,1024]x[0,1024]xf32>) -> () | ||
|
||
"dmp.swap"(%ref) { | ||
%swap_val = "dmp.swap"(%val) { | ||
strategy = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, | ||
swaps = [ | ||
#dmp.exchange<at [4, 0] size [100, 0] source offset [0, 4] to [-1, 0]>, | ||
#dmp.exchange<at [4, 104] size [100, 0] source offset [0, -4] to [1, 0]> | ||
] | ||
} : (memref<1024x1024xf32>) -> () | ||
} : (!stencil.temp<[0,1024]x[0,1024]xf32>) -> (!stencil.temp<[0,1024]x[0,1024]xf32>) | ||
|
||
"test.op"() : () -> () | ||
"test.op"(%swap_val) : (!stencil.temp<[0,1024]x[0,1024]xf32>) -> () | ||
|
||
// this op should be completely removed since both exchanges are empty, so we expect the next op to be a test.op | ||
// CHECK-NEXT: "test.op"() : () -> () | ||
// and its operand replaced by the unswapped input | ||
// CHECK-NEXT: "test.op"(%val) : (!stencil.temp<[0,1024]x[0,1024]xf32>) -> () | ||
} |
This file contains 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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
// RUN: XDSL_ROUNDTRIP | ||
|
||
builtin.module { | ||
%ref = "test.op"() : () -> (memref<1024x1024xf32>) | ||
%ref = "test.op"() : () -> (!stencil.field<[0,1024]x[0,1024]xf32>) | ||
%val = "test.op"() : () -> (!stencil.temp<[0,1024]x[0,1024]xf32>) | ||
|
||
"dmp.swap"(%ref) { | ||
strategy = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, | ||
swaps = [ | ||
#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>, | ||
#dmp.exchange<at [4, 104] size [100, 4] source offset [0, -4] to [1, 0]> | ||
] | ||
} : (memref<1024x1024xf32>) -> () | ||
} : (!stencil.field<[0,1024]x[0,1024]xf32>) -> () | ||
|
||
// CHECK: "dmp.swap"(%ref) {"strategy" = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, "swaps" = [#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>, #dmp.exchange<at [4, 104] size [100, 4] source offset [0, -4] to [1, 0]>]} : (memref<1024x1024xf32>) -> () | ||
|
||
%swap_val = "dmp.swap"(%val) { | ||
strategy = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, | ||
swaps = [ | ||
#dmp.exchange<at [4, 0] size [100, 2] source offset [0, 4] to [-1, 0]>, | ||
#dmp.exchange<at [4, 104] size [100, 2] source offset [0, -4] to [1, 0]> | ||
] | ||
} : (!stencil.temp<[0,1024]x[0,1024]xf32>) -> (!stencil.temp<[0,1024]x[0,1024]xf32>) | ||
|
||
// CHECK: "dmp.swap"(%ref) {"strategy" = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, "swaps" = [#dmp.exchange<at [4, 0] size [100, 4] source offset [0, 4] to [-1, 0]>, #dmp.exchange<at [4, 104] size [100, 4] source offset [0, -4] to [1, 0]>]} : (!stencil.field<[0,1024]x[0,1024]xf32>) -> () | ||
// CHECK-NEXT: %swap_val = "dmp.swap"(%val) {"strategy" = #dmp.grid_slice_2d<#dmp.topo<2x2>, false>, "swaps" = [#dmp.exchange<at [4, 0] size [100, 2] source offset [0, 4] to [-1, 0]>, #dmp.exchange<at [4, 104] size [100, 2] source offset [0, -4] to [1, 0]>]} : (!stencil.temp<[0,1024]x[0,1024]xf32>) -> !stencil.temp<[0,1024]x[0,1024]xf32> | ||
} |
This file contains 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 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 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 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 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 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 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 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