Skip to content
Draft
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
11 changes: 9 additions & 2 deletions include/PTO/IR/PTOOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1465,10 +1465,16 @@ def TMovOp : PTO_TOp<"tmov", [
return ::mlir::pto::PIPE::PIPE_V;
}

// MAT -> L0 (Left/Right/Bias/Scaling) are MTE1 moves.
// MAT -> Scaling moves L1 data into the fixpipe parameter buffer.
if (s == ::mlir::pto::AddressSpace::MAT &&
d == ::mlir::pto::AddressSpace::SCALING) {
return ::mlir::pto::PIPE::PIPE_FIX;
}

// MAT -> L0 (Left/Right/Bias) moves are executed by MTE1.
if ((s == ::mlir::pto::AddressSpace::MAT &&
(d == ::mlir::pto::AddressSpace::LEFT || d == ::mlir::pto::AddressSpace::RIGHT ||
d == ::mlir::pto::AddressSpace::BIAS || d == ::mlir::pto::AddressSpace::SCALING))) {
d == ::mlir::pto::AddressSpace::BIAS))) {
return ::mlir::pto::PIPE::PIPE_MTE1;
}

Expand Down Expand Up @@ -6576,6 +6582,7 @@ def TSqrtOp: PTO_TOp<"tsqrt", [
def TStoreFPOp: PTO_TOp<"tstore_fp", [
PTO_DpsInitOpInterface,
OpPipeInterface,
DeclareOpInterfaceMethods<MemoryEffectsOpInterface>
]> {
let summary = "TSTORE_FP: Store an accumulator tile into global memory using a scaling (fp) tile for vector quantization parameters.";

Expand Down
8 changes: 8 additions & 0 deletions lib/PTO/IR/PTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13693,6 +13693,14 @@ void TStoreOp::getEffects(SmallVectorImpl<SideEffects::EffectInstance<MemoryEffe
addEffect(effects, &getDstMutable(), MemoryEffects::Write::get());
}

// === TStoreFPOp ===
// Read: src (ACC), fp (scaling), Write: dst (GM)
void TStoreFPOp::getEffects(SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>> &effects) {
addEffect(effects, &getSrcMutable(), MemoryEffects::Read::get());
addEffect(effects, &getFpMutable(), MemoryEffects::Read::get());
addEffect(effects, &getDstMutable(), MemoryEffects::Write::get());
}

// === TMovOp ===
// Read: src, Write: dst
void TMovOp::getEffects(SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>> &effects) {
Expand Down
6 changes: 4 additions & 2 deletions lib/PTO/IR/VPTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2830,9 +2830,11 @@ static LogicalResult verifyStructuredAccStoreLike(
if (!isStructuredAccStoreScalingPayload(preQuant))
return op->emitOpError("vector pre_quant mode requires scaling pointer payload");
if (!isStructuredAccStoreFloatScalarPayloadType(
getStructuredAccStoreScalingElementType(preQuant)))
getStructuredAccStoreScalingElementType(preQuant)) &&
getStructuredAccStoreScalingElementType(preQuant) !=
IntegerType::get(op->getContext(), 64, IntegerType::Unsigned))
return op->emitOpError(
"vector pre_quant mode requires scaling pointer element type to be f16, bf16, or f32");
"vector pre_quant mode requires scaling pointer element type to be f16, bf16, f32, or packed ui64 Quant_PRE entries");
} else if (!isStructuredAccStoreFloatScalarPayload(preQuant)) {
return op->emitOpError(
"scalar pre_quant mode requires f16/bf16/f32 payload");
Expand Down
18 changes: 8 additions & 10 deletions lib/PTO/Transforms/ExpandTileOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,14 @@ func::FuncOp ExpandState::invokeTilelangDaemon(const SpecKey &key,
func::FuncOp ExpandState::invokeTilelangDSL(const SpecKey &key,
Operation *tileOp,
ModuleOp mod, MLIRContext *ctx) {
std::string uniqueName = buildUniqueFunctionBaseName(key);
SymbolTable targetSymTable(mod);
if (auto existingFunc = targetSymTable.lookup(uniqueName)) {
llvm::errs() << "ExpandTileOp: reuse existing function @" << uniqueName
<< "\n";
return cast<func::FuncOp>(existingFunc);
}

// Try daemon first if daemon socket path is provided.
if (!daemonSocketPath.empty()) {
func::FuncOp daemonResult = invokeTilelangDaemon(key, tileOp, mod, ctx);
Expand Down Expand Up @@ -1189,16 +1197,6 @@ func::FuncOp ExpandState::invokeTilelangDSL(const SpecKey &key,
SmallVector<func::FuncOp, 4> clonedFuncs;
llvm::StringMap<std::string> renamedSymbols;

std::string uniqueName = buildUniqueFunctionBaseName(key);

// Check if function already exists in module (deduplication)
SymbolTable targetSymTable(mod);
if (auto existingFunc = targetSymTable.lookup(uniqueName)) {
// Function already exists, return it directly (avoid redefinition)
llvm::errs() << "ExpandTileOp: reuse existing function @" << uniqueName << "\n";
return cast<func::FuncOp>(existingFunc);
}

std::vector<std::string> newNameStorage;
for (auto [index, fn] : llvm::enumerate(parsedFuncs)) {
IRMapping mapping;
Expand Down
2 changes: 2 additions & 0 deletions lib/PTO/Transforms/VPTOCANN900LLVMEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,8 @@ static std::string getCopyElementFragment(Type elementType) {
return intType.isUnsigned() ? "u16" : "s16";
case 32:
return intType.isUnsigned() ? "u32" : "s32";
case 64:
return "s32";
default:
return {};
}
Expand Down
2 changes: 2 additions & 0 deletions lib/PTO/Transforms/VPTOLLVMEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ static std::string getCopyElementFragment(Type elementType) {
return intType.isUnsigned() ? "u16" : "s16";
case 32:
return intType.isUnsigned() ? "u32" : "s32";
case 64:
return "s32";
default:
return {};
}
Expand Down
Loading
Loading