@@ -911,8 +911,7 @@ def generateLogicDataAndSolutions(logicFiles, args):
911
911
masterLibraries = {}
912
912
fullMasterLibrary = None
913
913
914
- nextSolIndex = 0
915
-
914
+ nextSolIndex = {}
916
915
for logic in Utils .tqdm (libraries , "Processing logic data" ):
917
916
(_ , architectureName , _ , solutionsForSchedule , _ , newLibrary ) = logic
918
917
@@ -923,10 +922,14 @@ def generateLogicDataAndSolutions(logicFiles, args):
923
922
masterLibraries [architectureName ] = deepcopy (newLibrary )
924
923
masterLibraries [architectureName ].version = args .version
925
924
elif globalParameters ["SeparateArchitectures" ] or globalParameters ["LazyLibraryLoading" ]:
925
+
926
926
if architectureName in masterLibraries :
927
- nextSolIndex = masterLibraries [architectureName ].merge (deepcopy (newLibrary ), nextSolIndex )
927
+ nextSolIndex [ architectureName ] = masterLibraries [architectureName ].merge (deepcopy (newLibrary ), nextSolIndex [ architectureName ] )
928
928
else :
929
929
masterLibraries [architectureName ] = deepcopy (newLibrary )
930
+ archIndexMap = MasterSolutionLibrary .ArchitectureIndexMap (architectureName )
931
+ masterLibraries [architectureName ].remapSolutionIndicesStartingFrom (archIndexMap )
932
+ nextSolIndex [architectureName ] = archIndexMap
930
933
masterLibraries [architectureName ].version = args .version
931
934
else :
932
935
if fullMasterLibrary is None :
@@ -944,8 +947,7 @@ def generateLogicDataAndSolutions(logicFiles, args):
944
947
if "fallback" in masterLibraries .keys ():
945
948
for key , value in masterLibraries .items ():
946
949
if key != "fallback" :
947
- value .merge (deepcopy (masterLibraries ["fallback" ]))
948
-
950
+ value .insert (deepcopy (masterLibraries ["fallback" ]))
949
951
masterLibraries .pop ("fallback" )
950
952
951
953
for _ , masterLibrary in masterLibraries .items ():
@@ -1017,6 +1019,23 @@ def WriteClientLibraryFromSolutions(solutionList, libraryWorkingPath, tensileSou
1017
1019
1018
1020
return (codeObjectFiles , newLibrary )
1019
1021
1022
+ ################################################################################
1023
+ # Write Master Solution Index CSV
1024
+ ################################################################################
1025
+ def writeMasterSolutionIndexCSV (outputPath , masterLibraries ):
1026
+ libraryPath = os .path .join (outputPath , "library" )
1027
+ ensurePath (libraryPath )
1028
+ try :
1029
+ with open (os .path .join (libraryPath , "TensileMasterSolutionIndex.csv" ), "w" ) as indexFile :
1030
+ indexFile .write ("architectureName,libraryName,libraryIndex,solutionIndex,solutionName\n " )
1031
+ for arch ,lib in masterLibraries .items ():
1032
+ for lazylibname ,lazylibvals in lib .lazyLibraries .items ():
1033
+ for solidx ,solution in lazylibvals .solutions .items ():
1034
+ line = "," .join (str (x ) for x in [arch , lazylibname , solidx , solution .index , solution .name ])
1035
+ indexFile .write ("%s\n " % (line ))
1036
+ except IOError as err :
1037
+ print1 ("Error writing MasterSolutionIndex %s" % err )
1038
+
1020
1039
################################################################################
1021
1040
# Tensile Create Library
1022
1041
################################################################################
@@ -1084,6 +1103,8 @@ def splitExtraParameters(par):
1084
1103
argParser .add_argument ("--global-parameters" , nargs = "+" , type = splitExtraParameters , default = [])
1085
1104
argParser .add_argument ("--ignore-asm-cap-cache" , dest = "IgnoreAsmCapCache" , action = "store_true" , default = False ,
1086
1105
help = "Ignore asm cap cache and derive the asm caps at runtime" )
1106
+ argParser .add_argument ("--write-master-solution-index" , dest = "WriteMasterSolutionIndex" , action = "store_true" ,
1107
+ default = False , help = "Output master solution index in csv format." )
1087
1108
args = argParser .parse_args ()
1088
1109
1089
1110
logicPath = args .LogicPath
@@ -1123,7 +1144,8 @@ def splitExtraParameters(par):
1123
1144
arguments ["CpuThreads" ] = args .CpuThreads
1124
1145
arguments ["PrintLevel" ] = args .PrintLevel
1125
1146
arguments ["IgnoreAsmCapCache" ] = args .IgnoreAsmCapCache
1126
-
1147
+ arguments ["WriteMasterSolutionIndex" ] = args .WriteMasterSolutionIndex
1148
+
1127
1149
for key , value in args .global_parameters :
1128
1150
arguments [key ] = value
1129
1151
@@ -1174,6 +1196,9 @@ def splitExtraParameters(par):
1174
1196
# Parse logicData, solutions, and masterLibraries from logic files
1175
1197
solutions , masterLibraries , fullMasterLibrary = generateLogicDataAndSolutions (logicFiles , args )
1176
1198
1199
+ if globalParameters ["LazyLibraryLoading" ] and arguments ["WriteMasterSolutionIndex" ]:
1200
+ writeMasterSolutionIndexCSV (outputPath , masterLibraries )
1201
+
1177
1202
kernels , kernelHelperObjs , _ = generateKernelObjectsFromSolutions (solutions )
1178
1203
1179
1204
# if any kernels are assembly, append every ISA supported
0 commit comments