Skip to content

Commit

Permalink
Report wall and user time in generated assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
hanno-becker committed Mar 31, 2024
1 parent 0fa0182 commit a87eb29
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions slothy/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a87eb29

Please sign in to comment.