Skip to content

Commit b3e1d9a

Browse files
DianaChenigcbot
authored andcommitted
IGA SWSB: Refactor dpas macro builder
Removed DpasMacroBuilder::getSuppressionBlockCandidate. Now the dpas macro is formed until a dpas is seen that cannot be in a macro, even if there is no suppression opportunity, i.e. no sources are the same within the macro. There is no performance drawback doing so. This also aligns with vISA's dpas macro logic.
1 parent 025d95a commit b3e1d9a

File tree

2 files changed

+7
-99
lines changed

2 files changed

+7
-99
lines changed

visa/iga/IGALibrary/IR/RegDeps.cpp

Lines changed: 7 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -589,19 +589,12 @@ size_t DepSetBuilder::DpasMacroBuilder::formSrcSuppressionBlock(
589589
BitSet<> allSrcBits(m_dsBuilder.getGRF_LEN());
590590
BitSet<> allDstNoLastBits(m_dsBuilder.getGRF_LEN());
591591
BitSet<> allSrcNoLastBits(m_dsBuilder.getGRF_LEN());
592-
SuppressBlockPtrTy bptr =
593-
getSuppressionBlockCandidate(startIt, srcIdx, allDstBits, allSrcBits,
594-
allDstNoLastBits, allSrcNoLastBits);
595-
if (!bptr)
596-
return 0;
592+
593+
SuppressBlock bptr(
594+
getNumberOfSuppresionGroups(srcIdx), srcIdx == 1 ? 8 : 4);
597595

598596
size_t numSuppressed = 0;
599597
InstListIterator it = startIt;
600-
// advance inst iterator to the next instruction following the block
601-
// Note that this instruction must be a macro candidate, otherwise the
602-
// suppression block won't formed
603-
std::advance(it, bptr->size());
604-
assert(it != m_instList.end());
605598

606599

607600
// find until the last instruction that can be suppressed
@@ -622,18 +615,14 @@ size_t DepSetBuilder::DpasMacroBuilder::formSrcSuppressionBlock(
622615
if (srcOp.getDirRegName() != RegName::GRF_R)
623616
break;
624617

625-
// found the first instruction that can't be suppressed. Stop looking.
626-
if (!bptr->contains(srcOp.getDirRegRef().regNum))
627-
break;
628-
629618
bool skipSetLastBits = false;
630619
if (hasProducerConsumerDep(dst_range, src_range, allDstBits)) {
631620
break;
632621
}
633622

634623
// at this point, we can add this DPAS into the macro
635624
++numSuppressed;
636-
bptr->addRegRanges(src_range, src_extra_range, dst_range);
625+
bptr.addRegRanges(src_range, src_extra_range, dst_range);
637626
if (!skipSetLastBits) {
638627
allSrcNoLastBits = allSrcBits;
639628
allDstNoLastBits = allDstBits;
@@ -650,76 +639,15 @@ size_t DepSetBuilder::DpasMacroBuilder::formSrcSuppressionBlock(
650639
if (numSuppressed) {
651640
// at least one instruction can be suppressed, the candidate block can be in
652641
// the macro udpate register footprint into DepSet
653-
updateRegFootprintsToDepSets(bptr->allSrcRange, bptr->allExtraSrcRange,
654-
bptr->allDstRange);
642+
updateRegFootprintsToDepSets(bptr.allSrcRange, bptr.allExtraSrcRange,
643+
bptr.allDstRange);
655644

656645
// return the total instructions found can be in the macro
657-
return bptr->size() + numSuppressed;
646+
return bptr.size() + numSuppressed;
658647
}
659648
return 0;
660649
}
661650

662-
DepSetBuilder::DpasMacroBuilder::SuppressBlockPtrTy
663-
DepSetBuilder::DpasMacroBuilder::getSuppressionBlockCandidate(
664-
InstListIterator startIt, uint32_t srcIdx, BitSet<> &allDstBits,
665-
BitSet<> &allSrcBits, BitSet<> &allDstNoLastBits,
666-
BitSet<> &allSrcNoLastBits, int forceGroupNum) const {
667-
assert(srcIdx == 1 || srcIdx == 2);
668-
size_t maxGroupNum =
669-
forceGroupNum < 0 ? getNumberOfSuppresionGroups(srcIdx) : forceGroupNum;
670-
// return null if the given src can't be suppressed
671-
if (!maxGroupNum)
672-
return nullptr;
673-
674-
SuppressBlockPtrTy sb(new SuppressBlock(maxGroupNum, srcIdx == 1 ? 8 : 4));
675-
// try from the startIt to see if there are dpas sequence that can form the
676-
// suppression block check number of maxGroupSize to find the first one block
677-
// those can potentially be suppressed
678-
InstListIterator it = startIt;
679-
for (size_t i = 0; i < maxGroupNum; ++i) {
680-
InstListIterator nextIt = it;
681-
++nextIt;
682-
// if next instruction is not a suppression candidate, there's no chance to
683-
// form a suppression block, return nullptr directly
684-
if (nextIt == m_instList.end())
685-
return nullptr;
686-
if (nextIsNotMacroCandidate(**it, **nextIt))
687-
return nullptr;
688-
if (!srcIsSuppressCandidate(**it, srcIdx))
689-
return nullptr;
690-
SrcRegRangeType src_range, src_extra_range;
691-
DstRegRangeType dst_range;
692-
m_inps.getDpasSrcDependency(**it, src_range, src_extra_range, m_model);
693-
m_inps.getDpasDstDependency(**it, dst_range);
694-
if (hasInternalDep(**it, dst_range, src_range,
695-
GetDpasSystolicDepth((*it)->getDpasFc()) == 8))
696-
return nullptr;
697-
698-
bool skipSetLastBits = false;
699-
if (hasProducerConsumerDep(dst_range, src_range, allDstBits)) {
700-
return nullptr;
701-
}
702-
uint16_t reg = (*it)->getSource(srcIdx).getDirRegRef().regNum;
703-
if (sb->partialOverlapped(reg))
704-
return nullptr;
705-
706-
// found the first duplicated register, the block is formed
707-
if (sb->contains(reg))
708-
break;
709-
sb->addRegs(reg);
710-
sb->addRegRanges(src_range, src_extra_range, dst_range);
711-
if (!skipSetLastBits) {
712-
allSrcNoLastBits = allSrcBits;
713-
allDstNoLastBits = allDstBits;
714-
}
715-
setDstSrcBits(src_range, dst_range, allSrcBits, allDstBits);
716-
++it;
717-
}
718-
719-
assert(sb->size());
720-
return sb;
721-
}
722-
723651
bool DepSetBuilder::DpasMacroBuilder::srcIsSuppressCandidate(
724652
const Instruction &inst, uint32_t srcIdx) const {
725653
// src1 always can be the candidate since all dpas depth must be the same

visa/iga/IGALibrary/IR/RegDeps.hpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ class DepSetBuilder {
596596
}
597597

598598
}; // SuppressionBlock
599-
typedef std::unique_ptr<SuppressBlock> SuppressBlockPtrTy;
600599

601600
// get the max number of suppression groups according to srcIdx and platform
602601
size_t getNumberOfSuppresionGroups(uint32_t srcIdx) const;
@@ -606,25 +605,6 @@ class DepSetBuilder {
606605
// instructions found
607606
size_t formSrcSuppressionBlock(InstListIterator startIt, uint32_t srcIdx);
608607

609-
// return the candidate SuppressBlock that is found fulfilling read
610-
// suppression requirement of given src index, start from the give
611-
// instruction. This block is the first candidate block of instructions
612-
// register those can be suppressed. Will need to check if the following
613-
// instructions having the same registers so that they can actually being
614-
// suppressed.
615-
// * return nullptr if there is no chance to suppress the given src
616-
// * allDstBits, allSrcBits - all used grf bits in the return suppressBlock
617-
// * allDstNoLastBits, allSrcNoLastBits - all used grf in the return
618-
// suppressBlock except the
619-
// last instruction's
620-
// * forceGroupNum - force to use the given value as maximum number of
621-
// suppression groups instead of
622-
// getting it from getNumberOfSuppresionGroups
623-
SuppressBlockPtrTy getSuppressionBlockCandidate(
624-
InstListIterator startIt, uint32_t srcIdx, BitSet<> &allDstBits,
625-
BitSet<> &allSrcBits, BitSet<> &allDstNoLastBits,
626-
BitSet<> &allSrcNoLastBits, int forceGroupNum = -1) const;
627-
628608
bool srcIsSuppressCandidate(const Instruction &inst, uint32_t srcIdx) const;
629609

630610
private:

0 commit comments

Comments
 (0)