Commit de21792d authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Dump the cell time-steps. Always activate all communication pairs.

parent c9338e42
......@@ -6,6 +6,10 @@ InternalUnitSystem:
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
Scheduler:
max_top_level_cells: 8
tasks_per_cell: 50
# Parameters governing the time integration
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
......
......@@ -2084,51 +2084,53 @@ int cell_unskip_tasks(struct cell *c, struct scheduler *s) {
/* Activate the send/recv tasks. */
if (ci->nodeID != engine_rank) {
/* If the local cell is active, receive data from the foreign cell. */
if (cj_active) {
/* /\* If the local cell is active, receive data from the foreign cell. *\/ */
/* if (cj_active) { */
scheduler_activate(s, ci->recv_grav);
}
/* } */
/* If the foreign cell is active, we want its ti_end values. */
if (ci_active) scheduler_activate(s, ci->recv_ti);
/* /\* If the foreign cell is active, we want its ti_end values. *\/ */
/* if (ci_active) */scheduler_activate(s, ci->recv_ti);
/* Is the foreign cell active and will need stuff from us? */
if (ci_active) {
/* /\* Is the foreign cell active and will need stuff from us? *\/ */
/* if (ci_active) { */
scheduler_activate_send(s, cj->send_grav, ci->nodeID);
/* Drift the cell which will be sent at the level at which it is
sent, i.e. drift the cell specified in the send task (l->t)
itself. */
/* /\* Drift the cell which will be sent at the level at which it is */
/* sent, i.e. drift the cell specified in the send task (l->t) */
/* itself. *\/ */
cell_activate_drift_gpart(cj, s);
}
/* } */
/* If the local cell is active, send its ti_end values. */
if (cj_active) scheduler_activate_send(s, cj->send_ti, ci->nodeID);
/* /\* If the local cell is active, send its ti_end values. *\/ */
/* if (cj_active) */scheduler_activate_send(s, cj->send_ti, ci->nodeID);
} else if (cj->nodeID != engine_rank) {
/* If the local cell is active, receive data from the foreign cell. */
if (ci_active) {
/* /\* If the local cell is active, receive data from the foreign cell. *\/ */
/* if (ci_active) { */
scheduler_activate(s, cj->recv_grav);
}
/* } */
/* If the foreign cell is active, we want its ti_end values. */
if (cj_active) scheduler_activate(s, cj->recv_ti);
/* /\* If the foreign cell is active, we want its ti_end values. *\/ */
/* if (cj_active) */
scheduler_activate(s, cj->recv_ti);
/* Is the foreign cell active and will need stuff from us? */
if (cj_active) {
/* /\* Is the foreign cell active and will need stuff from us? *\/ */
/* if (cj_active) { */
scheduler_activate_send(s, ci->send_grav, cj->nodeID);
/* Drift the cell which will be sent at the level at which it is
sent, i.e. drift the cell specified in the send task (l->t)
itself. */
/* /\* Drift the cell which will be sent at the level at which it is */
/* sent, i.e. drift the cell specified in the send task (l->t) */
/* itself. *\/ */
cell_activate_drift_gpart(ci, s);
}
/* } */
/* If the local cell is active, send its ti_end values. */
if (ci_active) scheduler_activate_send(s, ci->send_ti, cj->nodeID);
/* /\* If the local cell is active, send its ti_end values. *\/ */
/* if (ci_active) */
scheduler_activate_send(s, ci->send_ti, cj->nodeID);
}
#endif
}
......
......@@ -446,6 +446,8 @@ void engine_redistribute(struct engine *e) {
#ifdef WITH_MPI
message("\n REDISTRIBUTE!!! \n");
const int nr_nodes = e->nr_nodes;
const int nodeID = e->nodeID;
struct space *s = e->s;
......@@ -2885,7 +2887,7 @@ void engine_maketasks(struct engine *e) {
error("We have particles but no hydro or gravity tasks were created.");
/* Split the tasks. */
scheduler_splittasks(sched);
//scheduler_splittasks(sched);
/* Free the old list of cell-task links. */
if (e->links != NULL) free(e->links);
......@@ -3317,14 +3319,29 @@ void engine_print_task_counts(struct engine *e) {
const int nr_tasks = sched->nr_tasks;
const struct task *const tasks = sched->tasks;
int count_send_ti = 0;
int count_recv_ti = 0;
int count_send_gpart = 0;
int count_recv_gpart = 0;
/* Count and print the number of each task type. */
int counts[task_type_count + 1];
for (int k = 0; k <= task_type_count; k++) counts[k] = 0;
for (int k = 0; k < nr_tasks; k++) {
if (tasks[k].skip)
counts[task_type_count] += 1;
else
else {
counts[(int)tasks[k].type] += 1;
if(tasks[k].type == task_type_send && tasks[k].subtype == task_subtype_tend)
count_send_ti++;
if(tasks[k].type == task_type_recv && tasks[k].subtype == task_subtype_tend)
count_recv_ti++;
if(tasks[k].type == task_type_send && tasks[k].subtype == task_subtype_gpart)
count_send_gpart++;
if(tasks[k].type == task_type_recv && tasks[k].subtype == task_subtype_gpart)
count_recv_gpart++;
}
}
message("Total = %d (per cell = %d)", nr_tasks,
(int)ceil((double)nr_tasks / e->s->tot_cells));
......@@ -3339,10 +3356,12 @@ void engine_print_task_counts(struct engine *e) {
printf(" %s=%i", taskID_names[k], counts[k]);
printf(" skipped=%i ]\n", counts[task_type_count]);
fflush(stdout);
message("nr_parts = %zu.", e->s->nr_parts);
message("nr_gparts = %zu.", e->s->nr_gparts);
message("nr_sparts = %zu.", e->s->nr_sparts);
//message("nr_parts = %zu.", e->s->nr_parts);
//message("nr_gparts = %zu.", e->s->nr_gparts);
//message("nr_sparts = %zu.", e->s->nr_sparts);
message("send_ti=%d, recv_ti=%d, send_gpart=%d, recv_gpart=%d",
count_send_ti, count_recv_ti, count_send_gpart, count_recv_gpart);
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
clocks_getunit());
......@@ -4116,9 +4135,9 @@ void engine_step(struct engine *e) {
if (e->nodeID == 0) {
/* Print some information to the screen */
printf(" %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step, e->time,
e->timeStep, e->updates, e->g_updates, e->s_updates,
e->wallclock_time, e->step_props);
printf(" %6d %lld %14e %14e %12zu %12zu %12zu %21.3f %6d\n", e->step,
e->ti_current, e->time, e->timeStep, e->updates, e->g_updates,
e->s_updates, e->wallclock_time, e->step_props);
fflush(stdout);
fprintf(e->file_timesteps, " %6d %14e %14e %12zu %12zu %12zu %21.3f %6d\n",
......@@ -4137,6 +4156,10 @@ void engine_step(struct engine *e) {
e->timeStep = (e->ti_current - e->ti_old) * e->timeBase;
e->step_props = engine_step_prop_none;
space_print_cells(e->s);
//message("nr cells: %d %d", e->s->nr_cells, e->s->tot_cells);
message("ti_current=%lld ti_old=%lld", e->ti_current, e->ti_old);
/* Prepare the tasks to be launched, rebuild or repartition if needed. */
engine_prepare(e);
......
......@@ -538,6 +538,8 @@ void space_rebuild(struct space *s, int verbose) {
fflush(stdout);
#endif
message("\n REBUILD!!! \n");
/* Re-grid if necessary, or just re-set the cell data. */
space_regrid(s, verbose);
......@@ -3164,3 +3166,35 @@ void space_clean(struct space *s) {
free(s->gparts);
free(s->sparts);
}
void space_print_cells(const struct space *s) {
char filename[200];
sprintf(filename, "space_%d_%d.dat", s->e->step, engine_rank);
FILE *file = fopen(filename, "w");
fprintf(file, "ti_current=%lld\n", s->e->ti_current);
for (int k = 0; k < s->cdim[2]; ++k) {
fprintf(file, "\n -- k=%d -- \n\n", k);
for (int j = 0; j < s->cdim[1]; ++j) {
for (int i = 0; i < s->cdim[0]; ++i) {
#ifdef WITH_MPI
const int cid = cell_getid(s->cdim, i, j, k);
const struct cell *c = &s->cells_top[cid];
fprintf(file, "|(%d-%lld-%d-%d-%d)", c->nodeID, c->ti_end_min, c->gcount, (c->recv_grav!=NULL), (c->send_grav != NULL));
#endif
}
fprintf(file, "|\n");
}
}
fprintf(file, " -- --- --\n");
fclose(file);
}
......@@ -234,5 +234,6 @@ void space_replicate(struct space *s, int replicate, int verbose);
void space_reset_task_counters(struct space *s);
void space_clean(struct space *s);
void space_free_cells(struct space *s);
void space_print_cells(const struct space *s);
#endif /* SWIFT_SPACE_H */
......@@ -32,7 +32,7 @@ typedef long long integertime_t;
typedef char timebin_t;
/*! The number of time bins */
#define num_time_bins 56
#define num_time_bins 26
/*! The maximal number of timesteps in a simulation */
#define max_nr_timesteps (1LL << (num_time_bins + 1))
......
Markdown is supported
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