Commit 32989214 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Update the task plot scripts to include new tasks and subtasks.

Fixes an issue where gaps between successive tasks of the same type
were not seen as these were joined (for plotting efficiency I guess).
A gap is now seen.

Also change the colour handling so that the task/subtask types are
easier to differentiate.
parent dcaace6c
...@@ -31,8 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. ...@@ -31,8 +31,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import matplotlib import matplotlib
import matplotlib.collections as collections import matplotlib.collections as collections
matplotlib.use('Agg') matplotlib.use('Agg')
from matplotlib import colors
import pylab as pl import pylab as pl
import numpy as np import numpy as np
import six
import sys import sys
# Basic plot configuration. # Basic plot configuration.
...@@ -55,40 +57,46 @@ PLOT_PARAMS = {"axes.labelsize": 10, ...@@ -55,40 +57,46 @@ PLOT_PARAMS = {"axes.labelsize": 10,
pl.rcParams.update(PLOT_PARAMS) pl.rcParams.update(PLOT_PARAMS)
# Tasks and subtypes. Indexed as in tasks.h. # Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair", "init", "ghost", TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair",
"extra_ghost", "kick", "send", "recv", "init", "ghost", "extra_ghost", "drift", "kick1", "kick2",
"grav_gather_m", "grav_fft", "grav_mm", "grav_up", "timestep", "send", "recv", "grav_gather_m", "grav_fft",
"grav_external", "cooling", "count"] "grav_mm", "grav_up", "cooling", "sourceterms", "count"]
SUBTYPES = ["none", "density", "gradient", "force", "grav", "external_grav",
TASKCOLOURS = {"none": "black", "tend", "xv", "rho", "gpart", "count"]
"sort": "lightblue",
"self": "greenyellow", # Task/subtypes of interest.
"pair": "navy", FULLTYPES = ["self/force", "self/density", "sub_self/force",
"sub_self": "greenyellow", "sub_self/density", "pair/force", "pair/density", "sub_pair/force",
"sub_pair": "navy", "sub_pair/density", "recv/xv", "send/xv", "recv/rho", "send/rho",
"init": "indigo", "recv/tend", "send/tend"]
"ghost": "cyan",
"extra_ghost": "cyan", # Get a number of colours for the various types.
"kick": "green", colours = ["black", "gray", "rosybrown", "firebrick", "red", "darksalmon",
"send": "yellow", "sienna", "sandybrown", "bisque", "tan", "moccasin", "gold", "darkkhaki",
"recv": "magenta", "lightgoldenrodyellow", "olivedrab", "chartreuse", "darksage", "lightgreen",
"grav_gather_m": "mediumorchid", "green", "mediumseagreen", "mediumaquamarine", "mediumturquoise", "darkslategrey",
"grav_fft": "mediumnightblue", "cyan", "cadetblue", "skyblue", "dodgerblue", "slategray", "darkblue",
"grav_mm": "mediumturquoise", "slateblue", "blueviolet", "mediumorchid", "purple", "magenta", "hotpink",
"grav_up": "mediumvioletred", "pink"]
"grav_external": "darkred", maxcolours = len(colours)
"cooling": "darkblue",
"count": "powerblue"} # Set colours of task/subtype.
TASKCOLOURS = {}
SUBTYPES = ["none", "density", "gradient", "force", "grav", "tend", "count"] ncolours = 0
for task in TASKTYPES:
SUBCOLOURS = {"none": "black", TASKCOLOURS[task] = colours[ncolours]
"density": "red", ncolours = (ncolours + 1) % maxcolours
"gradient": "powerblue",
"force": "blue", SUBCOLOURS = {}
"grav": "indigo", for task in SUBTYPES:
"tend": "grey", SUBCOLOURS[task] = colours[ncolours]
"count": "black"} ncolours = (ncolours + 1) % maxcolours
for task in FULLTYPES:
SUBCOLOURS[task] = colours[ncolours]
ncolours = (ncolours + 1) % maxcolours
print SUBCOLOURS
# Show docs if help is requested. # Show docs if help is requested.
if len( sys.argv ) == 2 and ( sys.argv[1][0:2] == "-h" or sys.argv[1][0:3] == "--h" ): if len( sys.argv ) == 2 and ( sys.argv[1][0:2] == "-h" or sys.argv[1][0:3] == "--h" ):
...@@ -149,39 +157,26 @@ num_lines = pl.size(data) / 10 ...@@ -149,39 +157,26 @@ num_lines = pl.size(data) / 10
for line in range(num_lines): for line in range(num_lines):
thread = int(data[line,0]) thread = int(data[line,0])
tasks[thread].append({}) tasks[thread].append({})
tasks[thread][-1]["type"] = TASKTYPES[int(data[line,1])] tasktype = TASKTYPES[int(data[line,1])]
tasks[thread][-1]["subtype"] = SUBTYPES[int(data[line,2])] subtype = SUBTYPES[int(data[line,2])]
tasks[thread][-1]["type"] = tasktype
tasks[thread][-1]["subtype"] = subtype
tic = int(data[line,4]) / CPU_CLOCK * 1000 tic = int(data[line,4]) / CPU_CLOCK * 1000
toc = int(data[line,5]) / CPU_CLOCK * 1000 toc = int(data[line,5]) / CPU_CLOCK * 1000
tasks[thread][-1]["tic"] = tic tasks[thread][-1]["tic"] = tic
tasks[thread][-1]["toc"] = toc tasks[thread][-1]["toc"] = toc
tasks[thread][-1]["t"] = (toc + tic)/ 2 tasks[thread][-1]["t"] = (toc + tic)/ 2
if "self" in tasktype or "pair" in tasktype:
fulltype = tasktype + "/" + subtype
if fulltype in SUBCOLOURS:
tasks[thread][-1]["colour"] = SUBCOLOURS[fulltype]
else:
tasks[thread][-1]["colour"] = SUBCOLOURS[subtype]
else:
tasks[thread][-1]["colour"] = TASKCOLOURS[tasktype]
combtasks = {}
combtasks[-1] = []
for i in range(nthread):
combtasks[i] = []
for thread in range(nthread): for thread in range(nthread):
tasks[thread] = sorted(tasks[thread], key=lambda l: l["t"]) tasks[thread] = sorted(tasks[thread], key=lambda l: l["t"])
lasttype = ""
types = []
for task in tasks[thread]:
if task["type"] not in types:
types.append(task["type"])
if lasttype == "" or not lasttype == task["type"]:
combtasks[thread].append({})
combtasks[thread][-1]["type"] = task["type"]
combtasks[thread][-1]["subtype"] = task["subtype"]
combtasks[thread][-1]["tic"] = task["tic"]
combtasks[thread][-1]["toc"] = task["toc"]
if task["type"] == "self" or task["type"] == "pair" or task["type"] == "sub":
combtasks[thread][-1]["colour"] = SUBCOLOURS[task["subtype"]]
else:
combtasks[thread][-1]["colour"] = TASKCOLOURS[task["type"]]
lasttype = task["type"]
else:
combtasks[thread][-1]["toc"] = task["toc"]
typesseen = [] typesseen = []
fig = pl.figure() fig = pl.figure()
...@@ -192,11 +187,11 @@ tictoc = np.zeros(2) ...@@ -192,11 +187,11 @@ tictoc = np.zeros(2)
for i in range(nthread): for i in range(nthread):
# Collect ranges and colours into arrays. # Collect ranges and colours into arrays.
tictocs = np.zeros(len(combtasks[i])*2) tictocs = np.zeros(len(tasks[i])*2)
colours = np.empty(len(combtasks[i])*2, dtype='object') colours = np.empty(len(tasks[i])*2, dtype='object')
coloursseen = [] coloursseen = []
j = 0 j = 0
for task in combtasks[i]: for task in tasks[i]:
tictocs[j] = task["tic"] tictocs[j] = task["tic"]
tictocs[j+1] = task["toc"] tictocs[j+1] = task["toc"]
colours[j] = task["colour"] colours[j] = task["colour"]
......
...@@ -63,40 +63,44 @@ PLOT_PARAMS = {"axes.labelsize": 10, ...@@ -63,40 +63,44 @@ PLOT_PARAMS = {"axes.labelsize": 10,
pl.rcParams.update(PLOT_PARAMS) pl.rcParams.update(PLOT_PARAMS)
# Tasks and subtypes. Indexed as in tasks.h. # Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair", "init", TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair",
"ghost", "extra_ghost", "kick", "send", "recv", "init", "ghost", "extra_ghost", "drift", "kick1", "kick2",
"grav_gather_m", "grav_fft", "grav_mm", "grav_up", "timestep", "send", "recv", "grav_gather_m", "grav_fft",
"grav_external", "cooling", "count"] "grav_mm", "grav_up", "cooling", "sourceterms", "count"]
SUBTYPES = ["none", "density", "gradient", "force", "grav", "external_grav",
TASKCOLOURS = {"none": "black", "tend", "xv", "rho", "gpart", "count"]
"sort": "lightblue",
"self": "greenyellow", # Task/subtypes of interest.
"pair": "navy", FULLTYPES = ["self/force", "self/density", "sub_self/force",
"sub_self": "greenyellow", "sub_self/density", "pair/force", "pair/density", "sub_pair/force",
"sub_pair": "navy", "sub_pair/density", "recv/xv", "send/xv", "recv/rho", "send/rho",
"init": "indigo", "recv/tend", "send/tend"]
"ghost": "cyan",
"extra_ghost": "cyan", # Get a number of colours for the various types.
"kick": "green", colours = ["black", "gray", "rosybrown", "firebrick", "red", "darksalmon",
"send": "yellow", "sienna", "sandybrown", "bisque", "tan", "moccasin", "gold", "darkkhaki",
"recv": "magenta", "lightgoldenrodyellow", "olivedrab", "chartreuse", "darksage", "lightgreen",
"grav_gather_m": "mediumorchid", "green", "mediumseagreen", "mediumaquamarine", "mediumturquoise", "darkslategrey",
"grav_fft": "mediumnightblue", "cyan", "cadetblue", "skyblue", "dodgerblue", "slategray", "darkblue",
"grav_mm": "mediumturquoise", "slateblue", "blueviolet", "mediumorchid", "purple", "magenta", "hotpink",
"grav_up": "mediumvioletred", "pink"]
"grav_external": "darkred", maxcolours = len(colours)
"cooling": "darkblue",
"count": "powerblue"} # Set colours of task/subtype.
TASKCOLOURS = {}
SUBTYPES = ["none", "density", "gradient", "force", "grav", "tend", "count"] ncolours = 0
for task in TASKTYPES:
SUBCOLOURS = {"none": "black", TASKCOLOURS[task] = colours[ncolours]
"density": "red", ncolours = (ncolours + 1) % maxcolours
"gradient": "powerblue",
"force": "blue", SUBCOLOURS = {}
"grav": "indigo", for task in SUBTYPES:
"tend": "grey", SUBCOLOURS[task] = colours[ncolours]
"count": "black"} ncolours = (ncolours + 1) % maxcolours
for task in FULLTYPES:
SUBCOLOURS[task] = colours[ncolours]
ncolours = (ncolours + 1) % maxcolours
# Show docs if help is requested. # Show docs if help is requested.
if len( sys.argv ) == 2 and ( sys.argv[1][0:2] == "-h" or sys.argv[1][0:3] == "--h" ): if len( sys.argv ) == 2 and ( sys.argv[1][0:2] == "-h" or sys.argv[1][0:3] == "--h" ):
...@@ -185,39 +189,26 @@ for rank in range(nranks): ...@@ -185,39 +189,26 @@ for rank in range(nranks):
for line in range(num_lines): for line in range(num_lines):
thread = int(data[line,1]) thread = int(data[line,1])
tasks[thread].append({}) tasks[thread].append({})
tasks[thread][-1]["type"] = TASKTYPES[int(data[line,2])] tasktype = TASKTYPES[int(data[line,2])]
tasks[thread][-1]["subtype"] = SUBTYPES[int(data[line,3])] subtype = SUBTYPES[int(data[line,3])]
tasks[thread][-1]["type"] = tasktype
tasks[thread][-1]["subtype"] = subtype
tic = int(data[line,5]) / CPU_CLOCK * 1000 tic = int(data[line,5]) / CPU_CLOCK * 1000
toc = int(data[line,6]) / CPU_CLOCK * 1000 toc = int(data[line,6]) / CPU_CLOCK * 1000
tasks[thread][-1]["tic"] = tic tasks[thread][-1]["tic"] = tic
tasks[thread][-1]["toc"] = toc tasks[thread][-1]["toc"] = toc
tasks[thread][-1]["t"] = (toc + tic)/ 2 tasks[thread][-1]["t"] = (toc + tic)/ 2
if "self" in tasktype or "pair" in tasktype or "recv" in tasktype or "send" in tasktype:
combtasks = {} fulltype = tasktype + "/" + subtype
combtasks[-1] = [] if fulltype in SUBCOLOURS:
for i in range(nthread): tasks[thread][-1]["colour"] = SUBCOLOURS[fulltype]
combtasks[i] = [] else:
tasks[thread][-1]["colour"] = SUBCOLOURS[subtype]
else:
tasks[thread][-1]["colour"] = TASKCOLOURS[tasktype]
for thread in range(nthread): for thread in range(nthread):
tasks[thread] = sorted(tasks[thread], key=lambda l: l["t"]) tasks[thread] = sorted(tasks[thread], key=lambda l: l["t"])
lasttype = ""
types = []
for task in tasks[thread]:
if task["type"] not in types:
types.append(task["type"])
if lasttype == "" or not lasttype == task["type"]:
combtasks[thread].append({})
combtasks[thread][-1]["type"] = task["type"]
combtasks[thread][-1]["subtype"] = task["subtype"]
combtasks[thread][-1]["tic"] = task["tic"]
combtasks[thread][-1]["toc"] = task["toc"]
if task["type"] == "self" or task["type"] == "pair" or task["type"] == "sub":
combtasks[thread][-1]["colour"] = SUBCOLOURS[task["subtype"]]
else:
combtasks[thread][-1]["colour"] = TASKCOLOURS[task["type"]]
lasttype = task["type"]
else:
combtasks[thread][-1]["toc"] = task["toc"]
fig = pl.figure() fig = pl.figure()
ax = fig.add_subplot(1,1,1) ax = fig.add_subplot(1,1,1)
...@@ -227,11 +218,11 @@ for rank in range(nranks): ...@@ -227,11 +218,11 @@ for rank in range(nranks):
for i in range(nthread): for i in range(nthread):
# Collect ranges and colours into arrays. # Collect ranges and colours into arrays.
tictocs = np.zeros(len(combtasks[i])*2) tictocs = np.zeros(len(tasks[i])*2)
colours = np.empty(len(combtasks[i])*2, dtype='object') colours = np.empty(len(tasks[i])*2, dtype='object')
coloursseen = [] coloursseen = []
j = 0 j = 0
for task in combtasks[i]: for task in tasks[i]:
tictocs[j] = task["tic"] tictocs[j] = task["tic"]
tictocs[j+1] = task["toc"] tictocs[j+1] = task["toc"]
colours[j] = task["colour"] colours[j] = task["colour"]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment