2 """Determine critical path for a given precedence trace.""" 4 __author__ =
"Illya Shapoval" 12 """Find critical path, print algorithms on it and its length.""" 16 ) >= 2.0,
"This script requires Networkx version 2.0 or higher" 18 trace = nx.read_graphml(path_to_trace_file)
20 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
21 edge_attrs[
'Runtime'] = nx.get_node_attributes(trace,
24 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
'Runtime')
26 print "Algorithms on the critical path (%i): " % len(cpath)
28 print " {:<40} Runtime (ns)".
format(
"Name")
29 print " -----------------------------------------------------" 31 print " {:<40}: {}".
format(trace.node[node_id].
get(
'Name'),
32 trace.node[node_id].
get(
'Runtime'))
34 print "\nTotal critical path time: ", nx.algorithms.dag.dag_longest_path_length(
35 trace, weight=
'Runtime'),
"ns" 40 parser = argparse.ArgumentParser(
42 "Determine critical path for a precedence trace generated by the Avalanche Scheduler." 46 help=
"Path to GRAPHML precedence trace file.",
48 args = parser.parse_args()
53 if __name__ ==
'__main__':
def get_critical_path(path_to_trace_file)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))