Skip to content

Commit bf9ac8c

Browse files
committed
Timeline: Add detail info for single event
1 parent 7f7d6d6 commit bf9ac8c

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

lglpy/timeline/gui/timeline/info_widget.py

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
from collections import defaultdict
3030

31-
from ...data.raw_trace import GPUStreamID
31+
from ...data.raw_trace import GPUStreamID, GPUStageID
3232
from ...data.processed_trace import GPUWorkload
3333
from ...drawable.text_pane_widget import TextPaneWidget
3434

@@ -251,13 +251,71 @@ def get_active_region_stats(self):
251251

252252
return self.cached_range_info
253253

254+
def compute_active_event_stats_single(self, event):
255+
'''
256+
Get the metrics for the active event.
257+
258+
This function uses a cached lookup to avoid re-calculating every
259+
redraw, as the stats computation can be quite slow.
260+
261+
Args:
262+
event: The active event.
263+
264+
Returns:
265+
List of lines to be printed.
266+
'''
267+
# Skip non-workload types
268+
if not isinstance(event, GPUWorkload):
269+
return []
270+
271+
stream_name = GPUStreamID.get_ui_name(event.stream)
272+
stage_name = GPUStageID.get_ui_name(event.stage)
273+
274+
metrics = ['']
275+
276+
# Report total runtime of the selected workloads
277+
other_names = [
278+
'API workloads:',
279+
'Hardware workloads:'
280+
]
281+
282+
metrics.append('Active workload runtime:')
283+
label_len = len(stream_name) + len(' stream:')
284+
label_len = max(max(len(x) for x in other_names), label_len)
285+
286+
label = other_names[0]
287+
metrics.append(f' {label:{label_len}} {1:>5}')
288+
289+
label = other_names[1]
290+
metrics.append(f' {label:{label_len}} {1:>5}')
291+
292+
label = f'{stream_name} stream:'
293+
duration = float(event.duration) / 1000000.0
294+
metrics.append(f' {label:{label_len}} {duration:>5.2f} ms')
295+
296+
# Report total N workloads
297+
metrics.append('')
298+
metrics.append('Workload properties:')
299+
300+
label = event.get_workload_name()
301+
metrics.append(f' Name: {label}')
302+
metrics.append(f' Stream: {stream_name}')
303+
metrics.append(f' Stage: {stage_name}')
304+
metrics.append(f' Start: {event.start_time / 1000000.0:0.2f} ms')
305+
metrics.append(f' Duration: {event.duration / 1000000.0:0.2f} ms')
306+
metrics.append('')
307+
return metrics
308+
254309
def compute_active_event_stats_multi(self, active):
255310
'''
256-
Get the metrics for the active time range.
311+
Get the metrics for the active events.
257312
258313
This function uses a cached lookup to avoid re-calculating every
259314
redraw, as the stats computation can be quite slow.
260315
316+
Args:
317+
active: List of active events.
318+
261319
Returns:
262320
List of lines to be printed.
263321
'''
@@ -368,6 +426,9 @@ def get_active_event_stats(self):
368426
if len(active) == 0:
369427
info = None
370428

429+
elif len(active) == 1:
430+
info = self.compute_active_event_stats_single(active[0])
431+
371432
else:
372433
info = self.compute_active_event_stats_multi(active)
373434

0 commit comments

Comments
 (0)