Skip to content
Open
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
31 changes: 17 additions & 14 deletions Tensile/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,19 +441,6 @@ def supportedCompiler(compiler: str) -> bool:
validMFMA["I8"] = validMFMA["H"] + validMFMA["F8"]
validWMMA = [[16,16,16,1], ]
validTT = 64
validMFMA["_format9"] = []

for MFMA in [validMFMA["H"], validMFMA["S"], validMFMA["B"], validMFMA["D"], validMFMA["X"], validMFMA["F8"], validWMMA]:
for MI in MFMA:
for bm in range(int(math.log(MI[3],2))+1):
for tt0 in range(1,validTT+1):
for tt1 in range(1,validTT+1):
for wave_m in range (3):
for wave_n in range(3):
validMFMA["_format9"].append([MI[0],MI[1],MI[2],MI[3],2**bm,tt0,tt1,2**wave_m, 2**wave_n])

validMatrixInstructions = [[], [-1]] + validMFMA["H"] + validMFMA["S"] + validMFMA["B"] + validMFMA["D"] + validMFMA["X"] + validMFMA["F8"]
validMatrixInstructions = validMatrixInstructions + validMFMA["_format9"]

# The supported typed GEMM, each entry is (Ti, To, Tc).
# DataType (Ti) = The data-type of the input matrices: A/B
Expand Down Expand Up @@ -1060,7 +1047,7 @@ def supportedCompiler(compiler: str) -> bool:
# MatrixInst BlkM WT Wave
# - means (32x64) per MI * (4x1) per wave * (2x2) per workgroup = (32*4*2)x(64*1*2) = 256x128 macro tile
# Tensile will ignore the parameters ThreadTile and WorkGroup when the alternative format is used
"MatrixInstruction": validMatrixInstructions,
"MatrixInstruction": -1,

# StoreRemap: Optimize MatrixInstruction store patterns to enhance performance.
# MI output data between each threads are along N dims.
Expand Down Expand Up @@ -2407,6 +2394,22 @@ def assignGlobalParameters( config, capabilitiesCache: Optional[dict] = None ):
"""
global globalParameters

if False:
validMFMA["_format9"] = []

for MFMA in [validMFMA["H"], validMFMA["S"], validMFMA["B"], validMFMA["D"], validMFMA["X"], validMFMA["F8"], validWMMA]:
for MI in MFMA:
for bm in range(int(math.log(MI[3],2))+1):
for tt0 in range(1,validTT+1):
for tt1 in range(1,validTT+1):
for wave_m in range (3):
for wave_n in range(3):
validMFMA["_format9"].append([MI[0],MI[1],MI[2],MI[3],2**bm,tt0,tt1,2**wave_m, 2**wave_n])

validMatrixInstructions = [[], [-1]] + validMFMA["H"] + validMFMA["S"] + validMFMA["B"] + validMFMA["D"] + validMFMA["X"] + validMFMA["F8"]
validMatrixInstructions = validMatrixInstructions + validMFMA["_format9"]
validParameters["MatrixInstruction"] = validMatrixInstructions

# Minimum Required Version
if "MinimumRequiredVersion" in config:
if not versionIsCompatible(config["MinimumRequiredVersion"]):
Expand Down
41 changes: 27 additions & 14 deletions Tensile/SolutionLibrary.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,20 @@ def remapSolutionIndices(self, indexMap):
for row in self.rows:
row["library"].remapSolutionIndices(indexMap)

def __repr__(self) -> str:
return str(self.rows)


class MasterSolutionLibrary:
StateKeys = ["solutions", "library"]
ArchitectureSet = set()

def __init__(self, solutions, library, version=None):
self.lazyLibraries = {}
self.solutions = solutions
self.library = library
self.version = version

@classmethod
def ArchitectureIndexMap(cls, architectureName: str) -> int:
"""Maps hex characters from gfx name to an index.
Expand All @@ -275,12 +284,19 @@ def ArchitectureIndexMap(cls, architectureName: str) -> int:
if archString is not None:
archLiteral = archString.group(0)
archval = (int(archLiteral, 16) << 18)

# TODO(@bstefanuk) this section of code needs to be removed when dealing with
# parallel processing since each process may operate on multiple fallbacks that
# match a problem type.

# Check for duplicate architecture values
if archval >= 0 and not archval in cls.ArchitectureSet:
cls.ArchitectureSet.add(archval)
else:
tPrint(1, f"ERROR: Duplicate architecture value {archval} for {architectureName}, with arch set {cls.ArchitectureSet}")
raise RuntimeError("ERROR in architecture solution index mapping.")
# if archval >= 0 and not archval in cls.ArchitectureSet:
# cls.ArchitectureSet.add(archval)
# else:
# tPrint(1, f"ERROR: Duplicate architecture value {archval} for {architectureName}, with arch set {cls.ArchitectureSet}")
# raise RuntimeError("ERROR in architecture solution index mapping.")

cls.ArchitectureSet.add(archval)
return archval

@classmethod
Expand Down Expand Up @@ -455,10 +471,10 @@ def selection(d, problemType, solutions, library, placeholderName):
library = None
placeholderName = "TensileLibrary"
placeholderLibrary = None
for libName in reversed(libraryOrder):
library, placeholderName = libName(origData, problemType, allSolutions, library,
for updateNameFunc in reversed(libraryOrder):
library, placeholderName = updateNameFunc(origData, problemType, allSolutions, library,
placeholderName)
if libName == placeholder:
if updateNameFunc == placeholder:
placeholderLibrary = library

solutions = {s.index: s for s in allSolutions}
Expand Down Expand Up @@ -486,12 +502,6 @@ def BenchmarkingLibrary(cls, solutions):

return cls(solutionMap, library)

def __init__(self, solutions, library, version=None):
self.lazyLibraries = {}
self.solutions = solutions
self.library = library
self.version = version

def state(self):
rv = {
"solutions": state(iter(list(self.solutions.values()))),
Expand Down Expand Up @@ -599,6 +609,9 @@ def merge(self, other, startIndex=0):

return curIndex #Next unused index

def __repr__(self) -> str:
return str(self.library)

@property
def cpp_base_class(self):
return "SolutionLibrary<ContractionProblem, ContractionSolution>"
Expand Down
Loading