Debian Codegraph @

tensilelite/Tensile/BenchmarkProblems.py

raw symbols SCIP
1 ################################################################################
2 #
3 # Copyright (C) 2022-2025 Advanced Micro Devices, Inc. All rights reserved.
4 #
5 # Permission is hereby granted, free of charge, to any person obtaining a copy
6 # of this software and associated documentation files (the "Software"), to deal
7 # in the Software without restriction, including without limitation the rights
8 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 # copies of the Software, and to permit persons to whom the Software is
10 # furnished to do so, subject to the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included in
13 # all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 # SOFTWARE.
22 #
23 ################################################################################
24
25 import os
26 import shutil
27 import sys
28 import time
29
30 from copy import deepcopy
31 from pathlib import Path
32 from typing import Dict
33
34 from Tensile import CUSTOM_KERNEL_PATH, SolutionLibrary, LibraryIO
35 from Tensile.KernelWriter import DebugConfig
36 from Tensile.KernelHelperNaming import KernelHelperEnum, initHelperKernelObjects
37 from Tensile.Toolchain.Component import Assembler
38 from Tensile.SolutionStructs.Problem import ProblemType, ProblemSizes
39 from Tensile.SolutionStructs.Solution import Solution
40 from Tensile.SolutionStructs.Validators.MatrixInstruction import matrixInstructionToMIParameters, \
41 validateMIParameters
42 from Tensile.SolutionStructs.Naming import getKeyNoInternalArgs, getSolutionNameMin, getKernelNameMin
43
44 from .BenchmarkStructs import BenchmarkProcess, constructForkPermutations
45 from .Contractions import ProblemType as ContractionsProblemType
46 from .ClientWriter import runClient, writeClientConfig, writeClientConfigIni, getClientExecutablePath
47 from .KernelWriterAssembly import KernelWriterAssembly
48 from .TensileCreateLibrary import copyStaticFiles, writeSolutionsAndKernels
49 from .CustomKernels import getCustomKernelConfig
50 from .Toolchain.Assembly import AssemblyToolchain
51 from .Toolchain.Source import SourceToolchain
52 from Tensile.Common import HR, print1, print2, IsaInfo, IsaVersion, \
53 printExit, printWarning, ensurePath, tqdm, state, \
54 BENCHMARK_PROBLEMS_DIR, BENCHMARK_DATA_DIR
55 from Tensile.Common.Architectures import isaToGfx, gfxToVariants
56 from Tensile.Common.GlobalParameters import globalParameters, startTime
57
58
59 def _generateForkedSolutions(problemType, constantParams, forkPermutations, assembler: Assembler, \
60 debugConfig: DebugConfig, isaInfoMap: Dict[IsaVersion, IsaInfo]):
61 """Creates a list with a Solution object for each parameter combination in forkPermutations"""
62 print1("# Enumerating Solutions")
63
64 solutions = []
65 solutionSet = set()
66 for perm in forkPermutations:
67 # Expect only a single ISA in the map for the Tensile context
68 # because the GPU has to be physically present for benchmarking
69
70 solution = {
71 "ProblemType": deepcopy(problemType.state),
72 "ISA": next(iter(isaInfoMap.keys()))
73 }
74 solution.update(constantParams)
75 solution.update(perm)
76
77
78 mi = solution["MatrixInstruction"]
79 wavefrontSize = solution["WavefrontSize"]
80 workgroup = solution["WorkGroup"]
81 ptype = solution["ProblemType"]
82 isa = solution["ISA"]
83
84 if len(mi) == 9:
85 miParams = matrixInstructionToMIParameters(mi, isa, wavefrontSize, ptype, workgroup, isaInfoMap)
86 solution.update(miParams)
87 elif len(mi) == 0:
88 solution["EnableMatrixInstruction"] = False
89
90 if validateMIParameters(solution, isaInfoMap):
91 solutionObject = Solution(
92 solution,
93 debugConfig.splitGSU,
94 debugConfig.printSolutionRejectionReason,
95 debugConfig.printIndexAssignmentInfo,
96 assembler,
97 isaInfoMap
98 )
99 if solutionObject["Valid"]:
100 if solutionObject not in solutionSet:
101 solutionSet.add(solutionObject)
102 solutions.append(solutionObject)
103 elif debugConfig.printSolutionRejectionReason:
104 print1("rejecting solution " + str(solution))
105
106 return solutions
107
108
109 def _getCustomKernelSolutionObj(
110 kernelName,
111 internalSupportParams,
112 assembler: Assembler,
113 debugConfig: DebugConfig,
114 isaInfoMap: Dict[IsaVersion, IsaInfo],
115 directory=CUSTOM_KERNEL_PATH
116 ):
117 """Creates the Solution object for a custom kernel"""
118 sol = getCustomKernelConfig(kernelName, internalSupportParams, directory)
119
120 mi = sol["MatrixInstruction"]
121 isa = next(iter(isaInfoMap.keys()))
122 wavefrontSize = sol["WavefrontSize"]
123 ptype = sol["ProblemType"]
124 workgroup = sol.get("WorkGroup", None)
125
126 if len(mi) == 9:
127 miParams = matrixInstructionToMIParameters(mi, isa, wavefrontSize, ptype, workgroup, isaInfoMap)
128 sol.update(miParams)
129 elif len(mi) == 0:
130 sol["EnableMatrixInstruction"] = False
131
132 sol = Solution(
133 sol,
134 debugConfig.printIndexAssignmentInfo,
135 debugConfig.printSolutionRejectionReason,
136 debugConfig.printIndexAssignmentInfo,
137 assembler,
138 isaInfoMap
139 )
140
141 return sol
142
143
144 def _generateCustomKernelSolutions(
145 problemType,
146 customKernels,
147 internalSupportParams,
148 failOnMismatch,
149 assembler: Assembler,
150 debugConfig: DebugConfig,
151 isaInfoMap: Dict[str, IsaInfo]
152 ):
153 """Creates a list with a Solution object for each name in customKernel"""
154 solutions = []
155 for kernelName in customKernels:
156 print1("# Processing custom kernel {}".format(kernelName))
157 solution = _getCustomKernelSolutionObj(kernelName, internalSupportParams, assembler, debugConfig, isaInfoMap)
158 # The ActivationType setting in YAML is meaningless in customKernel case.
159 # Therefore, we override the customKernel setting with the ActivationType value from ProblemType to avoid false alarms during subsequent problemType checks.
160 solution["ProblemType"]["ActivationType"] = problemType["ActivationType"]
161 if solution["ProblemType"] != problemType:
162 # Raise error if this kernel was specifically requested and problem type doesn't match
163 if failOnMismatch:
164 benchmarkSet = set([(k,tuple(v)) if type(v) is list else (k,v) \
165 for k,v in problemType.items()])
166 customSet = set([(k,tuple(v)) if type(v) is list else (k,v) \
167 for k,v in solution["ProblemType"].items()])
168
169 msg = "The problem type in the config file does not match " \
170 "that of the custom kernel, {}.".format(kernelName) \
171 + "\nDiffering parameters:\n" \
172 + "\tConfig values:\n\t" \
173 + str(sorted(benchmarkSet - (customSet & benchmarkSet))) \
174 + "\n\tCustom kernel values:\n\t" \
175 + str(sorted(customSet - (customSet & benchmarkSet)))
176 printExit(msg)
177 else:
178 print1("# Rejected {}: Problem Type doesn't match".format(kernelName))
179 else:
180 print1("# Added {} to solutions".format(kernelName))
181 if solution["Valid"]:
182 solutions.append(solution)
183 elif debugConfig.printSolutionRejectionReason:
184 print1("rejecting solution " + str(solution))
185
186 return solutions
187
188 def writeBenchmarkFiles(
189 stepBaseDir,
190 solutions,
191 problemSizes,
192 biasTypeArgs,
193 factorDimArgs,
194 activationArgs,
195 icacheFlushArgs,
196 stepName,
197 solutionSummationSizes,
198 asmToolchain: AssemblyToolchain,
199 srcToolchain: SourceToolchain,
200 sourcePath: Path,
201 debugConfig: DebugConfig,
202 deviceId: int,
203 gfxName: str,
204 isaInfoMap: Dict[IsaVersion, IsaInfo],
205 probSolMap: dict
206 ):
207 """Write all the files needed for a given benchmarking step"""
208
209 ensurePath(sourcePath)
210 copyStaticFiles(sourcePath)
211
212 kernels = []
213 kernelHelperObjs = []
214 kernelNames = set()
215 kernelHelperNames = set()
216
217 # get unique kernels and kernel helpers
218 for solution in tqdm(solutions, "Finding unique solutions"):
219 solutionKernels = solution.getKernels()
220 for kernel in solutionKernels:
221 kName = getKeyNoInternalArgs(kernel, debugConfig.splitGSU)
222 if kName not in kernelNames:
223 kernels.append(kernel)
224 kernelNames.add(kName)
225
226 solutionHelperKernels = initHelperKernelObjects(solution,
227 KernelHelperEnum.All,
228 str(asmToolchain.assembler.path),
229 isaInfoMap)
230 for ko in solutionHelperKernels:
231 kname = ko.getKernelName()
232 if kname not in kernelHelperNames:
233 kernelHelperObjs.append(ko)
234 kernelHelperNames.add(kname)
235
236 kernelWriterAssembly = KernelWriterAssembly(asmToolchain.assembler, debugConfig)
237
238 cmdLineArchs = [var for isa in isaInfoMap.keys() for var in gfxToVariants(isaToGfx(isa))]
239 # cmdLineArchs = [variant isaToGfx(isa) for isa in isaInfoMap.keys() for gfxToVariants()]
240 # write solution, kernels and CMake
241 problemType = solutions[0]["ProblemType"]
242 codeObjectFiles, _= writeSolutionsAndKernels( \
243 sourcePath,
244 asmToolchain,
245 srcToolchain,
246 solutions,
247 kernels,
248 kernelHelperObjs,
249 kernelWriterAssembly,
250 debugConfig.splitGSU,
251 cmdLineArchs,
252 errorTolerant=True,
253 generateSourcesAndExit=globalParameters["GenerateSourcesAndExit"], # put in debug config
254 compress=False,
255 )
256 # ^ this is where solutions is mutated
257 for s in solutions:
258 s["SolutionNameMin"] = getSolutionNameMin(solution, debugConfig.splitGSU)
259 s["KernelNameMin"] = getKernelNameMin(solution, debugConfig.splitGSU)
260
261 newLibraryDir = ensurePath(sourcePath / 'library')
262 newLibraryFile = os.path.join(newLibraryDir, "TensileLibrary")
263 newLibrary = SolutionLibrary.MasterSolutionLibrary.BenchmarkingLibrary(
264 solutions,
265 asmToolchain.assembler,
266 debugConfig.splitGSU,
267 debugConfig.printSolutionRejectionReason,
268 debugConfig.printIndexAssignmentInfo,
269 isaInfoMap,
270 )
271 newLibrary.applyNaming(debugConfig.splitGSU)
272 LibraryIO.write(newLibraryFile, state(newLibrary), globalParameters["LibraryFormat"])
273
274 codeObjectFiles = [os.path.relpath(f, sourcePath) \
275 for f in codeObjectFiles]
276
277 if "TileAwareSelection" in problemType and problemType["TileAwareSelection"]:
278 maxMacroTile0 = 0
279 maxMacroTile1 = 0
280 for solution in solutions:
281 macroTile0 = solution["MacroTile0"]
282 macroTile1 = solution["MacroTile1"]
283 if macroTile0 > maxMacroTile0:
284 maxMacroTile0 = macroTile0
285 if macroTile1 > maxMacroTile1:
286 maxMacroTile1 = macroTile1
287 idealM = 36 * maxMacroTile0
288 idealN = 36 * maxMacroTile1
289 idealSizes = []
290 if problemType["Batched"]:
291 for idealK in solutionSummationSizes:
292 idealSize = {"Exact": [idealM, idealN, 1, idealK]}
293 idealSizes.append(idealSize)
294 else:
295 for idealK in solutionSummationSizes:
296 idealSize = {"Exact": [idealM, idealN, idealK]}
297 idealSizes.append(idealSize)
298 idealProblemSizes = ProblemSizes(problemType, idealSizes)
299 writeClientConfig(True, solutions, idealProblemSizes, biasTypeArgs, \
300 factorDimArgs, activationArgs, icacheFlushArgs, stepName, stepBaseDir, \
301 newLibrary, codeObjectFiles, True, deviceId, gfxName, probSolMap=probSolMap)
302 else:
303 writeClientConfig(True, solutions, problemSizes, biasTypeArgs, \
304 factorDimArgs, activationArgs, icacheFlushArgs, stepName, stepBaseDir, \
305 newLibrary, codeObjectFiles, False, deviceId, gfxName, probSolMap=probSolMap)
306
307 if len(solutions) == 0:
308 printExit("write solutions and kernels results 0 valid soultion.")
309
310 return codeObjectFiles
311
312
313 def _benchmarkProblemType(problemTypeConfig, problemSizeGroupConfig, problemSizeGroupIdx, useCache,
314 asmToolchain: AssemblyToolchain, srcToolchain: SourceToolchain, cCompiler: str,
315 buildTmpPath: Path, benchmarkProblemsPath: Path,
316 debugConfig: DebugConfig, deviceId: int,
317 gfxName: str, isaInfoMap: Dict[str, IsaInfo], probSolMap: dict
318 ):
319 """Run the benchmarking for a single entry in the BenchmarkProblems of a Tensile config"""
320 benchmarkTestFails = 0
321
322 print1("")
323 print1(HR)
324 print1("# Converting Config to BenchmarkProcess Object")
325 print1(HR)
326 print1("")
327 benchmarkProcess = BenchmarkProcess(problemTypeConfig, problemSizeGroupConfig, debugConfig.printIndexAssignmentInfo)
328
329 enableTileSelection = benchmarkProcess.problemType["TileAwareSelection"]
330 groupName = "{}_{:02d}".format(str(benchmarkProcess.problemType), problemSizeGroupIdx)
331 groupNamePath = benchmarkProblemsPath / groupName
332 ensurePath(groupNamePath / "Data")
333
334 totalBenchmarkSteps = len(benchmarkProcess)
335 resultsFileBaseFinal = None
336
337 print1("# NumBenchmarkSteps: {}".format(totalBenchmarkSteps))
338 print1("")
339 print1(HR)
340 print1("# Done Creating BenchmarkProcess Object")
341 print1(HR)
342
343 for benchmarkStepIdx in range(0, totalBenchmarkSteps):
344 benchmarkStep = benchmarkProcess[benchmarkStepIdx]
345 stepName = str(benchmarkStep)
346 shortName = stepName
347
348 print1("\n")
349 print1(HR)
350 currentTime = time.time()
351 elapsedTime = currentTime - startTime
352 print1("# Benchmark Step: {} - {} {:.3f}s".format(groupName, stepName, elapsedTime))
353 print1("# Num Sizes: {}".format(benchmarkStep.problemSizes.totalProblemSizes))
354 print1("# Factor Dim steps: {}".format(benchmarkStep.factorDimArgs.totalProblemSizes))
355 print1("# Bias Type steps: {}".format(benchmarkStep.biasTypeArgs.totalProblemSizes))
356 print1("# Activation steps: {}".format(benchmarkStep.activationArgs.totalProblemSizes))
357 print1("# ICacheFlush steps: {}".format(len(benchmarkStep.icacheFlushArgs)))
358 print1("# Fork Parameters:")
359 for k, v in benchmarkStep.forkParams.items():
360 print1("# {}: {}".format(k, v))
361 if benchmarkStep.internalSupportParams:
362 print("# InternalSupportParams: {}".format(benchmarkStep.internalSupportParams))
363
364 shortNamePath = ensurePath(groupNamePath / shortName)
365 stepBaseDir = shortNamePath
366 resultsFileBase = os.path.normpath(shortNamePath / ".." / "Data" / shortName)
367
368 if benchmarkStep.isFinal():
369 resultsFileBaseFinal = resultsFileBase
370 resultsFileName = resultsFileBase + ".csv"
371 solutionsFileName = resultsFileBase + ".yaml"
372
373 # check if a solution cache exists and if it matches our solution parameters
374 cachePath = os.path.join(stepBaseDir, "cache.yaml")
375 sourcePath = ensurePath(shortNamePath / "source")
376
377 cacheValid = False
378 if useCache and os.path.isfile(cachePath):
379 c = LibraryIO.read(cachePath)
380 if c["ConstantParams"] == benchmarkStep.constantParams and \
381 c["ForkParams"] == benchmarkStep.forkParams and \
382 c["ParamGroups"] == benchmarkStep.paramGroups and \
383 c["CustomKernels"] == benchmarkStep.customKernels and \
384 c["InternalSupportParams"] == benchmarkStep.internalSupportParams and \
385 c["CustomKernelWildcard"] == benchmarkStep.customKernelWildcard:
386 cacheValid = True
387 codeObjectFiles = c["CodeObjectFiles"]
388 else:
389 printWarning("Cache data does not match config: redoing solution generation")
390
391 if not cacheValid:
392 # enumerate benchmark permutations and create resulting solution objects
393 forkPermutations = constructForkPermutations(benchmarkStep.forkParams, \
394 benchmarkStep.paramGroups) if problemSizeGroupConfig["ForkParameters"] else []
395 maxPossibleSolutions = len(forkPermutations)
396
397 regSolutions = _generateForkedSolutions(benchmarkProcess.problemType, \
398 benchmarkStep.constantParams, forkPermutations, asmToolchain.assembler, \
399 debugConfig, isaInfoMap)
400 kcSolutions = _generateCustomKernelSolutions(benchmarkProcess.problemType, \
401 benchmarkStep.customKernels, benchmarkStep.internalSupportParams, \
402 not benchmarkStep.customKernelWildcard, asmToolchain.assembler, debugConfig, \
403 isaInfoMap)
404
405 maxPossibleSolutions += len(kcSolutions)
406 solutions = regSolutions + kcSolutions
407
408 print1("# Actual Solutions: {} / {} after SolutionStructs\n" \
409 .format(len(solutions), maxPossibleSolutions))
410
411 # handle no valid solutions
412 if len(solutions) == 0:
413 msg = "Your parameters resulted in 0 valid solutions."
414 if debugConfig.printSolutionRejectionReason:
415 msg += "\nExamine reject and backtrace messages above to see why" \
416 "and where solutions were rejected."
417 else:
418 msg += "\nYou should re-run with \"PrintSolutionRejectionReason: True\"" \
419 "to see why each parameter combination was rejected."
420 printExit(msg)
421
422 for solution in solutions:
423 print2("# ({}:{}) {}".format(0, 0, getSolutionNameMin(solution, debugConfig.splitGSU)))
424 print2(HR)
425
426 # write benchmarkFiles
427 prevCount = len(solutions)
428 codeObjectFiles = writeBenchmarkFiles(stepBaseDir, solutions, \
429 benchmarkStep.problemSizes, benchmarkStep.biasTypeArgs, \
430 benchmarkStep.factorDimArgs, benchmarkStep.activationArgs, \
431 benchmarkStep.icacheFlushArgs, shortName, [], asmToolchain, srcToolchain, \
432 sourcePath, debugConfig, deviceId, gfxName, isaInfoMap, probSolMap)
433 # ^ this mutates solutions
434
435 # write cache data
436 cacheData = {
437 "CodeObjectFiles": codeObjectFiles,
438 "ConstantParams": benchmarkStep.constantParams,
439 "ForkParams": benchmarkStep.forkParams,
440 "ParamGroups": benchmarkStep.paramGroups,
441 "CustomKernels": benchmarkStep.customKernels,
442 "CustomKernelWildcard": benchmarkStep.customKernelWildcard
443 }
444 LibraryIO.writeYAML(cachePath, cacheData)
445
446 print1("# Actual Solutions: {} / {} after KernelWriter\n" \
447 .format(len(solutions), prevCount ))
448
449 # add SolutionIndex and SolutionNameMin into benchmark yaml
450 for i in range(0, len(solutions)):
451 solution = solutions[i]
452 solution["SolutionIndex"] = i
453 solution["SolutionNameMin"] = getSolutionNameMin(solution, debugConfig.splitGSU)
454 solution["KernelNameMin"] = getKernelNameMin(solution, debugConfig.splitGSU)
455 else:
456 solutions = None
457 print1("# Using cached solution data")
458
459 ssProblemType = ProblemType(problemTypeConfig, debugConfig.printIndexAssignmentInfo)
460 conProblemType = ContractionsProblemType.FromOriginalState(ssProblemType)
461 outFile = os.path.join(sourcePath, "ClientParameters.ini")
462
463 writeClientConfigIni(True, benchmarkStep.problemSizes, benchmarkStep.biasTypeArgs,
464 benchmarkStep.factorDimArgs, benchmarkStep.activationArgs,
465 benchmarkStep.icacheFlushArgs, conProblemType,
466 stepBaseDir, codeObjectFiles, resultsFileName,
467 outFile, deviceId, probSolMap=probSolMap)
468
469 # I think the size portion of this yaml could be removed,
470 # but for now it's needed, so we update it even in the cache case
471 LibraryIO.writeSolutions(solutionsFileName, benchmarkStep.problemSizes, benchmarkStep.biasTypeArgs,
472 benchmarkStep.activationArgs, solutions, cacheValid)
473
474 # run benchmarking client
475 if not os.path.exists(resultsFileName) or globalParameters["ForceRedoBenchmarkProblems"]:
476 libraryLogicPath = None
477 forBenchmark = True
478 returncode = runClient(libraryLogicPath, forBenchmark, enableTileSelection, srcToolchain.compiler, cCompiler, shortNamePath)
479
480 if returncode:
481 benchmarkTestFails += 1
482 printWarning("BenchmarkProblems: Benchmark Process exited with code {}" \
483 .format(returncode))
484 else:
485 print1("# Already benchmarked; skipping.")
486
487 # End Iteration
488 currentTime = time.time()
489 elapsedTime = currentTime - startTime
490 print1("{}\n# {}\n# {}: End - {:.3f}s\n{}\n" \
491 .format(HR, groupName, shortName, elapsedTime, HR))
492
493 return (resultsFileBaseFinal, benchmarkTestFails)
494
495
496 def main(
497 config,
498 useCache,
499 asmToolchain: AssemblyToolchain,
500 srcToolchain: SourceToolchain,
501 cCompiler: str,
502 outputPath: Path,
503 buildTmpPath: Path,
504 debugConfig: DebugConfig,
505 deviceId: int,
506 gfxName: str,
507 isaInfoMap: Dict[str, IsaInfo],
508 probSolMap: dict
509 ):
510 """Entry point for the "BenchmarkProblems" section of a Tensile config yaml"""
511 getClientExecutablePath()
512
513 if config is None:
514 print(f'No config specified in {globalParameters["ConfigPath"]}, built client only')
515 return
516
517 benchmarkDataPath = ensurePath(outputPath / BENCHMARK_DATA_DIR)
518
519 totalTestFails = 0
520 for benchmarkProblemTypeConfig in config:
521 problemTypeConfig = benchmarkProblemTypeConfig[0]
522 if len(benchmarkProblemTypeConfig) < 2:
523 problemSizeGroupConfigs = [{}]
524 else:
525 problemSizeGroupConfigs = benchmarkProblemTypeConfig[1:]
526
527 for idx, sizeGroupConfig in enumerate(problemSizeGroupConfigs):
528 print2("ProblemTypeConfig: {}".format(problemTypeConfig))
529 problemTypeObj = ProblemType(problemTypeConfig, debugConfig.printIndexAssignmentInfo)
530
531 # using a suffix to check the csv version (for later addFromCSV())
532 csvSuffix = "_CSVWinner" if globalParameters["CSVExportWinner"] else ""
533 # results files will be named
534 newResultsFileName = os.path.join(benchmarkDataPath, "{}_{:02d}{}.csv" \
535 .format(str(problemTypeObj), idx, csvSuffix) )
536 newSolutionsFileName = os.path.join(benchmarkDataPath, "{}_{:02d}{}.yaml" \
537 .format(str(problemTypeObj), idx, csvSuffix) )
538 newGranularityFileName = os.path.join(benchmarkDataPath, "{}_{:02d}{}.gsp" \
539 .format(str(problemTypeObj), idx, csvSuffix) )
540
541 # skip if possible
542 if globalParameters["ForceRedoBenchmarkProblems"] \
543 or not os.path.exists(newResultsFileName):
544
545 # benchmark problem size group
546 benchmarkProblemsPath = ensurePath(outputPath / BENCHMARK_PROBLEMS_DIR)
547 (resultsFileBaseFinal, benchmarkErrors) = \
548 _benchmarkProblemType(
549 problemTypeConfig,
550 sizeGroupConfig,
551 idx,
552 useCache,
553 asmToolchain,
554 srcToolchain,
555 cCompiler,
556 buildTmpPath,
557 benchmarkProblemsPath,
558 debugConfig,
559 deviceId,
560 gfxName,
561 isaInfoMap,
562 probSolMap
563 )
564 totalTestFails += benchmarkErrors
565
566 print("clientExit={} {} for {}" \
567 .format(totalTestFails, "(ERROR)" if totalTestFails else "(PASS)", \
568 globalParameters["ConfigPath"]) )
569
570 # copy data
571 resultsFileBase = resultsFileBaseFinal
572 resultsFileName = resultsFileBase + ".csv"
573 solutionsFileName = resultsFileBase + ".yaml"
574 granularityFileName = resultsFileBase + "_Granularity.csv"
575 shutil.copy(resultsFileName, newResultsFileName)
576 shutil.copy(solutionsFileName, newSolutionsFileName)
577 if os.path.isfile(granularityFileName):
578 shutil.copy(granularityFileName, newGranularityFileName)
579 else:
580 print1("# {}_{:02d} already benchmarked; skipping." \
581 .format(str(problemTypeObj), idx) )
582
583 if globalParameters["ExitOnFails"] and totalTestFails:
584 sys.exit(1)