Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7506f87
Make TensileCreateLibrary a directory and add RCL specific ParseArgum…
davidd-amd Jan 6, 2025
a5d4757
Initialize missing variables
Jan 6, 2025
c056ae2
Merge remote-tracking branch 'origin/develop' into feature/tcl-arg-parse
davidd-amd Jan 11, 2025
2a48b5c
Add exported functions to module
davidd-amd Jan 11, 2025
0c05516
Add reasonable defaults and clean up
davidd-amd Jan 11, 2025
dfb6841
Can't completely remove generate sources and exit
davidd-amd Jan 11, 2025
209ef14
Update cmake support
davidd-amd Jan 11, 2025
bdaa170
Update docs string
davidd-amd Jan 14, 2025
11ec2de
Merge remote-tracking branch 'origin/develop' into new-build-algo
davidd-amd Jan 14, 2025
1480cb0
Refactor to simplify processing logic files
davidd-amd Jan 14, 2025
279a17e
memory consumption down to about 80GB for 64 procs
davidd-amd Jan 24, 2025
40e9cd2
validMFMA adds several GB to peak
davidd-amd Jan 24, 2025
a82ddbf
Added very basic loadd balancing which improves build times
davidd-amd Jan 28, 2025
18fad18
Add static requireParameters
davidd-amd Jan 28, 2025
4da5f39
Use new codeObjectFile entry in logic file
davidd-amd Feb 3, 2025
9cf1ced
Working master solution library
davidd-amd Feb 3, 2025
275df7e
Use msgpack not dat
davidd-amd Feb 3, 2025
cd021bc
Draft implementation of new build algo working end to end
davidd-amd Feb 7, 2025
79eaa39
Use the unique kernel count
davidd-amd Feb 8, 2025
a9a6d6f
TensileCreateLibrary clean up
davidd-amd Feb 9, 2025
488f85a
Use problem type info to compute co name
davidd-amd Mar 3, 2025
895c6a9
Improve kernel helper construction
davidd-amd Mar 3, 2025
ca141bd
Merge remote-tracking branch 'origin/develop' into new-build-algo
davidd-amd Mar 15, 2025
dd011ab
Corrections
davidd-amd Mar 15, 2025
d57a950
Need to have code object name in logic files
davidd-amd Mar 15, 2025
19a54f2
Working 942 build
davidd-amd Mar 19, 2025
daa7755
Merge remote-tracking branch 'origin/develop' into new-build-algo
davidd-amd Apr 3, 2025
c0508cf
Argument ordering
davidd-amd Apr 9, 2025
560552a
Merge remote-tracking branch 'origin/develop' into new-build-algo
davidd-amd Apr 9, 2025
862d8fd
Merge remote-tracking branch 'origin/develop' into new-build-algo
davidd-amd Apr 12, 2025
86cd832
Use file size to schedule logic file processing
davidd-amd Apr 13, 2025
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
6 changes: 4 additions & 2 deletions tensilelite/Tensile/BenchmarkProblems.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
from .Contractions import ProblemType as ContractionsProblemType
from .ClientWriter import runClient, writeClientConfig, writeClientConfigIni
from .KernelWriterAssembly import KernelWriterAssembly
from .TensileCreateLibrary import copyStaticFiles, writeSolutionsAndKernels
from .SolutionStructs import Solution, ProblemType, ProblemSizes
from Tensile.TensileCreateLibrary import copyStaticFiles
from Tensile.TensileCreateLibrary.Tuning import writeSolutionsAndKernels
from .CustomKernels import getCustomKernelConfig
from .Toolchain.Assembly import AssemblyToolchain
from .Toolchain.Source import SourceToolchain
Expand Down Expand Up @@ -229,7 +231,7 @@ def writeBenchmarkFiles(
kernels.append(kernel)
kernelNames.add(kName)

solutionHelperKernels = solution.getHelperKernelObjects()
solutionHelperKernels = solution.initHelperKernelObjects(list(isaInfoMap.keys()))
for ko in solutionHelperKernels:
kname = ko.getKernelName()
if kname not in kernelHelperNames:
Expand Down
73 changes: 73 additions & 0 deletions tensilelite/Tensile/CodeObjectName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@


from Tensile.Properties import Predicate
from Tensile.Contractions import ProblemType


def codeObjectFileBaseName(d: dict, useLazyLibraryLoading: bool=True):
"""Compute the code object library name from the solution metadata.

Args:
d: Solution metadata used to create the code object name.
lazyLibary: Use naming conventions necessary for lazy library loading.

Returns:
A string with the.
"""
placeholderName = "TensileLibrary"
problemType = ProblemType.FromOriginalState(d["ProblemType"])
if useLazyLibraryLoading:
placeholderName += '_' + str(problemType.aType) + str(problemType.bType)
placeholderName += '_' + str(problemType.cType) + str(problemType.computeInputType)
if problemType.activationType != 'none':
if str(problemType.activationType).upper() == 'ALL':
placeholderName += "_A"
elif str(problemType.activationType).upper() == 'HIPBLASLT_ALL':
placeholderName += "_HA"
else:
placeholderName += "_%s"%str(problemType.activationType).upper()
if problemType.swizzleTensorA:
placeholderName += '_STA'
if problemType.swizzleTensorB:
placeholderName += '_STB'
if problemType.useBias:
placeholderName += '_Bias'
if problemType.useE:
placeholderName += '_Grad' if problemType.useGradient else '_Aux'
if problemType.groupedGemm:
placeholderName += "_GG"
else:
placeholderName += "" if problemType.stridedBatched else "_GB" # legacy
if problemType.useScaleAB == "Scalar":
placeholderName += '_SAB'
elif problemType.useScaleAB == "Vector":
placeholderName += '_SABV'
if problemType.useScaleCD:
placeholderName += '_SCD'
if problemType.useScaleAlphaVec:
placeholderName += '_SAV'
if problemType.sparse:
placeholderName += '_SPB' if problemType.sparse == 2 else '_SPA'
if not problemType.f32XdlMathOp.isSingle() and problemType.computeInputType.isSingle():
placeholderName += '_M' + str(problemType.f32XdlMathOp)
if problemType.supportDeviceUserArguments:
placeholderName += '_UA'

placeholderName += problemType.placeholderStr(includeBatch=True, includeType=True)

if d.get("PerfMetric", "DeviceEfficiency") != "DeviceEfficiency":
predicate = Predicate(tag=d["PerfMetric"])
else:
predicate = Predicate(tag="TruePred")
if predicate.tag != "TruePred":
placeholderName += "_" + predicate.tag

operationID = problemType.operationIdentifier
placeholderName += "_" + operationID

devicePart = d["ArchitectureName"]
cuCount = d["CUCount"]
if cuCount: placeholderName += "_CU" + str(cuCount)
placeholderName += "_" + str(devicePart)

return placeholderName
41 changes: 23 additions & 18 deletions tensilelite/Tensile/Common/Parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import time

from joblib import Parallel, delayed
from typing import NamedTuple

from .Utilities import tqdm
from .Utilities import tqdm, printExit


def joblibParallelSupportsGenerator():
Expand Down Expand Up @@ -59,13 +60,11 @@ def CPUThreadCount(enable=True):
return min(cpu_count, cpuThreads)


def pcallWithGlobalParamsMultiArg(f, args, newGlobalParameters):
OverwriteGlobalParameters(newGlobalParameters)
def pcallWithGlobalParamsMultiArg(f, args):
return f(*args)


def pcallWithGlobalParamsSingleArg(f, arg, newGlobalParameters):
OverwriteGlobalParameters(newGlobalParameters)
def pcallWithGlobalParamsSingleArg(f, arg):
return f(arg)


Expand Down Expand Up @@ -195,8 +194,16 @@ def ParallelMapReturnAsGenerator(function, objects, message="", enable=True, mul
yield result.result()


class ParallelMapConfig(NamedTuple):
message: str = ""
enable: bool = True
multiArg: bool = False
return_as: str = "generator_unordered"
procs: int = None


def ParallelMap2(
function, objects, message="", enable=True, multiArg=True, return_as="list", procs=None
function, config: ParallelMapConfig, objects
):
"""
Generally equivalent to list(map(function, objects)), possibly executing in parallel.
Expand All @@ -206,18 +213,17 @@ def ParallelMap2(
multiArg: True if objects represent multiple arguments
(differentiates multi args vs single collection arg)
"""
if return_as in ("generator", "generator_unordered") and not joblibParallelSupportsGenerator():
return ParallelMapReturnAsGenerator(function, objects, message, enable, multiArg)
message = config.message
if config.return_as in ("generator", "generator_unordered") and not joblibParallelSupportsGenerator():
return ParallelMapReturnAsGenerator(function, objects, message, config.enable, config.multiArg)

from .GlobalParameters import globalParameters

threadCount = procs if procs else CPUThreadCount(enable)

threadCount = CPUThreadCount(enable)

threadCount = config.procs if config.procs else CPUThreadCount(config.enable)

if threadCount <= 1 and globalParameters["ShowProgressBar"]:
# Provide a progress bar for single-threaded operation.
return [function(*args) if multiArg else function(args) for args in tqdm(objects, message)]
return [function(*args) if config.multiArg else function(args) for args in tqdm(objects, message)]

countMessage = ""
try:
Expand All @@ -231,16 +237,15 @@ def ParallelMap2(
sys.stdout.flush()
currentTime = time.time()

pcall = pcallWithGlobalParamsMultiArg if multiArg else pcallWithGlobalParamsSingleArg
pargs = zip(objects, itertools.repeat(globalParameters))
pcall = pcallWithGlobalParamsMultiArg if config.multiArg else pcallWithGlobalParamsSingleArg

if joblibParallelSupportsGenerator():
rv = Parallel(n_jobs=threadCount, timeout=99999, return_as=return_as)(
delayed(pcall)(function, a, params) for a, params in pargs
rv = Parallel(n_jobs=threadCount, timeout=99999, return_as=config.return_as)(
delayed(pcall)(function, a) for a in objects
)
else:
rv = Parallel(n_jobs=threadCount, timeout=99999)(
delayed(pcall)(function, a, params) for a, params in pargs
delayed(pcall)(function, a) for a in objects
)

totalTime = time.time() - currentTime
Expand Down
2 changes: 1 addition & 1 deletion tensilelite/Tensile/CustomYamlLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def load_yaml_dict_item(yaml_path: Path, loader_type: yaml.Loader, key: str):

def load_logic_gfx_arch(yaml_path: Path, loader_type: yaml.Loader = DEFAULT_YAML_LOADER):
try:
GFX_ARCH_IDX = 2
GFX_ARCH_IDX = 2 # DataIndex.DEVICE_PROPERTIES
arch = load_yaml_sequence_item(yaml_path, loader_type, GFX_ARCH_IDX)

if isinstance(arch, dict):
Expand Down
10 changes: 8 additions & 2 deletions tensilelite/Tensile/KernelWriterActivationEnumHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ def __init__(self, state):

# derive parameter
self.language = "HIP"
self.kernelName = self.getKernelName()
self.kernelName = KernelWriterActivationEnumHeader.getKernelName(self)

def keys(self):
return self.getKernelName()

@staticmethod
def _getKernelName(solution):
s = "Gradient" if solution._state["ProblemType"]["Gradient"] else ""
return "Tensile%sActivationEnum_%s"%(s,
solution._state["ProblemType"]["ActivationComputeDataType"].toChar())

def getKernelName(self):
return "Tensile%sActivationEnum_%s"%(self.actGradientPrefix, \
return "Tensile%sActivationEnum_%s"%(self.actGradientPrefix,
self.state["ProblemType"]["ActivationComputeDataType"].toChar())

def getSourceFileString(self):
Expand Down
11 changes: 11 additions & 0 deletions tensilelite/Tensile/KernelWriterActivationFunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def __init__(self, state, cxxCompiler: str, supportedISA: List[IsaVersion]):
def keys(self):
return self.getKernelName()


@staticmethod
def _getKernelName(solution):
actGradientPrefix = "Gradient" if solution._state["ProblemType"]["Gradient"] else ""
gaurdStr = "NG" if solution._state["ProblemType"]["ActivationNoGuard"] else ""
return "Tensile%sActivation%s_%s_%s"%(actGradientPrefix, \
gaurdStr, \
solution._state["ProblemType"]["ActivationComputeDataType"].toChar(), \
solution._state["ProblemType"]["ActivationType"])


def getKernelName(self):
return "Tensile%sActivation%s_%s_%s"%(self.actGradientPrefix, \
self.gaurdStr, \
Expand Down
19 changes: 19 additions & 0 deletions tensilelite/Tensile/KernelWriterActivationOnly.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,25 @@ def kernelBody(self):

return kStr

@classmethod
def _getKernelName(cls, solution):
indexChars = INDEX_CHARS
# C dimensions
name = "D"
for i in range(0, solution.state["ProblemType"]["NumIndicesC"]):
name += indexChars[i].lower()
name += "_"
name += solution.state["ProblemType"]["DestDataType"].toChar()
if solution.state["ProblemType"]["ActivationType"] != 'none':
if solution.state["ProblemType"]["ActivationType"] in ['all', 'hipblaslt_all']:
name += "_%s"%"A"
else:
name += "_%s"%str(solution.state["ProblemType"]["ActivationType"]).upper()
name += solution.state["ProblemType"]["ActivationComputeDataType"].toChar()
name += ("ng" if solution.state["ProblemType"]["ActivationNoGuard"] else "")

return name


def getKernelName(self):
indexChars = INDEX_CHARS
Expand Down
4 changes: 0 additions & 4 deletions tensilelite/Tensile/KernelWriterAssembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,6 @@ def getSourceFileString(self,
kernel,
useShortNames: bool=False) -> Tuple[int, str]:
assert kernel["KernelLanguage"] == "Assembly"
# Skip if .o files will have already been built for this file
if kernel.duplicate:
self.language = "ASM"
return (0, "") # should this be an non zero number

try:
code = self._getCustomKernelSource(useShortNames, kernel, CUSTOM_KERNEL_PATH) if isCustomKernelConfig(kernel) else self._getKernelSource(kernel)
Expand Down
20 changes: 20 additions & 0 deletions tensilelite/Tensile/KernelWriterBetaOnly.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,26 @@ def kernelBodyBetaOnly(self):
return kStr


@staticmethod
def _getKernelName(solution, btype=None):
indexChars = INDEX_CHARS
# C dimensions
name = "C"
for i in range(0, solution._state["ProblemType"]["NumIndicesC"]):
name += indexChars[i].lower()
name += "_"
name += solution._state["ProblemType"]["DestDataType"].toChar()
if solution._state["ProblemType"]["GroupedGemm"]:
name += "_GG"
else:
name += "" if solution._state["ProblemType"]["StridedBatched"] else "_GB"
if solution._state["ProblemType"]["BetaOnlyUseBias"]:
name += "_Bias%s"%btype.toChar()
name += "_GA" if solution._state["_GlobalAccumulation"] else ""

return name


def getKernelName(self):
indexChars = INDEX_CHARS
# C dimensions
Expand Down
58 changes: 58 additions & 0 deletions tensilelite/Tensile/KernelWriterConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,64 @@ def kernelBody(self):
return kStr


@staticmethod
def _getKernelName(solution, num_elements_load, btype=None):
indexChars = INDEX_CHARS
# C dimensions
name = "C"
for i in range(0, solution._state["ProblemType"]["NumIndicesC"]):
name += indexChars[i].lower()
name += "_"

# add input datatype into kernel name (the datatype of workspace)
inputTypeStr = DataType("I").toChar() if solution._state["ProblemType"]["DataType"].isInt8() or solution._state["ProblemType"]["DataType"].isInt32() else \
(DataType("D").toChar() if solution._state["ProblemType"]["DataType"].isDouble() else DataType("S").toChar())

name += (inputTypeStr + solution._state["ProblemType"]["DestDataType"].toChar())

if solution._state["ProblemType"]["GroupedGemm"]:
name += "_GG"
else:
name += "" if solution._state["ProblemType"]["StridedBatched"] else "_GB"
if btype:
if solution._state["ProblemType"]["Gradient"]:
name += "_DBias%s"%(btype.toChar())
name += "_BiasSrc%s"%(solution._state["ProblemType"]["BiasSrc"])
else:
name += "_Bias%s"%btype.toChar()

factorDim = 0 if solution._state["ProblemType"]["Gradient"] else solution._state["ProblemType"]["UseBias"]
factorDim = max(factorDim, solution._state["ProblemType"]["UseScaleAlphaVec"])
if factorDim > 1:
name += "_FD%s"%("N" if factorDim == 2 else "MN")

if solution._state["ProblemType"]["UseE"]:
if solution._state["ProblemType"]["Gradient"]:
name += "_Grad%s"%solution._state["ProblemType"]["DataTypeE"].toChar()
else:
name += "_Aux%s"%solution._state["ProblemType"]["DataTypeE"].toChar()

if ((solution._state["ProblemType"]["ActivationType"] != 'none') and solution._state["ActivationFused"]):
if solution._state["ProblemType"]["ActivationType"] == 'all':
name += "_A"
elif solution._state["ProblemType"]["ActivationType"] == 'hipblaslt_all':
name += "_HA"
else:
name += "_%s"%str(solution._state["ProblemType"]["ActivationType"]).upper()
name += solution._state["ProblemType"]["ActivationComputeDataType"].toChar()
name += ("ng" if solution._state["ProblemType"]["ActivationNoGuard"] else "")
if solution._state["ProblemType"]["UseScaleAB"] == "Scalar":
name += "_ScaleAB"
elif solution._state["ProblemType"]["UseScaleAB"] == "Vector":
name += "_ScaleABVec"
name += "_ScaleCD" if solution._state["ProblemType"]["UseScaleCD"] else ""
name += "_ScaleAlphaVec" if solution._state["ProblemType"]["UseScaleAlphaVec"] else ""
name += "_PostGSU" + str(solution._state["GlobalSplitU"])
if num_elements_load != None:
name += "_VW" + str(num_elements_load)
return name


def getKernelName(self):
indexChars = INDEX_CHARS
# C dimensions
Expand Down
15 changes: 15 additions & 0 deletions tensilelite/Tensile/KernelWriterReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ def kernelBody(self):
return kStr


@staticmethod
def _getKernelName(solution, btype):
# C dimensions
indexChars = INDEX_CHARS
indicesStr = ""
for i in range(0, solution._state["ProblemType"]["NumIndicesC"]):
c = indexChars[i].lower()
indicesStr += indexChars[i].lower()
name = "D"
name += indicesStr
name += "_%s%s"%(btype.toChar(), solution._state["ProblemType"]["ComputeDataType"].toChar())
name += "_Reduction"
return name


def getKernelName(self):
name = "D"
name += self.indicesStr
Expand Down
Loading