Skip to content
Snippets Groups Projects
Commit 47938c57 authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

Merge branch 'fix-profiling-for-python3' into 'master'

Fix profiling for python3

See merge request !31
parents 61a971bd 7c3db818
No related branches found
No related tags found
1 merge request!31Fix profiling for python3
Pipeline #70107 passed
......@@ -529,17 +529,24 @@ class ComputationalGraph(ComputationalGraphNode, metaclass=ABCMeta):
for (i, op) in enumerate(n):
yield (iprefix+str(i), pnprefix+op.pretty_name, nprefix+op.name, op)
if isinstance(op, Problem):
for _ in __recurse_nodes(op.nodes, iprefix+str(i)+":", pnprefix+op.pretty_name+".", nprefix+op.name+"."):
yield _
yield from __recurse_nodes(op.nodes,
iprefix+str(i)+":",
pnprefix+op.pretty_name+".",
nprefix+op.name+".")
def __line(_i, _pn, _op, _k):
strdata = (_i, str(_op.mpi_params.task_id), _pn, type(_op).__name__, _k.split('.')[-1])
values = tuple(ff.format(self._profiler.all_data[_k][_])
for ff, _ in zip(("{:.5g}", "{}", "{:.5g}", "{:.5g}", "{:.5g}", "{}"),
(2, 1, 3, 4, 5, 0)))
return multiline_split(strdata + values, maxlen, split_sep, replace, newline_prefix)
ops, already_printed = [], []
ops += __line('', "MAIN", self, self.name+'.apply')
for (i, pn, n, op) in __recurse_nodes(self.nodes, nprefix=self.name+"."):
for k in self._profiler.all_data.keys():
if n == '.'.join(k.split('.')[:-1]) and not k in already_printed:
strdata = (i, str(op.mpi_params.task_id), pn, type(op).__name__, k.split('.')[-1])
values = tuple(ff.format(self._profiler.all_data[k][_])
for ff, _ in zip(("{:.5g}", "{}", "{:.5g}", "{:.5g}", "{:.5g}", "{}"), (2, 1, 3, 4, 5, 0)))
ops += multiline_split(strdata + values, maxlen, split_sep, replace, newline_prefix)
ops += __line(i, pn, op, k)
already_printed.append(k)
isize = max(strlen(s[0]) for s in ops)
......
......@@ -229,7 +229,7 @@ class Profiler(object):
nb = comm.allgather(len(self.table))
all_names = comm.allgather([_[0] for _ in self.table])
all_times = comm.allgather([_[1] for _ in self.table])
all_calls = comm.allgather([_[2] for _ in self.table])
all_calls = comm.allgather([int(_[2]) for _ in self.table])
all_data = {}
# all_data structure : task_size, calls nb, self total, task mean, task min, task max
nelem = 6
......@@ -243,7 +243,7 @@ class Profiler(object):
all_data[n][2] = t
all_data[n][nelem].append(t)
for n in all_data.keys():
all_data[n][1] /= all_data[n][0]
all_data[n][1] //= all_data[n][0]
all_data[n][3] = npw.average(all_data[n][nelem])
all_data[n][4] = npw.min(all_data[n][nelem])
all_data[n][5] = npw.max(all_data[n][nelem])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment