Commit 71d80338 authored by Loic Hausammann's avatar Loic Hausammann Committed by Matthieu Schaller
Browse files

Update cell graph

parent 20142737
......@@ -71,6 +71,8 @@ Parameters:
from all ranks.
-y, --task-dumps=<int> Time-step frequency at which task analysis
files and/or tasks are dumped.
--cell-dumps=<int> Time-step frequency at which cell graphs
are dumped.
-Y, --threadpool-dumps=<int> Time-step frequency at which threadpool
tasks are dumped.
......
......@@ -122,6 +122,8 @@ Parameters:
from all ranks.
-y, --task-dumps=<int> Time-step frequency at which task analysis
files and/or tasks are dumped.
--cell-dumps=<int> Time-step frequency at which cell graphs
are dumped.
-Y, --threadpool-dumps=<int> Time-step frequency at which threadpool
tasks are dumped.
......
......@@ -21,11 +21,13 @@ 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)
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
......@@ -34,6 +36,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
--------------------
......
......@@ -65,5 +65,7 @@ can be found by typing ``./swift -h``::
from all ranks.
-y, --task-dumps=<int> Time-step frequency at which task analysis
files and/or tasks are dumped.
--cell-dumps=<int> Time-step frequency at which cell graphs
are dumped.
-Y, --threadpool-dumps=<int> Time-step frequency at which threadpool
tasks are dumped.
......@@ -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
{
......
......@@ -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 */
......
......@@ -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.");
......
......@@ -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 */
......@@ -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
......
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