@@ -44,22 +44,24 @@ Requires the following events enabled in `enable_logging!`: `taskdeps`, `tasknam
4444
4545Options:
4646- `disconnected`: If `true`, render disconnected vertices (tasks or arguments without upstream/downstream dependencies)
47+ - `show_data`: If `true`, show the data dependencies in the graph
4748- `color_by`: How to color tasks; if `:fn`, then color by unique function name, if `:proc`, then color by unique processor
4849- `times`: If `true`, annotate each task with its start and finish times
4950- `times_digits`: Number of digits to display in the time annotations
5051- `colors`: A list of colors to use for coloring tasks
5152- `name_to_color`: A function that maps task names to colors
5253"""
53- function show_logs (io:: IO , logs:: Dict , :: Val{:graphviz} ; disconnected= false ,
54+ function show_logs (io:: IO , logs:: Dict , :: Val{:graphviz} ;
55+ disconnected= false , show_data:: Bool = true ,
5456 color_by= :fn , times:: Bool = true , times_digits:: Integer = 3 ,
5557 colors= default_colors, name_to_color= name_to_color)
56- dot = logs_to_dot (logs; disconnected, times, times_digits,
58+ dot = logs_to_dot (logs; disconnected, show_data, times, times_digits,
5759 color_by, colors, name_to_color)
5860 println (io, dot)
5961end
6062
61- function logs_to_dot (logs:: Dict ; disconnected= false , color_by = :fn ,
62- times:: Bool = true , times_digits:: Integer = 3 ,
63+ function logs_to_dot (logs:: Dict ; disconnected= false , show_data :: Bool = true ,
64+ color_by = :fn , times:: Bool = true , times_digits:: Integer = 3 ,
6365 colors= default_colors, name_to_color= name_to_color)
6466 # Lookup all relevant task/argument dependencies and values in logs
6567 g = SimpleDiGraph ()
@@ -325,36 +327,40 @@ function logs_to_dot(logs::Dict; disconnected=false, color_by=:fn,
325327 end
326328
327329 # Add object vertices
328- for objid in all_objids
329- objid_v = objid_to_vertex[objid]
330- if ! disconnected && ! (objid_v in con_vs)
331- continue
332- end
333- if objid in dtasks_to_patch || haskey (uid_to_tid, objid)
334- # DTask, skip it
335- continue
336- end
337- # Object
338- if haskey (objid_to_name, objid)
339- label = sanitize_label (objid_to_name[objid])
340- label *= " \\ nData: $(repr (objid)) "
341- else
342- label = " Data: $(repr (objid)) "
330+ if show_data
331+ for objid in all_objids
332+ objid_v = objid_to_vertex[objid]
333+ if ! disconnected && ! (objid_v in con_vs)
334+ continue
335+ end
336+ if objid in dtasks_to_patch || haskey (uid_to_tid, objid)
337+ # DTask, skip it
338+ continue
339+ end
340+ # Object
341+ if haskey (objid_to_name, objid)
342+ label = sanitize_label (objid_to_name[objid])
343+ label *= " \\ nData: $(repr (objid)) "
344+ else
345+ label = " Data: $(repr (objid)) "
346+ end
347+ str *= " a$objid_v [label=\" $label \" , shape=oval]\n "
343348 end
344- str *= " a$objid_v [label=\" $label \" , shape=oval]\n "
345349 end
346350
347351 # Add task argument move edges
348- seen_moves = Set {Tuple{UInt,UInt}} ()
349- for (tid, moves) in task_arg_moves
350- for (pos, (pre_objid, post_objid)) in moves
351- pre_objid == post_objid && continue
352- (pre_objid, post_objid) in seen_moves && continue
353- push! (seen_moves, (pre_objid, post_objid))
354- pre_objid_v = objid_to_vertex[pre_objid]
355- post_objid_v = objid_to_vertex[post_objid]
356- move_str = " a$pre_objid_v -> a$post_objid_v [label=\" move\" ]\n "
357- str *= move_str
352+ if show_data
353+ seen_moves = Set {Tuple{UInt,UInt}} ()
354+ for (tid, moves) in task_arg_moves
355+ for (pos, (pre_objid, post_objid)) in moves
356+ pre_objid == post_objid && continue
357+ (pre_objid, post_objid) in seen_moves && continue
358+ push! (seen_moves, (pre_objid, post_objid))
359+ pre_objid_v = objid_to_vertex[pre_objid]
360+ post_objid_v = objid_to_vertex[post_objid]
361+ move_str = " a$pre_objid_v -> a$post_objid_v [label=\" move\" ]\n "
362+ str *= move_str
363+ end
358364 end
359365 end
360366
@@ -371,31 +377,33 @@ function logs_to_dot(logs::Dict; disconnected=false, color_by=:fn,
371377 str *= " v$(src (edge)) $edge_sep v$(dst (edge)) [label=\" syncdep\" ]\n "
372378 end
373379
374- # Add task argument edges
375- for (tid, args) in task_args
376- haskey (tid_to_vertex, tid) || continue
377- tid_v = tid_to_vertex[tid]
378- tid_v in con_vs || continue
379- for (pos, arg) in args
380- arg_v = objid_to_vertex[arg]
381- if ! disconnected && ! (arg_v in con_vs)
382- continue
380+ if show_data
381+ # Add task argument edges
382+ for (tid, args) in task_args
383+ haskey (tid_to_vertex, tid) || continue
384+ tid_v = tid_to_vertex[tid]
385+ tid_v in con_vs || continue
386+ for (pos, arg) in args
387+ arg_v = objid_to_vertex[arg]
388+ if ! disconnected && ! (arg_v in con_vs)
389+ continue
390+ end
391+ arg_str = sanitize_label (pos isa Int ? " arg $pos " : " kwarg $pos " )
392+ str *= " a$arg_v $edge_sep v$tid_v [label=\" $arg_str \" ]\n "
383393 end
384- arg_str = sanitize_label (pos isa Int ? " arg $pos " : " kwarg $pos " )
385- str *= " a$arg_v $edge_sep v$tid_v [label=\" $arg_str \" ]\n "
386394 end
387- end
388395
389- # Add task result edges
390- for (tid, result) in task_result
391- haskey (tid_to_vertex, tid) || continue
392- tid_v = tid_to_vertex[tid]
393- tid_v in con_vs || continue
394- result_v = objid_to_vertex[result]
395- if ! disconnected && ! (result_v in con_vs)
396- continue
396+ # Add task result edges
397+ for (tid, result) in task_result
398+ haskey (tid_to_vertex, tid) || continue
399+ tid_v = tid_to_vertex[tid]
400+ tid_v in con_vs || continue
401+ result_v = objid_to_vertex[result]
402+ if ! disconnected && ! (result_v in con_vs)
403+ continue
404+ end
405+ str *= " v$tid_v $edge_sep a$result_v [label=\" result\" ]\n "
397406 end
398- str *= " v$tid_v $edge_sep a$result_v [label=\" result\" ]\n "
399407 end
400408
401409 # Generate the final graph
0 commit comments