From a87eb29561ba96c9d9bb9feadaf756bb46d20df4 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Sun, 31 Mar 2024 07:02:15 +0100 Subject: [PATCH] Report wall and user time in generated assembly --- slothy/core/core.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/slothy/core/core.py b/slothy/core/core.py index 3c3e17f0..a90866e5 100644 --- a/slothy/core/core.py +++ b/slothy/core/core.py @@ -253,6 +253,16 @@ def ipc_bound(self): return None return (self.codesize / cc) + @property + def optimization_wall_time(self): + """Returns the amount of wall clock time in seconds the optimization has taken""" + return self._optimization_wall_time + + @property + def optimization_user_time(self): + """Returns the amount of CPU time in seconds the optimization has taken""" + return self._optimization_user_time + @property def ipc(self): """The instruction/cycle (IPC) count that SLOTHY thinks the code will have.""" @@ -296,6 +306,16 @@ def codesize_with_bubbles(self, v): assert self._codesize_with_bubbles is None self._codesize_with_bubbles = v + @optimization_user_time.setter + def optimization_user_time(self, v): + assert self._optimization_user_time is None + self._optimization_user_time = v + + @optimization_wall_time.setter + def optimization_wall_time(self, v): + assert self._optimization_wall_time is None + self._optimization_wall_time = v + @property def pre_core_post_dict(self): """Dictionary indicating interleaving of iterations. @@ -643,12 +663,28 @@ def gen_visualized_code(): .set_comment(f"Expected IPC: {self.ipc:.2f}") \ .set_length(fixlen)) if self.cycles_bound is not None: + res.append(SourceLine("") \ + .set_comment(f"") \ + .set_length(fixlen)) res.append(SourceLine("") \ .set_comment(f"Cycle bound: {self.cycles_bound}") \ .set_length(fixlen)) res.append(SourceLine("") \ .set_comment(f"IPC bound: {self.ipc_bound:.2f}") \ .set_length(fixlen)) + if self.optimization_wall_time is not None: + res.append(SourceLine("") \ + .set_comment(f"") \ + .set_length(fixlen)) + res.append(SourceLine("") \ + .set_comment(f"Wall time: {self.optimization_wall_time:.2f}s") \ + .set_length(fixlen)) + res.append(SourceLine("") \ + .set_comment(f"User time: {self.optimization_user_time:.2f}s") \ + .set_length(fixlen)) + res.append(SourceLine("") \ + .set_comment(f"") \ + .set_length(fixlen)) res += list(gen_visualized_code()) res += self.orig_code_visualized @@ -1194,6 +1230,8 @@ def __init__(self, config): self._pre_core_post_dict = None self._codesize_with_bubbles = None self._register_used = None + self._optimization_wall_time = None + self._optimization_user_time = None self.lock() @@ -1757,6 +1795,9 @@ def _extract_positions(self, get_value): cycles_bound, _ = self._stalls_to_stats(stalls_bound) self._result.cycles_bound = cycles_bound + self._result.optimization_wall_time = self._model.cp_solver.WallTime() + self._result.optimization_user_time = self._model.cp_solver.UserTime() + nodes = self._model.tree.nodes if self.config.sw_pipelining.enabled: nodes_low = self._model.tree.nodes_low