diff --git a/doc/RTD/source/AnalysisTools/index.rst b/doc/RTD/source/AnalysisTools/index.rst index 80a04e24234997921c374a429826aaf817a5706e..ac28fb41a747a70ce62c0085e0427e5465a7de63 100644 --- a/doc/RTD/source/AnalysisTools/index.rst +++ b/doc/RTD/source/AnalysisTools/index.rst @@ -176,7 +176,7 @@ A short summary of the scripts in ``tools/task_plots/``: whole step and per thread and the minimum and maximum times spent per task type. - ``iplot_tasks.py``: An interactive task plot, showing what thread was doing what task and for - how long for a step. **Needs python2 and the tkinter module**. + how long for a step. **Needs the tkinter module**. - ``plot_tasks.py``: Creates a task plot image, showing what thread was doing what task and for how long. - ``plot_threadpool.py``: diff --git a/tools/task_plots/iplot_tasks.py b/tools/task_plots/iplot_tasks.py index 50e65ebf9b7b285ce6f8c55f20d1006db1c30e67..f136ec78782a167e4aa3403375fa38308c27d116 100755 --- a/tools/task_plots/iplot_tasks.py +++ b/tools/task_plots/iplot_tasks.py @@ -49,7 +49,7 @@ import sys import argparse # import hardcoded data -from swift_hardcoded_data import TASKTYPES, SUBTYPES +from swift_hardcoded_data import TASKTYPES, SUBTYPES, TASKCOLOURS, SUBCOLOURS # Handle the command line. parser = argparse.ArgumentParser(description="Plot task graphs") @@ -127,145 +127,6 @@ PLOT_PARAMS = { } pl.rcParams.update(PLOT_PARAMS) -# Task/subtypes of interest. -FULLTYPES = [ - "self/limiter", - "self/force", - "self/gradient", - "self/density", - "self/grav", - "sub_self/limiter", - "sub_self/force", - "sub_self/gradient", - "sub_self/density", - "pair/limiter", - "pair/force", - "pair/gradient", - "pair/density", - "pair/grav", - "sub_pair/limiter", - "sub_pair/force", - "sub_pair/gradient", - "sub_pair/density", - "recv/xv", - "send/xv", - "recv/rho", - "send/rho", - "recv/tend_part", - "send/tend_part", - "recv/tend_gpart", - "send/tend_gpart", - "recv/tend_spart", - "send/tend_spart", - "recv/tend_bpart", - "send/tend_bpart", - "recv/gpart", - "send/gpart", - "recv/spart", - "send/spart", - "send/sf_counts", - "recv/sf_counts", - "recv/bpart", - "send/bpart", - "recv/limiter", - "send/limiter", - "pack/limiter", - "unpack/limiter", - "self/stars_density", - "pair/stars_density", - "sub_self/stars_density", - "sub_pair/stars_density", - "self/stars_prep1", - "pair/stars_prep1", - "sub_self/stars_prep1", - "sub_pair/stars_prep1", - "self/stars_prep2", - "pair/stars_prep2", - "sub_self/stars_prep2", - "sub_pair/stars_prep2", - "self/stars_feedback", - "pair/stars_feedback", - "sub_self/stars_feedback", - "sub_pair/stars_feedback", - "self/bh_density", - "pair/bh_density", - "sub_self/bh_density", - "sub_pair/bh_density", - "self/bh_swallow", - "pair/bh_swallow", - "sub_self/bh_swallow", - "sub_pair/bh_swallow", - "self/do_swallow", - "pair/do_swallow", - "sub_self/do_swallow", - "sub_pair/do_swallow", - "self/bh_feedback", - "pair/bh_feedback", - "sub_self/bh_feedback", - "sub_pair/bh_feedback", -] - -# A number of colours for the various types. Recycled when there are -# more task types than colours... -colours = [ - "cyan", - "lightgray", - "darkblue", - "yellow", - "tan", - "dodgerblue", - "sienna", - "aquamarine", - "bisque", - "blue", - "green", - "lightgreen", - "brown", - "purple", - "moccasin", - "olivedrab", - "chartreuse", - "olive", - "darkgreen", - "green", - "mediumseagreen", - "mediumaquamarine", - "darkslategrey", - "mediumturquoise", - "black", - "cadetblue", - "skyblue", - "red", - "slategray", - "gold", - "slateblue", - "blueviolet", - "mediumorchid", - "firebrick", - "magenta", - "hotpink", - "pink", - "orange", - "lightgreen", -] -maxcolours = len(colours) - -# Set colours of task/subtype. -TASKCOLOURS = {} -ncolours = 0 -for task in TASKTYPES: - TASKCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours - -SUBCOLOURS = {} -for task in FULLTYPES: - SUBCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours - -for task in SUBTYPES: - SUBCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours - # For fiddling with colours... if args.verbose: print("#Selected colours:") diff --git a/tools/task_plots/plot_tasks.py b/tools/task_plots/plot_tasks.py index 2f6f6733bc88ff62c8120a5887f8a45f354eb6be..7cdb93846db3c88fe794901597d2058311c7e55d 100755 --- a/tools/task_plots/plot_tasks.py +++ b/tools/task_plots/plot_tasks.py @@ -50,7 +50,7 @@ import sys import argparse # import hardcoded data -from swift_hardcoded_data import TASKTYPES, SUBTYPES +from swift_hardcoded_data import TASKTYPES, SUBTYPES, TASKCOLOURS, SUBCOLOURS # Handle the command line. parser = argparse.ArgumentParser(description="Plot task graphs") @@ -150,144 +150,6 @@ PLOT_PARAMS = { } pl.rcParams.update(PLOT_PARAMS) -# Task/subtypes of interest. -FULLTYPES = [ - "self/limiter", - "self/force", - "self/gradient", - "self/density", - "self/grav", - "sub_self/limiter", - "sub_self/force", - "sub_self/gradient", - "sub_self/density", - "pair/limiter", - "pair/force", - "pair/gradient", - "pair/density", - "pair/grav", - "sub_pair/limiter", - "sub_pair/force", - "sub_pair/gradient", - "sub_pair/density", - "recv/xv", - "send/xv", - "recv/rho", - "send/rho", - "recv/tend_part", - "send/tend_part", - "recv/tend_gpart", - "send/tend_gpart", - "recv/tend_spart", - "send/tend_spart", - "recv/tend_bpart", - "send/tend_bpart", - "recv/gpart", - "send/gpart", - "recv/spart", - "send/spart", - "send/sf_counts", - "recv/sf_counts", - "recv/bpart", - "send/bpart", - "recv/limiter", - "send/limiter", - "pack/limiter", - "unpack/limiter", - "self/stars_density", - "pair/stars_density", - "sub_self/stars_density", - "sub_pair/stars_density", - "self/stars_prep1", - "pair/stars_prep1", - "sub_self/stars_prep1", - "sub_pair/stars_prep1", - "self/stars_prep2", - "pair/stars_prep2", - "sub_self/stars_prep2", - "sub_pair/stars_prep2", - "self/stars_feedback", - "pair/stars_feedback", - "sub_self/stars_feedback", - "sub_pair/stars_feedback", - "self/bh_density", - "pair/bh_density", - "sub_self/bh_density", - "sub_pair/bh_density", - "self/bh_swallow", - "pair/bh_swallow", - "sub_self/bh_swallow", - "sub_pair/bh_swallow", - "self/do_swallow", - "pair/do_swallow", - "sub_self/do_swallow", - "sub_pair/do_swallow", - "self/bh_feedback", - "pair/bh_feedback", - "sub_self/bh_feedback", - "sub_pair/bh_feedback", -] - -# A number of colours for the various types. Recycled when there are -# more task types than colours... -colours = [ - "cyan", - "lightgray", - "darkblue", - "yellow", - "tan", - "dodgerblue", - "sienna", - "aquamarine", - "bisque", - "blue", - "green", - "lightgreen", - "brown", - "purple", - "moccasin", - "olivedrab", - "chartreuse", - "olive", - "darkgreen", - "green", - "mediumseagreen", - "mediumaquamarine", - "darkslategrey", - "mediumturquoise", - "black", - "cadetblue", - "skyblue", - "red", - "slategray", - "gold", - "slateblue", - "blueviolet", - "mediumorchid", - "firebrick", - "magenta", - "hotpink", - "pink", - "orange", - "lightgreen", -] -maxcolours = len(colours) - -# Set colours of task/subtype. -TASKCOLOURS = {} -ncolours = 0 -for task in TASKTYPES: - TASKCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours - -SUBCOLOURS = {} -for task in FULLTYPES: - SUBCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours - -for task in SUBTYPES: - SUBCOLOURS[task] = colours[ncolours] - ncolours = (ncolours + 1) % maxcolours # For fiddling with colours... if args.verbose: @@ -518,4 +380,5 @@ for rank in ranks: pl.close() print("Graphics done, output written to", outpng) + sys.exit(0) diff --git a/tools/task_plots/swift_hardcoded_data.py b/tools/task_plots/swift_hardcoded_data.py index cafc2233b2259be246c4acd8ad08991d94dfe34a..7d18c657dd859556a6262f4f0b34796727c8bc9d 100644 --- a/tools/task_plots/swift_hardcoded_data.py +++ b/tools/task_plots/swift_hardcoded_data.py @@ -1,12 +1,18 @@ #!/usr/bin/env python3 -# ------------------------------------------------------------ -# This file contains data that is hardcoded into swift -# that needs to be reproduced exactly in order for analysis -# outputs to make any sense. -# The data is used in other scripts in this directory, this -# script is intended for imports only. -# ------------------------------------------------------------ +# ----------------------------------------------------------------------------- +# This file contains data that is hardcoded into swift that needs to be +# reproduced exactly in order for analysis outputs to make any sense. The data +# is used in other scripts in this directory, this script is intended for +# imports only. +# Additionally, we add some setup work: +# - check if a file "task_labels_task_types.txt" exists. If it does, verify that +# the hardcoded data in this file corresponds to the output written by SWIFT +# in that file. +# - set up a list of useful task type/subtype combinations. Note that this list +# needs to be verified manually for completeness. +# - assing colours to all task types, subtypes, and combinations thereof. +# ----------------------------------------------------------------------------- # Tasks and subtypes. Indexed as in tasks.h. TASKTYPES = [ @@ -74,6 +80,7 @@ TASKTYPES = [ "fof_attach_pair", "neutrino_weight", "sink_in", + "sink_density_ghost", "sink_ghost1", "sink_ghost2", "sink_out", @@ -84,6 +91,9 @@ TASKTYPES = [ "rt_ghost2", "rt_transport_out", "rt_tchem", + "rt_advance_cell_time", + "rt_sort", + "rt_collect_times", # "count", ] @@ -124,6 +134,170 @@ SUBTYPES = [ # "count", ] +# Task/subtypes of interest. +FULLTYPES = [ + "self/limiter", + "self/force", + "self/gradient", + "self/density", + "self/grav", + "sub_self/limiter", + "sub_self/force", + "sub_self/gradient", + "sub_self/density", + "pair/limiter", + "pair/force", + "pair/gradient", + "pair/density", + "pair/grav", + "sub_pair/limiter", + "sub_pair/force", + "sub_pair/gradient", + "sub_pair/density", + "recv/xv", + "send/xv", + "recv/rho", + "send/rho", + "recv/tend_part", + "send/tend_part", + "recv/tend_gpart", + "send/tend_gpart", + "recv/tend_spart", + "send/tend_spart", + "recv/tend_bpart", + "send/tend_bpart", + "recv/gpart", + "send/gpart", + "recv/spart", + "send/spart", + "send/sf_counts", + "recv/sf_counts", + "recv/bpart", + "send/bpart", + "recv/limiter", + "send/limiter", + "pack/limiter", + "unpack/limiter", + "self/stars_density", + "pair/stars_density", + "sub_self/stars_density", + "sub_pair/stars_density", + "self/stars_prep1", + "pair/stars_prep1", + "sub_self/stars_prep1", + "sub_pair/stars_prep1", + "self/stars_prep2", + "pair/stars_prep2", + "sub_self/stars_prep2", + "sub_pair/stars_prep2", + "self/stars_feedback", + "pair/stars_feedback", + "sub_self/stars_feedback", + "sub_pair/stars_feedback", + "self/bh_density", + "pair/bh_density", + "sub_self/bh_density", + "sub_pair/bh_density", + "self/bh_swallow", + "pair/bh_swallow", + "sub_self/bh_swallow", + "sub_pair/bh_swallow", + "self/do_swallow", + "pair/do_swallow", + "sub_self/do_swallow", + "sub_pair/do_swallow", + "self/bh_feedback", + "pair/bh_feedback", + "sub_self/bh_feedback", + "sub_pair/bh_feedback", + "self/rt_gradient", + "pair/rt_gradient", + "sub_self/rt_gradient", + "sub_pair/rt_gradient", + "self/rt_transport", + "pair/rt_transport", + "sub_self/rt_transport", + "sub_pair/rt_transport", + "self/sink_density", + "pair/sink_density", + "sub_self/sink_density", + "sub_pair/sink_density", + "self/sink_swallow", + "pair/sink_swallow", + "sub_self/sink_swallow", + "sub_pair/sink_swallow", + "self/sink_do_swallow", + "pair/sink_do_swallow", + "sub_self/sink_do_swallow", + "sub_pair/sink_do_swallow", + "self/sink_do_gas_swallow", + "pair/sink_do_gas_swallow", + "sub_self/sink_do_gas_swallow", + "sub_pair/sink_do_gas_swallow", +] + +# A number of colours for the various types. Recycled when there are +# more task types than colours... +colours = [ + "cyan", + "lightgray", + "darkblue", + "yellow", + "tan", + "dodgerblue", + "sienna", + "aquamarine", + "bisque", + "blue", + "green", + "lightgreen", + "brown", + "purple", + "moccasin", + "olivedrab", + "chartreuse", + "olive", + "darkgreen", + "green", + "mediumseagreen", + "mediumaquamarine", + "darkslategrey", + "mediumturquoise", + "black", + "cadetblue", + "skyblue", + "red", + "slategray", + "gold", + "slateblue", + "blueviolet", + "mediumorchid", + "firebrick", + "magenta", + "hotpink", + "pink", + "orange", + "lightgreen", +] +maxcolours = len(colours) + +# Set colours of task/subtype. +TASKCOLOURS = {} +ncolours = 0 +for task in TASKTYPES: + TASKCOLOURS[task] = colours[ncolours] + ncolours = (ncolours + 1) % maxcolours + +SUBCOLOURS = {} +for task in FULLTYPES: + SUBCOLOURS[task] = colours[ncolours] + ncolours = (ncolours + 1) % maxcolours + +for task in SUBTYPES: + SUBCOLOURS[task] = colours[ncolours] + ncolours = (ncolours + 1) % maxcolours + + # check if label files are found that have (possibly different) labels # output by SWIFT itself import os