Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d7f3133
feat: no global working path with asserts
bstefanuk Jan 14, 2025
a1375c7
fix: bad import statement
bstefanuk Jan 15, 2025
07cd30c
fix: different build_tmp dir in cmake than tensile
bstefanuk Jan 15, 2025
b5b0f49
fix: incorrect pathing in Tensile benchmarking
bstefanuk Jan 17, 2025
17aa51a
fix: string wrap paths for assert checks
bstefanuk Jan 17, 2025
33aea17
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 18, 2025
66c157d
fix: ensure all paths are built
bstefanuk Jan 18, 2025
c2e09c6
fix: missing global parameter warning
bstefanuk Jan 20, 2025
5faedfc
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 23, 2025
d3a11bc
fix: ensure library logic path is built
bstefanuk Jan 23, 2025
9517470
fix: client writer paths
bstefanuk Jan 23, 2025
4f73598
fix: use child path for client libraries
bstefanuk Jan 23, 2025
df28683
remove PrintTiming from global params
bstefanuk Jan 23, 2025
ea37c06
remove another assert
bstefanuk Jan 23, 2025
8d72b2b
restore PrintTiming
bstefanuk Jan 24, 2025
af18c2e
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 24, 2025
eab5145
fix: reviewer comments
bstefanuk Jan 28, 2025
5599a46
refactor: use env var for @timing decorator
bstefanuk Jan 24, 2025
54072cc
refactor: remove library print debug
bstefanuk Jan 24, 2025
4265e9c
refactor: remove exit after kernel gen option
bstefanuk Jan 24, 2025
08348e1
style: remove commented code
bstefanuk Jan 24, 2025
8c7b0a3
refactor: move common to a module
bstefanuk Jan 24, 2025
e745693
feat: remove 'CustomKernelDirectory' global param
bstefanuk Jan 28, 2025
a6080cf
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 29, 2025
20b514b
fix: amd clang version global param
bstefanuk Jan 29, 2025
6ef1f5c
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 30, 2025
1da3cbf
Merge branch 'develop' into remove-global-working-path
bstefanuk Jan 30, 2025
8390470
Merge branch 'remove-global-working-path' into move-common-to-module
bstefanuk Jan 31, 2025
884777b
fix: second pass on amd clang version
bstefanuk Jan 31, 2025
56ea8f7
Merge branch 'develop' into move-common-to-module
bstefanuk Feb 3, 2025
044fdf6
fix: imports for bolted on ops scripts
bstefanuk Feb 3, 2025
5ffa0a4
chore: remove safety asserts
bstefanuk Feb 4, 2025
94e4973
chore: create more separation in Common
bstefanuk Feb 5, 2025
8dc646a
fix: missing line at eof
bstefanuk Feb 5, 2025
364e4e5
fix: basic reviewer comments
bstefanuk Feb 7, 2025
92c13f3
chore: move global dependenct funcs to GlobalParameters.py
bstefanuk Feb 7, 2025
76d2579
fix: pass global params to splitArchs
bstefanuk Feb 7, 2025
57cb9af
style: don't format caps funcs
bstefanuk Feb 7, 2025
3d4ea71
fix: bad import
bstefanuk Feb 7, 2025
b5f8a63
Merge branch 'develop' into move-common-to-module
bstefanuk Feb 10, 2025
afec069
Add TensileLogic program to verify matrix instructions (#3)
bstefanuk Feb 10, 2025
2b4402e
Remove unused and static global parameters (#5)
bstefanuk Feb 11, 2025
dc7cf35
Update preferred search paths (#4)
bstefanuk Feb 11, 2025
cf7b74e
fix: remove files updated by precommit in merge
bstefanuk Feb 11, 2025
9de3e29
fix: remove log file
bstefanuk Feb 11, 2025
fc53bb1
Merge remote-tracking branch 'origin/develop' into move-common-to-module
davidd-amd Feb 11, 2025
8f48343
Copyright update
davidd-amd Feb 11, 2025
e4939f7
Merge branch 'develop' into move-common-to-module
bstefanuk Feb 12, 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
2 changes: 1 addition & 1 deletion tensilelite/Tensile/Activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
TensileInstructions
from .TensileInstructions.Enums import *
from .TensileInstructions.Instructions import *
from .Common import printExit, printWarning, globalParameters
from .Common import printExit, printWarning

from dataclasses import dataclass, field

Expand Down
5 changes: 2 additions & 3 deletions tensilelite/Tensile/AsmAddressCalculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

from .TensileInstructions import Module, EXEC, vgpr, sgpr, log2, Label
from .TensileInstructions.Instructions import *
from .Common import globalParameters
from .Utils import DataDirection
from .Common import INDEX_CHARS, DataDirection

##############################################################################
# Fields associated with computing address
Expand Down Expand Up @@ -192,7 +191,7 @@ def emitExtractAndScalePackedDims(self, kernel, ss, tmpVgpr, storeChar):
# - tmp+0 may be the incoming packed coordinate 0, used on replay too
# - tmp+1 is DIV output
# - tmp+2 is scratch
idxChar= globalParameters["IndexChars"][idx]
idxChar= INDEX_CHARS[idx]
module.addComment0("extract %s"%kw.sizeRef(idx))
assert(tmpVgpr+1 != packedBits) # bad since we still need packedBits below for remainder (can't overwrite here)
module.add(MacroInstruction("V_MAGIC_DIV", \
Expand Down
2 changes: 1 addition & 1 deletion tensilelite/Tensile/AsmMemoryInstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
#
################################################################################

from .Common import printExit
from .TensileInstructions import DSStoreB8, DSStoreB8HID16, ReadWriteInstruction, \
DSLoadD16HIU16, DSLoadD16HIU8, \
DSLoadU8, DSLoadU16, DSStoreD16HIB16, \
DSStoreB16
from .Common import printExit

from dataclasses import dataclass, field
from typing import Type
Expand Down
2 changes: 1 addition & 1 deletion tensilelite/Tensile/AsmStoreState.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from .TensileInstructions import DataType
from .AsmAddressCalculation import AddrCalculation
from .Utils import DataDirection
from .Common import DataDirection

from math import ceil, trunc, modf
from dataclasses import dataclass, field
Expand Down
23 changes: 10 additions & 13 deletions tensilelite/Tensile/BenchmarkProblems.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@
from copy import deepcopy
from pathlib import Path

from . import ClientExecutable
from . import SolutionLibrary
from . import LibraryIO
from . import Utils
from . import CUSTOM_KERNEL_PATH, ClientExecutable, SolutionLibrary, LibraryIO
from .BenchmarkStructs import BenchmarkProcess, constructForkPermutations
from .Contractions import ProblemType as ContractionsProblemType
from .ClientWriter import runClient, writeClientConfig, writeClientConfigIni
from .Common import globalParameters, HR, print1, print2, \
printExit, printWarning, ensurePath, startTime, validParameters
from .KernelWriterAssembly import KernelWriterAssembly
from .SolutionStructs import Solution, ProblemType, ProblemSizes
from .TensileCreateLibrary import copyStaticFiles, writeSolutionsAndKernels
from .CustomKernels import getCustomKernelConfig
from .Toolchain.Assembly import AssemblyToolchain
from .Toolchain.Source import SourceToolchain
from .Common import globalParameters, HR, print1, print2, \
printExit, printWarning, ensurePath, startTime, tqdm, state


def generateForkedSolutions(problemType, constantParams, forkPermutations, cxxCompiler):
Expand All @@ -71,7 +68,7 @@ def generateForkedSolutions(problemType, constantParams, forkPermutations, cxxCo
return solutions


def getCustomKernelSolutionObj(kernelName, internalSupportParams, cxxCompiler: str, directory=globalParameters["CustomKernelDirectory"]):
def getCustomKernelSolutionObj(kernelName, internalSupportParams, cxxCompiler: str, directory=CUSTOM_KERNEL_PATH):
"""Creates the Solution object for a custom kernel"""
config = getCustomKernelConfig(kernelName, internalSupportParams, directory)
return Solution(config, cxxCompiler)
Expand Down Expand Up @@ -115,7 +112,7 @@ def generateCustomKernelSolutions(problemType, customKernels, internalSupportPar

def writeBenchmarkFiles(stepBaseDir, solutions, problemSizes, \
biasTypeArgs, factorDimArgs, activationArgs, icacheFlushArgs, stepName, solutionSummationSizes, \
asmToolchain: AssemblyToolchain, srcToolchain: SourceToolchain, sourcePath: Path, buildTmpPath: Path):
asmToolchain: AssemblyToolchain, srcToolchain: SourceToolchain, sourcePath: Path):
"""Write all the files needed for a given benchmarking step"""

ensurePath(sourcePath)
Expand All @@ -127,7 +124,7 @@ def writeBenchmarkFiles(stepBaseDir, solutions, problemSizes, \
kernelHelperNames = set()

# get unique kernels and kernel helpers
for solution in Utils.tqdm(solutions, "Finding unique solutions"):
for solution in tqdm(solutions, "Finding unique solutions"):
solutionKernels = solution.getKernels()
for kernel in solutionKernels:
kName = Solution.getKeyNoInternalArgs(kernel)
Expand All @@ -144,7 +141,7 @@ def writeBenchmarkFiles(stepBaseDir, solutions, problemSizes, \

kernelSerialNaming = Solution.getSerialNaming(kernels)
kernelMinNaming = Solution.getMinNaming(kernels)
kernelWriterAssembly = KernelWriterAssembly(kernelMinNaming, kernelSerialNaming, srcToolchain.compiler)
kernelWriterAssembly = KernelWriterAssembly(kernelMinNaming, kernelSerialNaming, asmToolchain.assembler, asmToolchain.assemblerVersion)

# write solution, kernels and CMake
problemType = solutions[0]["ProblemType"]
Expand All @@ -157,9 +154,9 @@ def writeBenchmarkFiles(stepBaseDir, solutions, problemSizes, \

newLibraryDir = ensurePath(sourcePath / 'library')
newLibraryFile = os.path.join(newLibraryDir, "TensileLibrary")
newLibrary = SolutionLibrary.MasterSolutionLibrary.BenchmarkingLibrary(solutions, srcToolchain.compiler)
newLibrary = SolutionLibrary.MasterSolutionLibrary.BenchmarkingLibrary(solutions, asmToolchain.assembler)
newLibrary.applyNaming(kernelMinNaming)
LibraryIO.write(newLibraryFile, Utils.state(newLibrary), globalParameters["LibraryFormat"])
LibraryIO.write(newLibraryFile, state(newLibrary), globalParameters["LibraryFormat"])

codeObjectFiles = [os.path.relpath(f, sourcePath) \
for f in codeObjectFiles]
Expand Down Expand Up @@ -316,7 +313,7 @@ def benchmarkProblemType(problemTypeConfig, problemSizeGroupConfig, problemSizeG
benchmarkStep.problemSizes, benchmarkStep.biasTypeArgs, \
benchmarkStep.factorDimArgs, benchmarkStep.activationArgs, \
benchmarkStep.icacheFlushArgs, shortName, [], asmToolchain, srcToolchain, \
sourcePath, buildTmpPath)
sourcePath)
# ^ this mutates solutions

# write cache data
Expand Down
22 changes: 11 additions & 11 deletions tensilelite/Tensile/ClientExecutable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
#
# Copyright (C) 2022-2024 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -28,8 +28,8 @@
from typing import Optional
from pathlib import Path

from . import Common
from .Common import globalParameters
from . import SOURCE_PATH
from .Common import globalParameters, print2, ClientExecutionLock, ensurePath

class CMakeEnvironment:
def __init__(self, sourceDir, buildDir, **options):
Expand All @@ -43,23 +43,23 @@ def generate(self):
args += itertools.chain.from_iterable([ ['-D', '{}={}'.format(key, value)] for key,value in self.options.items()])
args += [self.sourceDir]

Common.print2(' '.join(args))
with Common.ClientExecutionLock():
subprocess.check_call(args, cwd=Common.ensurePath(self.buildDir))
print2(' '.join(args))
with ClientExecutionLock(globalParameters["ClientExecutionLockPath"]):
subprocess.check_call(args, cwd=ensurePath(self.buildDir))

def build(self):
args = ['make', '-j']
Common.print2(' '.join(args))
with Common.ClientExecutionLock():
print2(' '.join(args))
with ClientExecutionLock(globalParameters["ClientExecutionLockPath"]):
subprocess.check_call(args, cwd=self.buildDir)

def builtPath(self, path, *paths):
return os.path.join(self.buildDir, path, *paths)

def clientExecutableEnvironment(builddir: Optional[str], cxxCompiler: str, cCompiler: str):
sourcedir = globalParameters["SourcePath"]
builddir = Common.ensurePath(builddir)
sourcedir = SOURCE_PATH

builddir = ensurePath(builddir)

options = {'CMAKE_BUILD_TYPE': globalParameters["CMakeBuildType"],
'TENSILE_USE_MSGPACK': 'ON',
Expand Down
22 changes: 11 additions & 11 deletions tensilelite/Tensile/ClientWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@
#
################################################################################

from pathlib import Path
from . import ClientExecutable
from . import LibraryIO
from .TensileInstructions import getGfxName, DataType
from .Common import globalParameters, ensurePath, print1, printExit, CHeader, printWarning, listToInitializer, ClientExecutionLock
from .SolutionStructs import Problem, ProblemType, ProblemSizesMock, ProblemSizesMockDummy, ActivationArgs, BiasTypeArgs, FactorDimArgs
from .TensileCreateLibrary import copyStaticFiles

import os
import subprocess
import shlex
import shutil

from pathlib import Path
from enum import Enum
from glob import glob

from . import ROOT_PATH
from . import ClientExecutable
from . import LibraryIO
from .Common import globalParameters, ensurePath, print1, printExit, printWarning, ClientExecutionLock, isaToGfx
from .SolutionStructs import ProblemType, ProblemSizesMock, ProblemSizesMockDummy, ActivationArgs, BiasTypeArgs, FactorDimArgs
from .TensileCreateLibrary import copyStaticFiles
from .Contractions import FreeIndex, BatchIndex
from .Contractions import ProblemType as ContractionsProblemType

Expand Down Expand Up @@ -194,7 +194,7 @@ def runClient(libraryLogicPath, forBenchmark, enableTileSelection, cxxCompiler:
buildPath = ensurePath(outputPath / "build")

runScriptName = writeRunScript(buildPath, forBenchmark, enableTileSelection, cxxCompiler, cCompiler, buildPath, configPaths)
with ClientExecutionLock():
with ClientExecutionLock(globalParameters["ClientExecutionLockPath"]):
process = subprocess.Popen(runScriptName, cwd=buildPath)
process.communicate()

Expand All @@ -207,7 +207,7 @@ def getBuildClientLibraryScript(buildPath, libraryLogicPath, cxxCompiler):
import io
runScriptFile = io.StringIO()

callCreateLibraryCmd = globalParameters["ScriptPath"] + "/bin/TensileCreateLibrary"
callCreateLibraryCmd = ROOT_PATH + "/bin/TensileCreateLibrary"

if not globalParameters["LazyLibraryLoading"]:
callCreateLibraryCmd += " --no-lazy-library-loading"
Expand Down Expand Up @@ -516,7 +516,7 @@ def param(key, value):
libraryFile = os.path.join(sourceDir, "library", libraryFilename)
param("library-file", libraryFile)

currentGFXName = getGfxName(globalParameters["CurrentISA"])
currentGFXName = isaToGfx(globalParameters["CurrentISA"])
for coFile in codeObjectFiles:
if 'gfx' not in coFile or currentGFXName in coFile:
param("code-object", os.path.join(sourceDir,coFile))
Expand Down
Loading