Skip to content

Commit 161f980

Browse files
committed
Enable the SLPVectorizer on Triton side with no scheduling part. Remove the SLPVectorizer once the IGCVectorizer works well.
1 parent 1da08d7 commit 161f980

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

third_party/intel/backend/compiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def make_llir(src, metadata, options):
310310
paths = [path for (name, path) in options.extern_libs]
311311
llvm.link_extern_libs(llvm_mod, paths)
312312
intel.optimize_module(llvm_mod, llvm.OPTIMIZE_O3)
313-
if os.getenv("TRITON_INTEL_ENABLE_POST_PROCESS_LLIR", "0") == "1":
313+
if os.getenv("TRITON_INTEL_ENABLE_POST_PROCESS_LLIR", "1") == "1":
314314
intel.post_process_llir(llvm_mod)
315315

316316
# Get some metadata
@@ -335,6 +335,9 @@ def make_spv(src, metadata, options):
335335
else:
336336
metadata["build_flags"] = ""
337337

338+
if os.getenv("TRITON_INTEL_ENABLE_POST_PROCESS_LLIR", "1") == "1":
339+
metadata["build_flags"] += " -igc_opts 'DisablePHIScalarization=1'"
340+
338341
if options.generate_native_code:
339342
with tempfile.NamedTemporaryFile(delete=False, mode='wb', suffix='.spv') as fsrc, \
340343
tempfile.NamedTemporaryFile(delete=False, mode='r', suffix='.log') as flog:

third_party/intel/lib/Target/LLVMIR/SLPVectorizer.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13408,10 +13408,6 @@ Value *BoUpSLP::vectorizeTree(
1340813408
const ExtraValueToDebugLocsMap &ExternallyUsedValues,
1340913409
SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals,
1341013410
Instruction *ReductionRoot) {
13411-
// All blocks must be scheduled before any instructions are inserted.
13412-
for (auto &BSIter : BlocksSchedules) {
13413-
scheduleBlock(BSIter.second.get());
13414-
}
1341513411
// Clean Entry-to-LastInstruction table. It can be affected after scheduling,
1341613412
// need to rebuild it.
1341713413
EntryToLastInstruction.clear();
@@ -15269,7 +15265,11 @@ bool SLPVectorizerPass::runImpl(Function &F, ScalarEvolution *SE_,
1526915265
R.clearReductionData();
1527015266

1527115267
// Vectorize trees that end at reductions.
15268+
// llvm::outs() << "BB befoer vectorize:\n" << *BB << "\n";
15269+
// llvm::outs().flush();
1527215270
Changed |= vectorizeChainsInBlock(BB, R);
15271+
// llvm::outs() << "BB after vectorize:\n" << *BB << "\n";
15272+
// llvm::outs().flush();
1527315273
}
1527415274

1527515275
if (Changed) {
@@ -15436,14 +15436,25 @@ bool SLPVectorizerPass::vectorizeInsertElementInst(InsertElementInst *IEI,
1543615436
return false;
1543715437

1543815438
LLVM_DEBUG(dbgs() << "SLP: array mappable to vector: " << *IEI << "\n");
15439-
return tryToVectorizeList(BuildVectorInsts, R);
15439+
// llvm::outs() << "Before Vectorize the instruction Function:\n" <<
15440+
// *BB->getParent() << "\n";
15441+
auto changed = tryToVectorizeList(BuildVectorInsts, R);
15442+
// llvm::outs() << "After Vectorize the instruction BB:\n" <<
15443+
// *BB->getParent() << "\n"; llvm::outs().flush();
15444+
15445+
return changed;
1544015446
}
1544115447

1544215448
bool SLPVectorizerPass::vectorizeInserts(InstSetVector &Instructions,
1544315449
BasicBlock *BB, BoUpSLP &R) {
1544415450
assert(all_of(Instructions, IsaPred<InsertElementInst>) &&
1544515451
"This function only accepts Insert instructions");
1544615452
bool OpsChanged = false;
15453+
15454+
// for (auto *I : Instructions) {
15455+
// llvm::outs() << "Vectorize insert instructions: " << *I << "\n";
15456+
// llvm::outs().flush();
15457+
// }
1544715458
// Try to match and vectorize a buildvector sequence.
1544815459
for (auto *I : reverse(Instructions)) {
1544915460
if (R.isDeleted(I))
@@ -15545,8 +15556,11 @@ void mlir::triton::intel::SLPVectorizer(llvm::Module &mod, bool trace) {
1554515556
FunctionPassManager FPM;
1554615557
FPM.addPass(SLPVectorizerPass(trace));
1554715558

15559+
// ::llvm::setCurrentDebugType("SLP");
15560+
// ::llvm::DebugFlag = true;
1554815561
for (llvm::Function &function : mod.functions()) {
1554915562
if (isCandidate(function))
1555015563
FPM.run(function, FAM);
1555115564
}
15565+
// ::llvm::DebugFlag = false;
1555215566
}

0 commit comments

Comments
 (0)