12 """Determine critical path for a given precedence trace.""" 14 __author__ =
"Illya Shapoval" 22 """Find critical path, print algorithms on it and its length.""" 26 ) >= 2.0,
"This script requires Networkx version 2.0 or higher" 28 trace = nx.read_graphml(path_to_trace_file)
30 for inNode, outNode, edge_attrs
in trace.in_edges(data=
True):
31 edge_attrs[
'Runtime'] = nx.get_node_attributes(trace,
34 cpath = nx.algorithms.dag.dag_longest_path(trace, weight=
'Runtime')
36 print "Algorithms on the critical path (%i): " % len(cpath)
38 print " {:<40} Runtime (ns)".
format(
"Name")
39 print " -----------------------------------------------------" 41 print " {:<40}: {}".
format(trace.node[node_id].
get(
'Name'),
42 trace.node[node_id].
get(
'Runtime'))
44 print "\nTotal critical path time: ", nx.algorithms.dag.dag_longest_path_length(
45 trace, weight=
'Runtime'),
"ns" 50 parser = argparse.ArgumentParser(
52 "Determine critical path for a precedence trace generated by the Avalanche Scheduler." 56 help=
"Path to GRAPHML precedence trace file.",
58 args = parser.parse_args()
63 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()))