Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions include/PTO/IR/PTOOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,7 @@ def AicInitializePipeOp : PTO_Op<"aic_initialize_pipe"> {
let arguments = (ins
I8Attr:$dir_mask,
I32Attr:$slot_size,
OptionalAttr<BoolAttr>:$nosplit,
Optional<PtrType>:$gm_slot_buffer,
I32:$c2v_consumer_buf,
I32:$v2c_consumer_buf
Expand All @@ -1197,7 +1198,9 @@ def AicInitializePipeOp : PTO_Op<"aic_initialize_pipe"> {

let assemblyFormat = [{
`{` `dir_mask` `=` $dir_mask `,`
`slot_size` `=` $slot_size `}`
`slot_size` `=` $slot_size
(`,` `nosplit` `=` $nosplit^)?
`}`
`(`
(`gm_slot_buffer` `=` $gm_slot_buffer^ `:` type($gm_slot_buffer) `,`)?
`c2v_consumer_buf` `=` $c2v_consumer_buf `:` type($c2v_consumer_buf) `,`
Expand All @@ -1213,6 +1216,7 @@ def AivInitializePipeOp : PTO_Op<"aiv_initialize_pipe"> {
let arguments = (ins
I8Attr:$dir_mask,
I32Attr:$slot_size,
OptionalAttr<BoolAttr>:$nosplit,
Optional<PtrType>:$gm_slot_buffer,
I32:$c2v_consumer_buf,
I32:$v2c_consumer_buf
Expand All @@ -1223,7 +1227,9 @@ def AivInitializePipeOp : PTO_Op<"aiv_initialize_pipe"> {

let assemblyFormat = [{
`{` `dir_mask` `=` $dir_mask `,`
`slot_size` `=` $slot_size `}`
`slot_size` `=` $slot_size
(`,` `nosplit` `=` $nosplit^)?
`}`
`(`
(`gm_slot_buffer` `=` $gm_slot_buffer^ `:` type($gm_slot_buffer) `,`)?
`c2v_consumer_buf` `=` $c2v_consumer_buf `:` type($c2v_consumer_buf) `,`
Expand Down
1 change: 1 addition & 0 deletions include/PTO/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace pto {

std::unique_ptr<Pass> createLoweringSyncToPipePass();
std::unique_ptr<Pass> createPTOLowerFrontendPipeOpsPass();
std::unique_ptr<Pass> createPTOInferValidatePipeInitPass();
std::unique_ptr<Pass> createPTOResolveReservedBuffersPass();
std::unique_ptr<Pass> createPTOWrapFunctionsInSectionsPass();
std::unique_ptr<Pass> createPTOVerifyTFreePass();
Expand Down
26 changes: 23 additions & 3 deletions include/PTO/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,35 @@ def PTOLowerFrontendPipeOps : Pass<"pto-lower-frontend-pipe-ops", "func::FuncOp"
];
}

def PTOInferValidatePipeInit : Pass<"pto-infer-validate-pipe-init", "ModuleOp"> {
let summary = "Infer and validate internal pipe init nosplit configuration";
let description = [{
Runs after frontend pipe lowering and before memory planning. For each
logical pipe, this pass:
- validates that downstream `pto.tpush` / `pto.tpop` / `pto.tfree` users
do not mix `split = 0` with `split = 1/2`
- preserves explicit `nosplit` attrs on internal pipe init ops and rejects
conflicts across peer pipe init pairs
- infers missing `nosplit` attrs from downstream split usage for backward
compatibility with older IR that omitted init-level `nosplit`
- propagates the resolved `nosplit` value across peer pipe init pairs so
both ends of one logical pipe agree before EmitC lowering
}];

let constructor = "mlir::pto::createPTOInferValidatePipeInitPass()";

let dependentDialects = [
"mlir::pto::PTODialect",
"mlir::func::FuncDialect"
];
}

def PTOResolveReservedBuffers : Pass<"pto-resolve-reserved-buffers", "ModuleOp"> {
let summary = "Resolve reserved local buffer addresses and peer pipe flag bases";
let description = [{
Runs after `pto-plan-memory`. Assumes `pto.reserve_buffer` base addresses
have already been planned, then:
- aligns missing `flag_base` attrs for peer internal pipe init ops
- infers implicit `nosplit = true` for internal pipe init ops when any
downstream `pto.tpush` / `pto.tpop` / `pto.tfree` user on the same
logical pipe has `split = 0`
- rejects internal pipe init ops without explicit `flag_base` when their
`local_addr` cannot be traced back to `pto.reserve_buffer` /
`pto.import_reserved_buffer`
Expand Down
1 change: 1 addition & 0 deletions lib/PTO/Transforms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ add_mlir_dialect_library(PTOTransforms
BufferizableOpInterfaceImpl.cpp
ConvertToPTOOp.cpp
PTOLowerFrontendPipeOpsPass.cpp
PTOInferValidatePipeInitPass.cpp
PTOResolveReservedBuffersPass.cpp
PTOWrapFunctionsInSectionsPass.cpp
InsertSync/PTOIRTranslator.cpp
Expand Down
Loading
Loading