-
Notifications
You must be signed in to change notification settings - Fork 30
[Feature] pto.tmrgsort format2 should support 2-way and 3-way merge (currently hardcoded to 4-way) #427
Copy link
Copy link
Open
Labels
Description
Background
pto.tmrgsort currently has two formats:
- format1: single-list intra-block merge,
ins(src, blockLen) - format2: multi-list merge, hardcoded to exactly 4 sources,
ins(src0, src1, src2, src3)
However, the underlying PTO-ISA TMRGSORT instruction supports 2-way, 3-way, and 4-way merges:
// 2-way
TMRGSORT(dst, executedNumList, tmp, src0, src1)
// 3-way
TMRGSORT(dst, executedNumList, tmp, src0, src1, src2)
// 4-way (currently supported)
TMRGSORT(dst, executedNumList, tmp, src0, src1, src2, src3)
Current Limitation
isFormat2() hardcodes a 4-source requirement (include/PTO/IR/PTOOps.td:3246):
bool isFormat2() { return getSrcs().size() == 4u && getDsts().size() == 2u && getExcuted(); }The print function also hardcodes access to exactly 4 srcs (lib/PTO/IR/PTO.cpp:4521-4524).
Passing 2 or 3 sources triggers the catch-all verifier error:
tmrgsort expects format1 (1 src + blockLen + 1 dst) or format2 (4 srcs, outs dst, excuted)
Expected Behavior
format2 should accept 2, 3, or 4 sources. The isFormat2() predicate should be relaxed to srcs.size() >= 2 && srcs.size() <= 4.
Assembly format would become variadic:
// 2-way
pto.tmrgsort ins(%src0, %src1 {exhausted = false} : ...) outs(%dst, %tmp, %excuted : ...)
// 3-way
pto.tmrgsort ins(%src0, %src1, %src2 {exhausted = false} : ...) outs(%dst, %tmp, %excuted : ...)Layers Requiring Changes
-
include/PTO/IR/PTOOps.td— relaxisFormat2()predicate -
lib/PTO/IR/PTO.cpp— updateprint,parse, andverifyto handle variable-length srcs -
lib/PTO/Transforms/PTOViewToMemref.cpp— update lowering patterns for variable-length srcs -
docs/PTO_IR_manual.md— update format2 assembly format description and examples -
test/— add regression tests for 2-way and 3-way cases
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Todo