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