| 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 |
import itertools |
| 26 |
import os.path |
| 27 |
import subprocess |
| 28 |
import time |
| 29 |
from collections import OrderedDict |
| 30 |
from copy import deepcopy |
| 31 |
from typing import Dict |
| 32 |
|
| 33 |
from Tensile import __version__ |
| 34 |
|
| 35 |
from .Architectures import isaToGfx |
| 36 |
from .Types import IsaVersion, IsaInfo |
| 37 |
from .Utilities import locateExe, versionIsCompatible, print1, print2, printExit, printWarning, \ |
| 38 |
getVerbosity |
| 39 |
from .ValidParameters import validParameters |
| 40 |
|
| 41 |
startTime = time.time() |
| 42 |
|
| 43 |
globalParameters = OrderedDict() |
| 44 |
globalParameters["MinimumRequiredVersion"] = ( |
| 45 |
"0.0.0" |
| 46 |
) |
| 47 |
globalParameters["PerformanceMetric"] = ( |
| 48 |
"DeviceEfficiency" |
| 49 |
) |
| 50 |
globalParameters["ClientLogLevel"] = ( |
| 51 |
3 |
| 52 |
) |
| 53 |
|
| 54 |
globalParameters["KernelTime"] = False |
| 55 |
globalParameters["PreciseKernelTime"] = ( |
| 56 |
True |
| 57 |
) |
| 58 |
|
| 59 |
globalParameters["PinClocks"] = False |
| 60 |
globalParameters["HardwareMonitor"] = ( |
| 61 |
True |
| 62 |
) |
| 63 |
globalParameters["MinFlopsPerSync"] = ( |
| 64 |
1 |
| 65 |
) |
| 66 |
globalParameters["NumBenchmarks"] = ( |
| 67 |
1 |
| 68 |
) |
| 69 |
globalParameters["SyncsPerBenchmark"] = ( |
| 70 |
1 |
| 71 |
) |
| 72 |
globalParameters["EnqueuesPerSync"] = 1 |
| 73 |
globalParameters["MaxEnqueuesPerSync"] = -1 |
| 74 |
globalParameters["SleepPercent"] = ( |
| 75 |
300 |
| 76 |
) |
| 77 |
globalParameters["SkipSlowSolutionRatio"] = 0.0 |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
globalParameters["NumElementsToValidate"] = ( |
| 87 |
128 |
| 88 |
) |
| 89 |
globalParameters["NumElementsToValidateWinner"] = ( |
| 90 |
0 |
| 91 |
) |
| 92 |
globalParameters["BoundsCheck"] = 0 |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
globalParameters["ValidationMaxToPrint"] = 4 |
| 99 |
globalParameters["ValidationPrintValids"] = False |
| 100 |
|
| 101 |
globalParameters["ForceRedoBenchmarkProblems"] = ( |
| 102 |
True |
| 103 |
) |
| 104 |
globalParameters["ForceRedoLibraryLogic"] = ( |
| 105 |
True |
| 106 |
) |
| 107 |
globalParameters["ForceRedoLibraryClient"] = ( |
| 108 |
True |
| 109 |
) |
| 110 |
|
| 111 |
globalParameters["ShowProgressBar"] = ( |
| 112 |
True |
| 113 |
) |
| 114 |
globalParameters["SolutionSelectionAlg"] = ( |
| 115 |
1 |
| 116 |
) |
| 117 |
globalParameters["GenerateSourcesAndExit"] = False |
| 118 |
globalParameters["ExitOnFails"] = ( |
| 119 |
1 |
| 120 |
) |
| 121 |
globalParameters["CpuThreads"] = ( |
| 122 |
-1 |
| 123 |
) |
| 124 |
globalParameters["NumWarmups"] = 0 |
| 125 |
|
| 126 |
globalParameters["PythonProfile"] = False |
| 127 |
|
| 128 |
globalParameters["ISA"] = [] |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
globalParameters["CMakeBuildType"] = ( |
| 134 |
"Release" |
| 135 |
) |
| 136 |
globalParameters["LogicFormat"] = "yaml" |
| 137 |
globalParameters["LibraryFormat"] = "yaml" |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
globalParameters["CSVExportWinner"] = False |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
globalParameters["CSVMergeSameProblemID"] = False |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
globalParameters["DataInitTypeAB"] = 3 |
| 165 |
globalParameters["DataInitTypeA"] = -1 |
| 166 |
globalParameters["DataInitTypeB"] = -1 |
| 167 |
globalParameters["DataInitTypeC"] = 3 |
| 168 |
globalParameters["DataInitTypeD"] = 0 |
| 169 |
globalParameters["DataInitTypeE"] = 0 |
| 170 |
globalParameters["DataInitTypeAlpha"] = 2 |
| 171 |
globalParameters["DataInitTypeBeta"] = 2 |
| 172 |
globalParameters["DataInitTypeBias"] = 3 |
| 173 |
globalParameters["DataInitTypeScaleA"] = 2 |
| 174 |
globalParameters["DataInitTypeScaleB"] = 2 |
| 175 |
globalParameters["DataInitTypeScaleC"] = 2 |
| 176 |
globalParameters["DataInitTypeScaleD"] = 2 |
| 177 |
globalParameters["DataInitTypeScaleAlphaVec"] = 3 |
| 178 |
globalParameters["DataInitValueActivationArgs"] = [2.0, 2.0] |
| 179 |
globalParameters["CEqualD"] = ( |
| 180 |
False |
| 181 |
) |
| 182 |
|
| 183 |
|
| 184 |
globalParameters["DataInitSeed"] = 0 |
| 185 |
globalParameters["PruneSparseMode"] = ( |
| 186 |
0 |
| 187 |
) |
| 188 |
|
| 189 |
|
| 190 |
globalParameters["CMakeCXXFlags"] = "" |
| 191 |
globalParameters["CMakeCFlags"] = "" |
| 192 |
globalParameters["AsanBuild"] = False |
| 193 |
|
| 194 |
globalParameters["KeepBuildTmp"] = False |
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
globalParameters["PrintTensorA"] = 0 |
| 201 |
globalParameters["PrintTensorB"] = 0 |
| 202 |
globalParameters["PrintTensorC"] = ( |
| 203 |
0 |
| 204 |
) |
| 205 |
globalParameters["PrintTensorD"] = ( |
| 206 |
0 |
| 207 |
) |
| 208 |
globalParameters["PrintTensorRef"] = ( |
| 209 |
0 |
| 210 |
) |
| 211 |
globalParameters["PrintTensorBias"] = 0 |
| 212 |
globalParameters["PrintTensorScaleAlphaVec"] = 0 |
| 213 |
globalParameters["PrintTensorAmaxD"] = 0 |
| 214 |
globalParameters["PrintWinnersOnly"] = False |
| 215 |
globalParameters["PrintCodeCommands"] = ( |
| 216 |
False |
| 217 |
) |
| 218 |
globalParameters["DumpTensors"] = ( |
| 219 |
False |
| 220 |
) |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
globalParameters["Platform"] = 0 |
| 227 |
|
| 228 |
|
| 229 |
globalParameters["ClientExecutionLockPath"] = ( |
| 230 |
None |
| 231 |
) |
| 232 |
globalParameters["LibraryUpdateFile"] = ( |
| 233 |
"" |
| 234 |
) |
| 235 |
globalParameters["LibraryUpdateComment"] = ( |
| 236 |
False |
| 237 |
) |
| 238 |
|
| 239 |
|
| 240 |
globalParameters["ROCmSMIPath"] = None |
| 241 |
globalParameters["HipClangVersion"] = "0.0.0" |
| 242 |
|
| 243 |
|
| 244 |
if os.name == "nt": |
| 245 |
globalParameters["RuntimeLanguage"] = "HIP" |
| 246 |
else: |
| 247 |
globalParameters["RuntimeLanguage"] = "HIP" |
| 248 |
|
| 249 |
globalParameters["CodeObjectVersion"] = "4" |
| 250 |
|
| 251 |
|
| 252 |
globalParameters["PerfModelL2ReadHits"] = 0.0 |
| 253 |
globalParameters["PerfModelL2WriteHits"] = 0.15 |
| 254 |
globalParameters["PerfModelL2ReadBwMul"] = 2 |
| 255 |
globalParameters["PerfModelReadEfficiency"] = 0.85 |
| 256 |
|
| 257 |
|
| 258 |
globalParameters["MaxWorkspaceSize"] = 128 * 1024 * 1024 |
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
globalParameters["GranularityThreshold"] = 0.0 |
| 263 |
|
| 264 |
globalParameters["PristineOnGPU"] = ( |
| 265 |
True |
| 266 |
) |
| 267 |
|
| 268 |
globalParameters["SeparateArchitectures"] = ( |
| 269 |
False |
| 270 |
) |
| 271 |
|
| 272 |
globalParameters["LazyLibraryLoading"] = ( |
| 273 |
False |
| 274 |
) |
| 275 |
|
| 276 |
globalParameters["EnableMarker"] = False |
| 277 |
|
| 278 |
globalParameters["UseUserArgs"] = False |
| 279 |
|
| 280 |
globalParameters["RotatingBufferSize"] = 0 |
| 281 |
globalParameters["RotatingMode"] = ( |
| 282 |
0 |
| 283 |
) |
| 284 |
|
| 285 |
|
| 286 |
globalParameters["BuildIdKind"] = "sha1" |
| 287 |
globalParameters["AsmDebug"] = ( |
| 288 |
False |
| 289 |
) |
| 290 |
|
| 291 |
globalParameters["UseEffLike"] = True |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
defaultGlobalParameters = deepcopy(globalParameters) |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
internalParameters = { |
| 304 |
|
| 305 |
"GlobalSplitUPGR": 16 |
| 306 |
} |
| 307 |
|
| 308 |
|
| 309 |
defaultInternalSupportParams = { |
| 310 |
"KernArgsVersion": 2, |
| 311 |
|
| 312 |
|
| 313 |
"SupportUserGSU": True, |
| 314 |
|
| 315 |
|
| 316 |
"SupportCustomWGM": True, |
| 317 |
"SupportCustomStaggerU": True, |
| 318 |
|
| 319 |
"UseUniversalArgs": True, |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
defaultBenchmarkCommonParameters = [ |
| 324 |
{"InnerUnroll": [1]}, |
| 325 |
{"KernelLanguage": ["Assembly"]}, |
| 326 |
{"LdsPadA": [-1]}, |
| 327 |
{"LdsPadB": [-1]}, |
| 328 |
{"LdsPadMetadata": [0]}, |
| 329 |
{"LdsBlockSizePerPadA": [-1]}, |
| 330 |
{"LdsBlockSizePerPadB": [-1]}, |
| 331 |
{"LdsBlockSizePerPadMetadata": [0]}, |
| 332 |
{"TransposeLDS": [-1]}, |
| 333 |
{"MaxOccupancy": [40]}, |
| 334 |
{"MaxLDS": [-1]}, |
| 335 |
{"VectorWidthA": [-1]}, |
| 336 |
{"VectorWidthB": [-1]}, |
| 337 |
{"VectorStore": [-1]}, |
| 338 |
{"StoreVectorWidth": [-1]}, |
| 339 |
{"GlobalReadVectorWidthA": [-1]}, |
| 340 |
{"GlobalReadVectorWidthB": [-1]}, |
| 341 |
{"LocalReadVectorWidth": [-1]}, |
| 342 |
{"WaveSeparateGlobalReadA": [0]}, |
| 343 |
{"WaveSeparateGlobalReadB": [0]}, |
| 344 |
{"WaveSeparateGlobalReadMetadata": [0]}, |
| 345 |
{"UnrollLoopSwapGlobalReadOrder": [0]}, |
| 346 |
{"PrefetchGlobalRead": [1]}, |
| 347 |
{"PrefetchLocalRead": [1]}, |
| 348 |
{"ClusterLocalRead": [1]}, |
| 349 |
{"SuppressNoLoadLoop": [False]}, |
| 350 |
{"ExpandPointerSwap": [True]}, |
| 351 |
{"ScheduleGlobalRead": [1]}, |
| 352 |
{"ScheduleLocalWrite": [1]}, |
| 353 |
{"ScheduleIterAlg": [3]}, |
| 354 |
{"GlobalReadPerMfma": [1]}, |
| 355 |
{"LocalWritePerMfma": [-1]}, |
| 356 |
{"InterleaveAlpha": [0]}, |
| 357 |
{"OptNoLoadLoop": [1]}, |
| 358 |
{"BufferLoad": [True]}, |
| 359 |
{"BufferStore": [True]}, |
| 360 |
{"DirectToVgprA": [False]}, |
| 361 |
{"DirectToVgprB": [False]}, |
| 362 |
{"DirectToVgprSparseMetadata": [False]}, |
| 363 |
{"DirectToLds": [False]}, |
| 364 |
{"UseSgprForGRO": [-1]}, |
| 365 |
{"UseInstOffsetForGRO": [0]}, |
| 366 |
{"AssertSummationElementMultiple": [1]}, |
| 367 |
{"AssertFree0ElementMultiple": [1]}, |
| 368 |
{"AssertFree1ElementMultiple": [1]}, |
| 369 |
{"AssertAIGreaterThanEqual": [-1]}, |
| 370 |
{"AssertAILessThanEqual": [-1]}, |
| 371 |
{"StaggerU": [32]}, |
| 372 |
{"StaggerUStride": [256]}, |
| 373 |
{"StaggerUMapping": [0]}, |
| 374 |
{"MagicDivAlg": [2]}, |
| 375 |
{"GlobalSplitU": [1]}, |
| 376 |
{"GlobalSplitUAlgorithm": ["MultipleBuffer"]}, |
| 377 |
{"GlobalSplitUCoalesced": [False]}, |
| 378 |
{"GlobalSplitUWorkGroupMappingRoundRobin": [False]}, |
| 379 |
{"Use64bShadowLimit": [1]}, |
| 380 |
{"NumLoadsCoalescedA": [1]}, |
| 381 |
{"NumLoadsCoalescedB": [1]}, |
| 382 |
{"WorkGroup": [[16, 16, 1]]}, |
| 383 |
{"WorkGroupMapping": [8]}, |
| 384 |
{"WorkGroupMappingXCC": [1]}, |
| 385 |
{"WorkGroupMappingXCCGroup": [-1]}, |
| 386 |
{"ThreadTile": [[4, 4]]}, |
| 387 |
{"WavefrontSize": [64]}, |
| 388 |
{"MatrixInstruction": [[]]}, |
| 389 |
{"1LDSBuffer": [0]}, |
| 390 |
{"DepthU": [-1]}, |
| 391 |
{"NonTemporalE": [0]}, |
| 392 |
{"NonTemporalD": [0]}, |
| 393 |
{"NonTemporalC": [0]}, |
| 394 |
{"NonTemporalA": [0]}, |
| 395 |
{"NonTemporalB": [0]}, |
| 396 |
{"NonTemporalWS": [0]}, |
| 397 |
{"NonTemporalMetadata": [0]}, |
| 398 |
{"NonTemporal": [-1]}, |
| 399 |
{"PreloadKernArgs": [True]}, |
| 400 |
{"CustomKernelName": [""]}, |
| 401 |
{"NoReject": [False]}, |
| 402 |
{"StoreRemapVectorWidth": [0]}, |
| 403 |
{"SourceSwap": [False]}, |
| 404 |
{"StorePriorityOpt": [False]}, |
| 405 |
{"NumElementsPerBatchStore": [0]}, |
| 406 |
{"StoreSyncOpt": [0]}, |
| 407 |
{"GroupLoadStore": [False]}, |
| 408 |
{"MIArchVgpr": [False]}, |
| 409 |
{"StreamK": [0]}, |
| 410 |
{"StreamKAtomic": [0]}, |
| 411 |
{"StreamKXCCMapping": [0]}, |
| 412 |
{"DebugStreamK": [0]}, |
| 413 |
{"ActivationFused": [True]}, |
| 414 |
{"ActivationFuncCall": [True]}, |
| 415 |
{"ActivationAlt": [False]}, |
| 416 |
{"WorkGroupReduction": [False]}, |
| 417 |
{"ConvertAfterDS": [False]}, |
| 418 |
{"ForceDisableShadowInit": [False]}, |
| 419 |
{"LDSTrInst": [False]}, |
| 420 |
{"WaveSplitK": [ False ]}, |
| 421 |
{"MbskPrefetchMethod": [0]}, |
| 422 |
{"UseCustomMainLoopSchedule": [1]} |
| 423 |
] |
| 424 |
|
| 425 |
|
| 426 |
defaultSolution = {} |
| 427 |
for paramDict in defaultBenchmarkCommonParameters: |
| 428 |
for key, value in paramDict.items(): |
| 429 |
defaultSolution[key] = value[0] |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
defaultProblemSizes = [{"Range": [[2880], 0, 0]}] |
| 435 |
defaultBenchmarkFinalProblemSizes = [{"Range": [[64, 64, 64, 512], 0, 0]}] |
| 436 |
defaultBatchedProblemSizes = [{"Range": [[2880], 0, [1], 0]}] |
| 437 |
defaultBatchedBenchmarkFinalProblemSizes = [{"Range": [[64, 64, 64, 512], 0, [1], 0]}] |
| 438 |
|
| 439 |
|
| 440 |
defaultSolutionSummationSizes = [32, 64, 96, 128, 256, 512, 1024, 2048, 4096, 8192, 16192] |
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
defaultAnalysisParameters = { |
| 447 |
"ScheduleName": "Tensile", |
| 448 |
"DeviceNames": "fallback", |
| 449 |
"ArchitectureName": "gfx000", |
| 450 |
"LibraryType": "GridBased", |
| 451 |
"SolutionImportanceMin": 0.01, |
| 452 |
} |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
def restoreDefaultGlobalParameters(): |
| 461 |
""" |
| 462 |
Restores `globalParameters` back to defaults. |
| 463 |
""" |
| 464 |
global globalParameters |
| 465 |
global defaultGlobalParameters |
| 466 |
|
| 467 |
|
| 468 |
globalParameters.clear() |
| 469 |
for key, value in deepcopy(defaultGlobalParameters).items(): |
| 470 |
globalParameters[key] = value |
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
def printCapabilitiesTable(isaInfoMap: Dict[str, IsaInfo]): |
| 475 |
""" |
| 476 |
Prints a capability table for the given parameters and ISA information map. |
| 477 |
|
| 478 |
Args: |
| 479 |
supportedIsas: The ISAs to show in the table. |
| 480 |
isaInfoMap: The ISA information map containing assembler and architecture capabilities. |
| 481 |
""" |
| 482 |
|
| 483 |
def printTable(rows): |
| 484 |
rows = [[str(cell) for cell in row] for row in rows] |
| 485 |
colWidths = [max(len(cell) for cell in col) for col in zip(*rows)] |
| 486 |
|
| 487 |
for row in rows: |
| 488 |
print(" ".join(cell.ljust(width) for cell, width in zip(row, colWidths))) |
| 489 |
|
| 490 |
def capRow(isaInfoMap, cap, capType): |
| 491 |
return [cap] + [ |
| 492 |
"1" if cap in getattr(info, capType) and getattr(info, capType)[cap] else "-" |
| 493 |
for info in isaInfoMap.values() |
| 494 |
] |
| 495 |
|
| 496 |
gfxs = list(map(isaToGfx, isaInfoMap.keys())) |
| 497 |
headerRow = ["Capability"] + gfxs |
| 498 |
|
| 499 |
allAsmCaps = sorted( |
| 500 |
set(itertools.chain(*[info.asmCaps for info in isaInfoMap.values()])), |
| 501 |
key=lambda k: (k.split("_")[-1], k), |
| 502 |
) |
| 503 |
asmCapRows = [capRow(isaInfoMap, cap, "asmCaps") for cap in allAsmCaps] |
| 504 |
|
| 505 |
allArchCaps = sorted(set(itertools.chain(*[info.archCaps for info in isaInfoMap.values()]))) |
| 506 |
archCapRows = [capRow(isaInfoMap, cap, "archCaps") for cap in allArchCaps] |
| 507 |
|
| 508 |
printTable([headerRow] + asmCapRows + archCapRows) |
| 509 |
|
| 510 |
|
| 511 |
def assignGlobalParameters(config, isaInfoMap: Dict[IsaVersion, IsaInfo]): |
| 512 |
""" |
| 513 |
Assign Global Parameters |
| 514 |
Each global parameter has a default parameter, and the user |
| 515 |
can override them, those overridings happen here |
| 516 |
""" |
| 517 |
|
| 518 |
global globalParameters |
| 519 |
|
| 520 |
|
| 521 |
if "MinimumRequiredVersion" in config: |
| 522 |
if not versionIsCompatible(config["MinimumRequiredVersion"]): |
| 523 |
printExit( |
| 524 |
"Config file requires version=%s is not compatible with current Tensile version=%s" |
| 525 |
% (config["MinimumRequiredVersion"], __version__) |
| 526 |
) |
| 527 |
|
| 528 |
|
| 529 |
print2("GlobalParameters:") |
| 530 |
for key in globalParameters: |
| 531 |
defaultValue = globalParameters[key] |
| 532 |
if key in config: |
| 533 |
configValue = config[key] |
| 534 |
if configValue == defaultValue: |
| 535 |
print2(" %24s: %8s (same)" % (key, configValue)) |
| 536 |
else: |
| 537 |
print2(" %24s: %8s (overriden)" % (key, configValue)) |
| 538 |
else: |
| 539 |
print2(" %24s: %8s (unspecified)" % (key, defaultValue)) |
| 540 |
|
| 541 |
globalParameters["ROCmPath"] = "/opt/rocm" |
| 542 |
if "ROCM_PATH" in os.environ: |
| 543 |
globalParameters["ROCmPath"] = os.environ.get("ROCM_PATH") |
| 544 |
if "TENSILE_ROCM_PATH" in os.environ: |
| 545 |
globalParameters["ROCmPath"] = os.environ.get("TENSILE_ROCM_PATH") |
| 546 |
if os.name == "nt" and "HIP_DIR" in os.environ: |
| 547 |
globalParameters["ROCmPath"] = os.environ.get("HIP_DIR") |
| 548 |
globalParameters["CmakeCxxCompiler"] = None |
| 549 |
if "CMAKE_CXX_COMPILER" in os.environ: |
| 550 |
globalParameters["CmakeCxxCompiler"] = os.environ.get("CMAKE_CXX_COMPILER") |
| 551 |
if "CMAKE_C_COMPILER" in os.environ: |
| 552 |
globalParameters["CmakeCCompiler"] = os.environ.get("CMAKE_C_COMPILER") |
| 553 |
|
| 554 |
globalParameters["ROCmBinPath"] = os.path.join(globalParameters["ROCmPath"], "bin") |
| 555 |
try: |
| 556 |
globalParameters["ROCmSMIPath"] = locateExe(globalParameters["ROCmBinPath"], "rocm-smi") |
| 557 |
except OSError: |
| 558 |
if os.name == "nt": |
| 559 |
|
| 560 |
pass |
| 561 |
else: |
| 562 |
raise |
| 563 |
|
| 564 |
if "AsanBuild" in config: |
| 565 |
globalParameters["AsanBuild"] = config["AsanBuild"] |
| 566 |
|
| 567 |
if "KeepBuildTmp" in config: |
| 568 |
globalParameters["KeepBuildTmp"] = config["KeepBuildTmp"] |
| 569 |
|
| 570 |
if "CodeObjectVersion" in config: |
| 571 |
globalParameters["CodeObjectVersion"] = config["CodeObjectVersion"] |
| 572 |
|
| 573 |
if getVerbosity() >= 1: |
| 574 |
printCapabilitiesTable(isaInfoMap) |
| 575 |
|
| 576 |
isaList = list(isaInfoMap.keys()) |
| 577 |
validParameters["ISA"] = [IsaVersion(0, 0, 0), *isaList] |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
try: |
| 590 |
compiler = "hipcc" |
| 591 |
output = subprocess.run( |
| 592 |
[compiler, "--version"], check=True, |
| 593 |
stdout=subprocess.PIPE, |
| 594 |
|
| 595 |
stderr=subprocess.DEVNULL, |
| 596 |
).stdout.decode() |
| 597 |
|
| 598 |
for line in output.split("\n"): |
| 599 |
if "HIP version" in line: |
| 600 |
globalParameters["HipClangVersion"] = line.split()[2] |
| 601 |
print1("# Found hipcc version " + globalParameters["HipClangVersion"]) |
| 602 |
|
| 603 |
except (subprocess.CalledProcessError, OSError) as e: |
| 604 |
printWarning("Error: {} running {} {} ".format("hipcc", "--version", e)) |
| 605 |
|
| 606 |
|
| 607 |
ignoreKeys = [ |
| 608 |
"Architecture", |
| 609 |
"PrintLevel", |
| 610 |
"Device", |
| 611 |
"UseCompression", |
| 612 |
"CxxCompiler", |
| 613 |
"CCompiler", |
| 614 |
"OffloadBundler", |
| 615 |
"Assembler", |
| 616 |
"LogicPath", |
| 617 |
"LogicFilter", |
| 618 |
"OutputPath", |
| 619 |
"Experimental", |
| 620 |
"GenSolTable", |
| 621 |
] |
| 622 |
for key in config: |
| 623 |
if key in ignoreKeys: |
| 624 |
continue |
| 625 |
value = config[key] |
| 626 |
if key not in globalParameters: |
| 627 |
printWarning("Global parameter %s = %s unrecognised." % (key, value)) |
| 628 |
globalParameters[key] = value |
| 629 |
|
| 630 |
|
| 631 |
def setupRestoreClocks(): |
| 632 |
import atexit |
| 633 |
|
| 634 |
def restoreClocks(): |
| 635 |
|
| 636 |
|
| 637 |
if globalParameters["PinClocks"]: |
| 638 |
rsmi = globalParameters["ROCmSMIPath"] |
| 639 |
if rsmi is not None: |
| 640 |
subprocess.call([rsmi, "-d", "0", "--resetclocks"]) |
| 641 |
subprocess.call([rsmi, "-d", "0", "--setfan", "50"]) |
| 642 |
|
| 643 |
atexit.register(restoreClocks) |
| 644 |
|
| 645 |
setupRestoreClocks() |