@@ -204,28 +204,6 @@ struct LayoutInfoLattice : public Lattice<LayoutInfo> {
204204 using Lattice::Lattice;
205205};
206206
207- // / Helper Function to find a proper instruction multiple for the user-supplied
208- // / sg-level data shape. `candidates` are uArch allowed shapes.
209- // / `candidateMultiples` are uArch multiples of such shapes (e.g., block count).
210- template <typename T>
211- int getLargestDivisor (T dim, ArrayRef<T> candidates,
212- ArrayRef<T> candidateMultiples = {}) {
213- static_assert (std::is_integral<T>::value, " T must be an integer type" );
214- int largest = -1 ;
215- SmallVector<T> multiples = {1 };
216- if (!candidateMultiples.empty ())
217- multiples =
218- SmallVector<T>(candidateMultiples.begin (), candidateMultiples.end ());
219- for (T candidate : candidates) {
220- for (T multiple : multiples) {
221- int value = static_cast <int >(candidate * multiple);
222- if (value != 0 && dim % value == 0 && value > largest)
223- largest = value;
224- }
225- }
226- return largest;
227- }
228-
229207// / Helper Functions to get default layouts. A `default layout` is a layout that
230208// / is assigned to a value when the layout is not fixed by some anchor operation
231209// / (like DPAS).
@@ -505,7 +483,7 @@ void LayoutInfoPropagation::visitPrefetchNdOp(
505483 prefetch.emitWarning (" No known block params found for the element type." );
506484 auto [bWidth, bHeight, bCount] = blockWHC.value ();
507485 SmallVector<int > instData;
508- int instWidth = getLargestDivisor (
486+ int instWidth = xegpu:: getLargestDivisor (
509487 static_cast <int >(tdescTy.getDimSize (tdescTy.getRank () - 1 )), bWidth,
510488 bCount);
511489 if (instWidth == -1 )
@@ -514,7 +492,7 @@ void LayoutInfoPropagation::visitPrefetchNdOp(
514492 if (tdescTy.getRank () == 1 )
515493 instData = {instWidth};
516494 else {
517- int instHeight = getLargestDivisor (
495+ int instHeight = xegpu:: getLargestDivisor (
518496 static_cast <int >(tdescTy.getDimSize (tdescTy.getRank () - 2 )), bHeight);
519497 if (instHeight == -1 )
520498 prefetch.emitWarning (
@@ -634,15 +612,15 @@ void LayoutInfoPropagation::visitDpasOp(
634612 const unsigned dataALen = aTy.getShape ().front ();
635613 auto supportedALen = uArchInstruction->getSupportedM (aTy.getElementType ());
636614 const int maxALen =
637- getLargestDivisor (dataALen, ArrayRef<unsigned >(supportedALen));
615+ xegpu:: getLargestDivisor (dataALen, ArrayRef<unsigned >(supportedALen));
638616 if (maxALen == -1 )
639617 dpas.emitWarning (
640618 " No suitable instruction multiple found for the given shape." );
641619
642620 const unsigned dataBLen = bTy.getShape ().back ();
643621 auto supportedBLen = uArchInstruction->getSupportedK (bTy.getElementType ());
644622 const int maxBLen =
645- getLargestDivisor (dataBLen, ArrayRef<unsigned >(supportedBLen));
623+ xegpu:: getLargestDivisor (dataBLen, ArrayRef<unsigned >(supportedBLen));
646624 if (maxBLen == -1 )
647625 dpas.emitWarning (
648626 " No suitable instruction multiple found for the given shape." );
@@ -662,7 +640,7 @@ void LayoutInfoPropagation::visitDpasOp(
662640 const unsigned dataCLen = bTy.getShape ().back ();
663641 auto supportedCLen = uArchInstruction->getSupportedN (bTy.getElementType ());
664642 const int maxCLen =
665- getLargestDivisor (dataCLen, ArrayRef<unsigned >(supportedCLen));
643+ xegpu:: getLargestDivisor (dataCLen, ArrayRef<unsigned >(supportedCLen));
666644 if (maxCLen == -1 )
667645 dpas.emitWarning (
668646 " No suitable instruction multiple found for the given shape." );
@@ -691,7 +669,7 @@ void LayoutInfoPropagation::visitStoreNdOp(
691669 store.emitWarning (" No known block params found for the element type." );
692670 auto [bWidth, bHeight, bCount] = blockWHC.value ();
693671 SmallVector<int > instData;
694- int instWidth = getLargestDivisor (
672+ int instWidth = xegpu:: getLargestDivisor (
695673 static_cast <int >(dataTy.getDimSize (dataTy.getRank () - 1 )), bWidth,
696674 bCount);
697675 if (instWidth == -1 )
@@ -700,7 +678,7 @@ void LayoutInfoPropagation::visitStoreNdOp(
700678 if (dataTy.getRank () == 1 )
701679 instData = {instWidth};
702680 else {
703- int instHeight = getLargestDivisor (
681+ int instHeight = xegpu:: getLargestDivisor (
704682 static_cast <int >(dataTy.getDimSize (dataTy.getRank () - 2 )), bHeight);
705683 if (instHeight == -1 )
706684 store.emitWarning (
0 commit comments