51 def l1MenuGraph(flags, do_dot=False, verbose=False):
52 """Find the L1Topo call graph. For each node, provide a AlgData
53 object. These objects carry information needed to configure
58 logger.debug(
'menu object')
59 logger.debug(L1Menu.printSummary())
64 for algType
in (
"TOPO",
"MULTTOPO"):
65 algs = L1Menu.topoAlgorithms(algType)
67 for alg_key
in algs.keys():
68 keyed_algs = algs[alg_key]
69 for name, value
in keyed_algs.items():
73 ad.klass = value[
'klass']
74 ad.l1AlgType = algType
75 if algType ==
'MULTTOPO':
76 ad.globalL1AlgType =
'COUNT'
78 threshold_name = value[
'threshold']
79 ad.threshold = L1Menu.thresholds()[threshold_name][
'value']
80 ad.threshold_flavour = value[
'flavour']
82 logger.info(
'No threshold data for COUNT alg '+name)
84 inputs = value[
'input']
85 if isinstance(inputs, list):
90 outputs = value[
'output']
91 if isinstance(outputs, list):
94 ad.outputs = [outputs]
100 alg_data_list.append(ad)
106 [all_inputs.extend(ad.inputs)
for ad
in alg_data_list]
107 all_inputs = {}.fromkeys(all_inputs)
108 all_inputs = all_inputs.keys()
111 [all_outputs.extend(ad.outputs)
for ad
in alg_data_list]
112 all_outputs = {}.fromkeys(all_outputs)
113 all_outputs = all_outputs.keys()
118 if k
not in all_outputs:
119 missing_inputs.append(k)
121 logger.debug(
'input algs to be added ['+
str(len(missing_inputs))+
']')
122 for io
in missing_inputs:
123 logger.debug(
'input alg: ' + io)
128 klass =
'TopoEventInputAlg'
129 ad.name = klass +
'_' + io
132 ad.globalL1AlgType =
'INPUT'
135 alg_data_list.append(ad)
138 for ad
in alg_data_list:
139 if ad.globalL1AlgType
is not None:
continue
140 isSortAlg = ad.inputs[0]
in missing_inputs
142 if len(ad.inputs) != 1:
143 raise RuntimeError(
'AlgData with > 1 inputs '
144 'at least 1 from input alg')
146 ad.globalL1AlgType =
'SORT'
148 for inp
in ad.inputs:
149 if inp
in missing_inputs:
150 raise RuntimeError(
'AlgData with >1 inputs'
151 'at least 1 from input alg')
153 ad.globalL1AlgType =
'DECISION'
158 for ad
in alg_data_list:
160 assert algname
not in alg2inputs
162 alg2inputs[algname] = ad.inputs
164 for outp
in ad.outputs:
165 assert outp
not in output2alg
166 output2alg[outp] = algname
168 logger.verbose(
'\nalg2inputs')
169 logger.verbose(pprint.pformat(alg2inputs, indent=4))
171 logger.verbose(
'\noutput2alg')
172 logger.verbose(pprint.pformat(output2alg, indent=4))
176 alg_names = [ad.name
for ad
in alg_data_list]
177 assert len(alg_names) == len(
set(alg_names))
181 [outputs.extend(ad.outputs)
for ad
in alg_data_list]
182 assert len(outputs) == len(
set(outputs))
188 for a
in alg_data_list:
193 for ad
in alg_data_list:
194 ad.input_sns = [output2sn[inp]
for inp
in ad.inputs]
197 logger.verbose(
'\nalg data:')
198 for ad
in alg_data_list:
199 logger.verbose(pprint.pformat(
str(ad), indent=4))
206 for a
in alg_data_list:
209 adj_table[a.sn].
append(output2sn[i])
213 for w
in adj_table[v]:
219 return G, alg_data_list