CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
238 lines
7.9 KiB
Python
238 lines
7.9 KiB
Python
################################################################################
|
|
#
|
|
# Copyright (C) 2016-2022 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
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
#
|
|
# The above copyright notice and this permission notice shall be included in
|
|
# all copies or substantial portions of the Software.
|
|
#
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
#
|
|
################################################################################
|
|
|
|
import os
|
|
import sys
|
|
import argparse
|
|
import re
|
|
from distutils.util import strtobool
|
|
|
|
import pandas as pd
|
|
from ExtractSizes import *
|
|
from TuningConfiguration import *
|
|
|
|
headers = ""
|
|
|
|
def MatchLine(headerPattern, linePattern, line):
|
|
|
|
global headers
|
|
|
|
if not headers:
|
|
matched = headerPattern.match(line)
|
|
|
|
if matched:
|
|
headers = line
|
|
|
|
return matched
|
|
else:
|
|
matched = linePattern.match(line)
|
|
|
|
return matched
|
|
|
|
def ResultsFilesList(inputPath, resultsName):
|
|
|
|
resultsFilePattern = re.compile(resultsName + "\.[0-9]*")
|
|
resultsFiles = [f for f in os.listdir(inputPath)]
|
|
|
|
filteredFiles = [f for f in resultsFiles if resultsFilePattern.match(f)]
|
|
|
|
return filteredFiles
|
|
|
|
def ParseResults(inputPath, outputPath, resultsName):
|
|
|
|
global headers
|
|
|
|
headers = ""
|
|
|
|
filteredFiles = ResultsFilesList(inputPath, resultsName)
|
|
|
|
headerPattern = re.compile("transA,transB")
|
|
linePattern = re.compile(r"(N|T),(N|T).*")
|
|
|
|
outfilename = resultsName + ".csv"
|
|
|
|
outputFilePath = os.path.join(outputPath, outfilename)
|
|
outfile = open(outputFilePath,'w')
|
|
|
|
for fl in filteredFiles:
|
|
flPath = os.path.join(inputPath,fl)
|
|
filteredLines = [ line for line in open(flPath) if MatchLine(headerPattern, linePattern, line)]
|
|
outfile.writelines(filteredLines)
|
|
outfile.flush()
|
|
outfile.close()
|
|
|
|
def getMultiplier(xdl):
|
|
|
|
if xdl:
|
|
return 2
|
|
|
|
return 1
|
|
|
|
def getCuCount(gpu):
|
|
|
|
gpuMap = {'vega10':64, 'mi25':64, 'vega20':64, 'v340l':56,'mi50':60,'arcturus':120,'mi60':64}
|
|
for key in gpuMap.keys():
|
|
if gpu == key:
|
|
return gpuMap[key]
|
|
|
|
return 64
|
|
|
|
def fillCallCounts(problemMapper, callCounts, callCount, callCountStrided, isOne):
|
|
|
|
for i in problemMapper:
|
|
for klist in i:
|
|
midList = list()
|
|
for key in klist:
|
|
if key == "transposeA" or key == "transposeB" or key == "f" or key == "i":
|
|
if klist[key] == 10 and isOne:
|
|
klist[key] = 1
|
|
midList.append(klist[key])
|
|
if len(midList) == 4:
|
|
callCounts.append(midList)
|
|
|
|
for line in callCounts:
|
|
if line[0] == "gemm" or line[0] == "gemm_ex":
|
|
callCount.append(line[3])
|
|
elif "gemm_strided_batched" in line[0]:
|
|
callCountStrided.append(line[3])
|
|
|
|
def chooseCallCount(resultsName, callCount, callCountStrided):
|
|
if "strided" in resultsName:
|
|
return callCountStrided
|
|
return callCount
|
|
|
|
def ProcessResults(outputPath, resultsName, freqM, sz, call_count, gpu = 'vega20', xdl = False):
|
|
|
|
global headers
|
|
resultsFilename = resultsName + ".csv"
|
|
|
|
resultsFilePath = os.path.join(outputPath, resultsFilename)
|
|
|
|
data = None
|
|
data = pd.read_csv(resultsFilePath)
|
|
multiplier = getMultiplier(xdl)
|
|
cus = getCuCount(gpu)
|
|
|
|
headerValues = headers.strip().split(",")
|
|
headerLength = len(headerValues)
|
|
key = headerValues[0:headerLength-2]
|
|
key.append('us')
|
|
|
|
performanceField = "rocblas-Gflops"
|
|
timingField = "us"
|
|
|
|
df = data.groupby(key,sort=False)
|
|
|
|
results = df[performanceField].mean().to_frame()
|
|
timingResults = df[timingField].mean().to_frame()
|
|
|
|
freq=freqM
|
|
factor=sz * 64 * multiplier * cus
|
|
results['eff'] = 100*1e3*results['rocblas-Gflops'] / (factor * freq)
|
|
results['us_w'] = timingResults['us']*call_count
|
|
|
|
aggregateFileName = resultsName + "-aggregated.csv"
|
|
aggregateFilePath = os.path.join(outputPath, aggregateFileName)
|
|
|
|
results.to_csv(aggregateFilePath, header=True)
|
|
|
|
resultsBad = results[results['eff'] < 70]
|
|
badResultsFileName = resultsName + "-bad.csv"
|
|
badResultsFilePath = os.path.join(outputPath, badResultsFileName)
|
|
resultsBad.sort_values(by='us_w',ascending=False).to_csv(badResultsFilePath, header=True)
|
|
|
|
large1 = data
|
|
large1['N'] = pd.to_numeric(large1['N'])
|
|
large1['M'] = pd.to_numeric(large1['M'])
|
|
large2 = large1[large1['N']>1000]
|
|
large = large2[large2['M']>1000]
|
|
|
|
largeAgg = large.groupby(key)
|
|
largeResults = largeAgg[performanceField].mean().to_frame()
|
|
largeResultsTime = largeAgg[timingField].mean().to_frame()
|
|
largeResults['eff'] = 100*1e3*largeResults['rocblas-Gflops'] / (factor * freq)
|
|
largeResults['us_w'] = largeResultsTime['us']
|
|
|
|
resultsFileName = resultsName + "-large.csv"
|
|
resultsFilePath = os.path.join(outputPath, resultsFileName)
|
|
largeResults.sort_values(by='us_w',ascending=False).to_csv(resultsFilePath, header=True)
|
|
|
|
resultsBad = largeResults[largeResults['eff'] < 70]
|
|
badResultsFileName = resultsName + "-bad-large.csv"
|
|
badResultsFilePath = os.path.join(outputPath, badResultsFileName)
|
|
resultsBad.sort_values(by='eff',ascending=True).to_csv(badResultsFilePath, header=True)
|
|
|
|
def RunMain():
|
|
|
|
userArgs = sys.argv[1:]
|
|
|
|
def strbool(arg):
|
|
return bool(strtobool(arg))
|
|
|
|
argParser = argparse.ArgumentParser()
|
|
argParser.add_argument("input_path", help="path where the results are located")
|
|
argParser.add_argument("output_path", help="path where the processed files are to go")
|
|
argParser.add_argument("frequency", help="frequecy in megahertz used in testing", type=int,default=1301)
|
|
argParser.add_argument("data_size", help="data size",type=int,default=2)
|
|
argParser.add_argument("input_file_name", help="configuration file path")
|
|
argParser.add_argument("gpu", help="which gpu was used", type=str,default="vega20")
|
|
argParser.add_argument("mfma", help="were mfma instructions enabled", type=strbool,default=False)
|
|
argParser.add_argument("is_count_1", help="were mfma instructions enabled", type=strbool,default=False) # duplicated parameter?
|
|
|
|
args = argParser.parse_args(userArgs)
|
|
|
|
inputPath = args.input_path
|
|
outputPath = args.output_path
|
|
freqM = args.frequency
|
|
sz = args.data_size
|
|
inputFileName = args.input_file_name
|
|
cu = args.gpu
|
|
xdl = args.mfma
|
|
isOne = args.is_count_1
|
|
|
|
problemMapper = list(ProcessFile(inputFileName).values())
|
|
callCounts = list(list())
|
|
callCount = list()
|
|
callCountStrided = list()
|
|
|
|
fillCallCounts(problemMapper, callCounts, callCount, callCountStrided, isOne)
|
|
|
|
resultsFiles = [f for f in os.listdir(inputPath) if (os.path.isfile(os.path.join(inputPath, f)))]
|
|
resultsNameSet = set()
|
|
|
|
for resultsFile in resultsFiles:
|
|
resultsName, _ = os.path.splitext(resultsFile)
|
|
resultsNameSet.add(resultsName)
|
|
|
|
resultsNames = list(resultsNameSet)
|
|
|
|
for resultsName in resultsNames:
|
|
ParseResults(inputPath, outputPath, resultsName)
|
|
callCountChoice = chooseCallCount(resultsName, callCount, callCountStrided)
|
|
ProcessResults(outputPath, resultsName, freqM, sz, callCountChoice, cu, xdl)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
RunMain()
|