From e2bb99ff21815b3fa78e81cc1ef90850b525b987 Mon Sep 17 00:00:00 2001 From: loikki Date: Fri, 13 Sep 2019 13:43:29 +0200 Subject: [PATCH 1/5] Update cell graph --- doc/RTD/source/AnalysisTools/index.rst | 12 ++++++++++-- examples/main.c | 21 +++++++++++++++++++++ src/engine.c | 1 - src/space.c | 5 +++-- src/space.h | 2 +- tools/make_cell_hierarchy.sh | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/doc/RTD/source/AnalysisTools/index.rst b/doc/RTD/source/AnalysisTools/index.rst index f7f2f9796..b735c5558 100644 --- a/doc/RTD/source/AnalysisTools/index.rst +++ b/doc/RTD/source/AnalysisTools/index.rst @@ -21,8 +21,8 @@ Cell graph ---------- An interactive graph of the cells is available with the configuration option ``--enable-cell-graph``. -During a run, SWIFT will generate a ``cell_hierarchy_*.csv`` file per MPI rank. -The command ``tools/make_cell_hierarchy.sh cell_hierarchy_*.csv`` merges the files together and generates the file ``cell_hierarchy.html`` +During a run, SWIFT will generate a ``cell_hierarchy_*.csv`` file per MPI rank at the frequency given by the parameter ``--cell-dumps=n``. +The command ``tools/make_cell_hierarchy.sh cell_hierarchy_0000_*.csv`` merges the files at time step 0 together and generates the file ``cell_hierarchy.html`` that contains the graph and can be read with your favorite web browser. With chrome, you cannot access the files directly, you will need to either access them through an existing server (e.g. public http provided by your university) @@ -34,6 +34,14 @@ or install ``npm`` and then run the following commands http-server . Now you can open the web page ``http://localhost:8080/cell_hierarchy.html``. +When running a large simulation, the data loading may take a while (a few seconds for EAGLE_6). +Your browser should not be hanging, but will seems to be idle. + +If you wish to add some information to the graph, you can do it by modifying the files ``src/space.c`` and ``tools/data/cell_hierarchy.html``. +In the first one, you will need to modify the calls to ``fprintf`` in the functions ``space_write_cell_hierarchy`` and ``space_write_cell``. +Here the code is simply writing CSV files containing all the required information about the cells. +In the second one, you will need to find the function ``mouseover`` and add the field that you have created. +You can also increase the size of the bubble through the style parameter ``height``. Memory usage reports -------------------- diff --git a/examples/main.c b/examples/main.c index 27af0897a..bef1b4314 100644 --- a/examples/main.c +++ b/examples/main.c @@ -148,6 +148,7 @@ int main(int argc, char *argv[]) { int with_aff = 0; int dry_run = 0; int dump_tasks = 0; + int dump_cells = 0; int dump_threadpool = 0; int nsteps = -2; int restart = 0; @@ -263,6 +264,9 @@ int main(int argc, char *argv[]) { OPT_INTEGER('y', "task-dumps", &dump_tasks, "Time-step frequency at which task graphs are dumped.", NULL, 0, 0), + OPT_INTEGER(0, "cell-dumps", &dump_cells, + "Time-step frequency at which cell graphs are dumped.", NULL, + 0, 0), OPT_INTEGER('Y', "threadpool-dumps", &dump_threadpool, "Time-step frequency at which threadpool tasks are dumped.", NULL, 0, 0), @@ -323,6 +327,16 @@ int main(int argc, char *argv[]) { } #endif +#ifndef SWIFT_CELL_GRAPH + if (dump_cells) { + if (myrank == 0) { + error( + "complete cell dumps are only created when " + "configured with --enable-cell-graph."); + } + } +#endif + #ifndef SWIFT_DEBUG_THREADPOOL if (dump_threadpool) { printf( @@ -1261,6 +1275,13 @@ int main(int argc, char *argv[]) { task_dump_stats(dumpfile, &e, /* header = */ 0, /* allranks = */ 1); } +#ifdef SWIFT_CELL_GRAPH + /* Dump the cell data using the given frequency. */ + if (dump_cells && (dump_cells == 1 || j % dump_cells == 1)) { + space_write_cell_hierarchy(e.s, j + 1); + } +#endif + /* Dump memory use report if collected. */ #ifdef SWIFT_MEMUSE_REPORTS { diff --git a/src/engine.c b/src/engine.c index 462f38ba4..35b203f3e 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3557,7 +3557,6 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, #endif scheduler_write_dependencies(&e->sched, e->verbose); - space_write_cell_hierarchy(e->s); if (e->nodeID == 0) scheduler_write_task_level(&e->sched); /* Run the 0th time-step */ diff --git a/src/space.c b/src/space.c index a417117f6..eb498035d 100644 --- a/src/space.c +++ b/src/space.c @@ -5670,14 +5670,15 @@ void space_write_cell(const struct space *s, FILE *f, const struct cell *c) { * @brief Write a csv file containing the cell hierarchy * * @param s The #space. + * @param j The file number. */ -void space_write_cell_hierarchy(const struct space *s) { +void space_write_cell_hierarchy(const struct space *s, int j) { #ifdef SWIFT_CELL_GRAPH /* Open file */ char filename[200]; - sprintf(filename, "cell_hierarchy_%04i.csv", engine_rank); + sprintf(filename, "cell_hierarchy_%04i_%04i.csv", j, engine_rank); FILE *f = fopen(filename, "w"); if (f == NULL) error("Error opening task level file."); diff --git a/src/space.h b/src/space.h index 0b3327166..ad20641e4 100644 --- a/src/space.h +++ b/src/space.h @@ -374,6 +374,6 @@ void space_free_foreign_parts(struct space *s); void space_struct_dump(struct space *s, FILE *stream); void space_struct_restore(struct space *s, FILE *stream); -void space_write_cell_hierarchy(const struct space *s); +void space_write_cell_hierarchy(const struct space *s, int j); #endif /* SWIFT_SPACE_H */ diff --git a/tools/make_cell_hierarchy.sh b/tools/make_cell_hierarchy.sh index 87fbe4c97..9d1d3caf7 100644 --- a/tools/make_cell_hierarchy.sh +++ b/tools/make_cell_hierarchy.sh @@ -9,7 +9,7 @@ then rm $csv_output fi -for filename in ./cell_hierarchy_*.csv; +for filename in $@; do cat $filename >> cell_hierarchy.csv done -- GitLab From a7e6ad6a57c03db6cfb13e4e5232915fb24d9064 Mon Sep 17 00:00:00 2001 From: loikki Date: Fri, 13 Sep 2019 15:08:46 +0200 Subject: [PATCH 2/5] Update doc with new argument --- README | 2 ++ doc/RTD/source/CommandLineOptions/index.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README b/README index ee7abd5a5..8d722a66d 100644 --- a/README +++ b/README @@ -71,6 +71,8 @@ Parameters: from all ranks. -y, --task-dumps= Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps= Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps= Time-step frequency at which threadpool tasks are dumped. diff --git a/doc/RTD/source/CommandLineOptions/index.rst b/doc/RTD/source/CommandLineOptions/index.rst index 114447754..621209351 100644 --- a/doc/RTD/source/CommandLineOptions/index.rst +++ b/doc/RTD/source/CommandLineOptions/index.rst @@ -65,5 +65,7 @@ can be found by typing ``./swift -h``:: from all ranks. -y, --task-dumps= Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps= Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps= Time-step frequency at which threadpool tasks are dumped. -- GitLab From 84f139fedd1708bdd07fa08358975678fd312c10 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Fri, 13 Sep 2019 17:03:57 +0200 Subject: [PATCH 3/5] Applied code formatting tool --- examples/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/main.c b/examples/main.c index bef1b4314..1d7aa8777 100644 --- a/examples/main.c +++ b/examples/main.c @@ -331,8 +331,8 @@ int main(int argc, char *argv[]) { if (dump_cells) { if (myrank == 0) { error( - "complete cell dumps are only created when " - "configured with --enable-cell-graph."); + "complete cell dumps are only created when " + "configured with --enable-cell-graph."); } } #endif -- GitLab From d2592e2f0f9a555d4ab6ed456fec8aacb07ebe74 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller Date: Fri, 13 Sep 2019 17:12:26 +0200 Subject: [PATCH 4/5] Update all READMEs. Make the script runnable. --- README.md | 2 ++ tools/make_cell_hierarchy.sh | 0 2 files changed, 2 insertions(+) mode change 100644 => 100755 tools/make_cell_hierarchy.sh diff --git a/README.md b/README.md index efffc9b4c..f91b03d3f 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ Parameters: from all ranks. -y, --task-dumps= Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps= Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps= Time-step frequency at which threadpool tasks are dumped. diff --git a/tools/make_cell_hierarchy.sh b/tools/make_cell_hierarchy.sh old mode 100644 new mode 100755 -- GitLab From c84318c0b6283c952e69e64a7f669d7fb2a86b21 Mon Sep 17 00:00:00 2001 From: loikki Date: Fri, 13 Sep 2019 17:32:14 +0200 Subject: [PATCH 5/5] Remove mention to chrome --- doc/RTD/source/AnalysisTools/index.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/RTD/source/AnalysisTools/index.rst b/doc/RTD/source/AnalysisTools/index.rst index b735c5558..8b4467f5f 100644 --- a/doc/RTD/source/AnalysisTools/index.rst +++ b/doc/RTD/source/AnalysisTools/index.rst @@ -25,7 +25,9 @@ During a run, SWIFT will generate a ``cell_hierarchy_*.csv`` file per MPI rank a The command ``tools/make_cell_hierarchy.sh cell_hierarchy_0000_*.csv`` merges the files at time step 0 together and generates the file ``cell_hierarchy.html`` that contains the graph and can be read with your favorite web browser. -With chrome, you cannot access the files directly, you will need to either access them through an existing server (e.g. public http provided by your university) +With most web browsers, you cannot access the files directly. +If it is the case, the cells will never appear (but everything else should be fine). +To solve this problem, you will need to either access them through an existing server (e.g. public http provided by your university) or install ``npm`` and then run the following commands .. code-block:: bash -- GitLab