diff --git a/src/active.h b/src/active.h index 2c9e1c8aa10d8ce88ce5238fc98a10b7e12418fb..edb276c5e9d7f420e8bcaa9cb9d15dae0ad4a880 100644 --- a/src/active.h +++ b/src/active.h @@ -41,8 +41,8 @@ __attribute__((always_inline)) INLINE static int cell_is_drifted( #ifdef SWIFT_DEBUG_CHECKS if (c->ti_old > e->ti_current) error( - "Cell has been drifted too far forward in time! c->ti_old=%d " - "e->ti_current=%d", + "Cell has been drifted too far forward in time! c->ti_old=%lld " + "e->ti_current=%lld", c->ti_old, e->ti_current); #endif @@ -61,8 +61,10 @@ __attribute__((always_inline)) INLINE static int cell_is_active( #ifdef SWIFT_DEBUG_CHECKS if (c->ti_end_min < e->ti_current) - error("cell in an impossible time-zone! c->ti_end_min=%d e->ti_current=%d", - c->ti_end_min, e->ti_current); + error( + "cell in an impossible time-zone! c->ti_end_min=%lld " + "e->ti_current=%lld", + c->ti_end_min, e->ti_current); #endif return (c->ti_end_min == e->ti_current); @@ -80,8 +82,10 @@ __attribute__((always_inline)) INLINE static int cell_is_all_active( #ifdef SWIFT_DEBUG_CHECKS if (c->ti_end_max < e->ti_current) - error("cell in an impossible time-zone! c->ti_end_max=%d e->ti_current=%d", - c->ti_end_max, e->ti_current); + error( + "cell in an impossible time-zone! c->ti_end_max=%lld " + "e->ti_current=%lld", + c->ti_end_max, e->ti_current); #endif return (c->ti_end_max == e->ti_current); diff --git a/src/cell.c b/src/cell.c index c7b992bb72f5431c267c19fad6355d31c663b20b..1d580b929b6c42b1d8bc4e264d48941ce83f9ea1 100644 --- a/src/cell.c +++ b/src/cell.c @@ -715,10 +715,10 @@ void cell_clean_links(struct cell *c, void *data) { */ void cell_check_drift_point(struct cell *c, void *data) { - const int ti_current = *(int *)data; + integertime_t ti_current = *(int *)data; if (c->ti_old != ti_current && c->nodeID == engine_rank) - error("Cell in an incorrect time-zone! c->ti_old=%d ti_current=%d", + error("Cell in an incorrect time-zone! c->ti_old=%lld ti_current=%lld", c->ti_old, ti_current); } @@ -1007,8 +1007,8 @@ void cell_set_super(struct cell *c, struct cell *super) { void cell_drift(struct cell *c, const struct engine *e) { const double timeBase = e->timeBase; - const int ti_old = c->ti_old; - const int ti_current = e->ti_current; + const integertime_t ti_old = c->ti_old; + const integertime_t ti_current = e->ti_current; struct part *const parts = c->parts; struct xpart *const xparts = c->xparts; struct gpart *const gparts = c->gparts; diff --git a/src/cell.h b/src/cell.h index 3772cfe929a52601f407614f7f94929126f27514..563a0af3f42d34f551ece9ef338f492705e16d67 100644 --- a/src/cell.h +++ b/src/cell.h @@ -67,7 +67,7 @@ struct pcell { /* Stats on this cell's particles. */ double h_max; - int ti_end_min, ti_end_max, ti_old; + integertime_t ti_end_min, ti_end_max, ti_old; /* Number of particles in this cell. */ int count, gcount; @@ -206,13 +206,13 @@ struct cell { #endif /*! Minimum end of (integer) time step in this cell. */ - int ti_end_min; + integertime_t ti_end_min; /*! Maximum end of (integer) time step in this cell. */ - int ti_end_max; + integertime_t ti_end_max; /*! Last (integer) time the cell's content was drifted forward in time. */ - int ti_old; + integertime_t ti_old; /*! Minimum dimension, i.e. smallest edge of this cell (min(width)). */ float dmin; diff --git a/src/engine.c b/src/engine.c index 4538452521ddb28afa398108378a81bbc35e09bb..fd641996fff30b0adc2392b8d45277ef340998e2 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1998,7 +1998,7 @@ void engine_marktasks_mapper(void *map_data, int num_elements, void *extra_data) { /* Unpack the arguments. */ struct task *tasks = (struct task *)map_data; - const int ti_end = ((size_t *)extra_data)[0]; + const integertime_t ti_end = ((size_t *)extra_data)[0]; size_t *rebuild_space = &((size_t *)extra_data)[1]; struct scheduler *s = (struct scheduler *)(((size_t *)extra_data)[2]); @@ -2357,7 +2357,7 @@ void engine_collect_kick(struct cell *c) { /* Counters for the different quantities. */ int updated = 0, g_updated = 0; - int ti_end_min = max_nr_timesteps; + integertime_t ti_end_min = max_nr_timesteps; /* Only do something is the cell is non-empty */ if (c->count != 0 || c->gcount != 0) { @@ -2401,7 +2401,7 @@ void engine_collect_timestep(struct engine *e) { const ticks tic = getticks(); int updates = 0, g_updates = 0; - int ti_end_min = max_nr_timesteps; + integertime_t ti_end_min = max_nr_timesteps; const struct space *s = e->s; /* Collect the cell data. */ diff --git a/src/engine.h b/src/engine.h index a363d7d5bf8ac2194506ccdc2e3541594b04aa01..72d54f6d263eef9cc2f7d63a3b2aeddcf8b3c2e5 100644 --- a/src/engine.h +++ b/src/engine.h @@ -114,11 +114,11 @@ struct engine { /* The previous system time. */ double timeOld; - int ti_old; + integertime_t ti_old; /* The current system time. */ double time; - int ti_current; + integertime_t ti_current; /* Time step */ double timeStep; @@ -128,7 +128,7 @@ struct engine { double timeBase_inv; /* Minimal ti_end for the next time-step */ - int ti_end_min; + integertime_t ti_end_min; /* Number of particles updated */ size_t updates, g_updates; @@ -139,7 +139,7 @@ struct engine { /* Snapshot information */ double timeFirstSnapshot; double deltaTimeSnapshot; - int ti_nextSnapshot; + integertime_t ti_nextSnapshot; char snapshotBaseName[200]; int snapshotCompression; struct UnitSystem *snapshotUnits; diff --git a/src/hydro/Gadget2/hydro.h b/src/hydro/Gadget2/hydro.h index e80ea9f0c061e90becb3beb8a7db4d7a8f7a3db9..ace32c1904f65739c00af88ac36ca0858ba52d46 100644 --- a/src/hydro/Gadget2/hydro.h +++ b/src/hydro/Gadget2/hydro.h @@ -365,8 +365,8 @@ __attribute__((always_inline)) INLINE static void hydro_reset_acceleration( * @param timeBase The minimal time-step size */ __attribute__((always_inline)) INLINE static void hydro_predict_extra( - struct part *restrict p, const struct xpart *restrict xp, float dt, int t0, - int t1, double timeBase) { + struct part *restrict p, const struct xpart *restrict xp, float dt, + integertime_t t0, integertime_t t1, double timeBase) { const float h_inv = 1.f / p->h; diff --git a/src/kick.h b/src/kick.h index c2515e4f4d9a28ad3723e911f4eb6cf5a25b7294..fe30a367ff54f247be8f54dc299cb4dcd6b8face 100644 --- a/src/kick.h +++ b/src/kick.h @@ -44,8 +44,8 @@ __attribute__((always_inline)) INLINE static void kick_gpart( get_integer_time_begin(ti_current, gp->time_bin); const integertime_t old_ti_end = get_integer_time_end(ti_current, gp->time_bin); - const int ti_start = (old_ti_begin + old_ti_end) / 2; - const int ti_end = old_ti_end + new_dti / 2; + const integertime_t ti_start = (old_ti_begin + old_ti_end) / 2; + const integertime_t ti_end = old_ti_end + new_dti / 2; const float dt = (ti_end - ti_start) * timeBase; const float half_dt = (ti_end - old_ti_end) * timeBase; @@ -73,7 +73,7 @@ __attribute__((always_inline)) INLINE static void kick_gpart( * @param timeBase The minimal allowed time-step size. */ __attribute__((always_inline)) INLINE static void kick_part( - struct part *restrict p, struct xpart *restrict xp, int new_dti, + struct part *restrict p, struct xpart *restrict xp, integertime_t new_dti, integertime_t ti_current, double timeBase) { /* Compute the time step for this kick */ @@ -81,8 +81,8 @@ __attribute__((always_inline)) INLINE static void kick_part( get_integer_time_begin(ti_current, p->time_bin); const integertime_t old_ti_end = get_integer_time_end(ti_current, p->time_bin); - const int ti_start = (old_ti_begin + old_ti_end) / 2; - const int ti_end = old_ti_end + new_dti / 2; + const integertime_t ti_start = (old_ti_begin + old_ti_end) / 2; + const integertime_t ti_end = old_ti_end + new_dti / 2; const float dt = (ti_end - ti_start) * timeBase; const float half_dt = (ti_end - old_ti_end) * timeBase; diff --git a/src/runner.c b/src/runner.c index 2311e0d730bd41f2a6b3f59de9bbc3fcbfaff1e1..13705452de9fe8f74c71db9c4fb68d57a9374386 100644 --- a/src/runner.c +++ b/src/runner.c @@ -114,7 +114,7 @@ const char runner_flip[27] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, #include "runner_doiact_grav.h" #undef ICHECK -#define ICHECK -116650 +#define ICHECK 116650 /** * @brief Perform source terms @@ -594,7 +594,7 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) { struct xpart *restrict xparts = c->xparts; int redo, count = c->count; const struct engine *e = r->e; - const int ti_current = e->ti_current; + const integertime_t ti_current = e->ti_current; const double timeBase = e->timeBase; const float target_wcount = e->hydro_properties->target_neighbours; const float max_wcount = @@ -837,7 +837,7 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { const struct engine *e = r->e; const double timeBase = e->timeBase; - const int ti_current = e->ti_current; + const integertime_t ti_current = e->ti_current; const int count = c->count; const int gcount = c->gcount; struct part *restrict parts = c->parts; @@ -855,7 +855,7 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { } int updated = 0, g_updated = 0; - int ti_end_min = max_nr_timesteps, ti_end_max = 0; + integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0; /* No children? */ if (!c->split) { @@ -887,8 +887,8 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { /* Minimal time for next end of time-step */ const integertime_t ti_end = get_integer_time_end(ti_current, gp->time_bin); - ti_end_min = min((int)ti_end, ti_end_min); - ti_end_max = max((int)ti_end, ti_end_max); + ti_end_min = min(ti_end, ti_end_min); + ti_end_max = max(ti_end, ti_end_max); } } @@ -905,7 +905,7 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { integertime_t ti_end = get_integer_time_end(ti_current, p->time_bin); if (p->id == ICHECK) - message("Particle in kick ti_end=%lld ti_current=%d", ti_end, + message("Particle in kick ti_end=%lld ti_current=%lld", ti_end, e->ti_current); /* If particle needs to be kicked */ @@ -918,10 +918,10 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { if (p->gpart != NULL) gravity_end_force(p->gpart, const_G); /* Compute the next timestep (hydro condition) */ - const int new_dti = get_part_timestep(p, xp, e); + const integertime_t new_dti = get_part_timestep(p, xp, e); if (p->id == ICHECK) - message("time_step=%d (%e)", new_dti, new_dti * e->timeBase); + message("time_step=%lld (%e)", new_dti, new_dti * e->timeBase); /* Now we have a time step, proceed with the kick */ kick_part(p, xp, new_dti, e->ti_current, timeBase); @@ -936,11 +936,11 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { } if (p->id == ICHECK) - message("ti_current = %d dti=%lld ti_end=%lld (%f)", ti_current, + message("ti_current = %lld dti=%lld ti_end=%lld (%f)", ti_current, get_integer_timestep(p->time_bin), ti_end, ti_end * e->timeBase); - ti_end_min = min((int)ti_end, ti_end_min); - ti_end_max = max((int)ti_end, ti_end_max); + ti_end_min = min(ti_end, ti_end_min); + ti_end_max = max(ti_end, ti_end_max); } } @@ -972,6 +972,8 @@ void runner_do_kick(struct runner *r, struct cell *c, int timer) { if (timer) TIMER_TOC(timer_kick); } +#ifdef WITH_MPI + /** * @brief Construct the cell properties from the received particles * @@ -989,8 +991,8 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { TIMER_TIC; - int ti_end_min = max_nr_timesteps; - int ti_end_max = 0; + integertime_t ti_end_min = max_nr_timesteps; + integertime_t ti_end_max = 0; float h_max = 0.f; /* If this cell is a leaf, collect the particle data. */ @@ -998,14 +1000,14 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { /* Collect everything... */ for (size_t k = 0; k < nr_parts; k++) { - const int ti_end = 0; // parts[k].ti_end; //MATTHIEU + const integertime_t ti_end = 0; // parts[k].ti_end; //MATTHIEU // if(ti_end < ti_current) error("Received invalid particle !"); ti_end_min = min(ti_end_min, ti_end); ti_end_max = max(ti_end_max, ti_end); h_max = max(h_max, parts[k].h); } for (size_t k = 0; k < nr_gparts; k++) { - const int ti_end = 0; // gparts[k].ti_end; //MATTHIEU + const integertime_t ti_end = 0; // gparts[k].ti_end; //MATTHIEU // if(ti_end < ti_current) error("Received invalid particle !"); ti_end_min = min(ti_end_min, ti_end); ti_end_max = max(ti_end_max, ti_end); @@ -1034,6 +1036,8 @@ void runner_do_recv_cell(struct runner *r, struct cell *c, int timer) { if (timer) TIMER_TOC(timer_dorecv_cell); } +#endif /* WITH_MPI */ + /** * @brief The #runner main thread routine. * @@ -1084,8 +1088,8 @@ void *runner_main(void *data) { if (!cell_is_active(ci, e) && t->type != task_type_sort && t->type != task_type_send && t->type != task_type_recv) error( - "Task (type='%s/%s') should have been skipped ti_current=%d " - "c->ti_end_min=%d", + "Task (type='%s/%s') should have been skipped ti_current=%lld " + "c->ti_end_min=%lld", taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, ci->ti_end_min); @@ -1093,8 +1097,8 @@ void *runner_main(void *data) { if (!cell_is_active(ci, e) && t->type == task_type_sort && t->flags == 0) error( - "Task (type='%s/%s') should have been skipped ti_current=%d " - "c->ti_end_min=%d t->flags=%d", + "Task (type='%s/%s') should have been skipped ti_current=%lld " + "c->ti_end_min=%lld t->flags=%d", taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, ci->ti_end_min, t->flags); @@ -1103,8 +1107,8 @@ void *runner_main(void *data) { if (t->type != task_type_send && t->type != task_type_recv) error( - "Task (type='%s/%s') should have been skipped ti_current=%d " - "ci->ti_end_min=%d cj->ti_end_min=%d", + "Task (type='%s/%s') should have been skipped ti_current=%lld " + "ci->ti_end_min=%lld cj->ti_end_min=%lld", taskID_names[t->type], subtaskID_names[t->subtype], e->ti_current, ci->ti_end_min, cj->ti_end_min); } diff --git a/src/scheduler.c b/src/scheduler.c index a96a5923d7e65f9536953b06ba0ccb4ce8b814b6..aca611710a89ab7386d1cd096183bfb090e558c4 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -1056,7 +1056,7 @@ void scheduler_start(struct scheduler *s) { /* Check we have not missed an active task */ #ifdef SWIFT_DEBUG_CHECKS - const int ti_current = s->space->e->ti_current; + const integertime_t ti_current = s->space->e->ti_current; if (ti_current > 0) { @@ -1071,8 +1071,9 @@ void scheduler_start(struct scheduler *s) { if (ci->ti_end_min == ti_current && t->skip && t->type != task_type_sort && t->type) error( - "Task (type='%s/%s') should not have been skipped ti_current=%d " - "c->ti_end_min=%d", + "Task (type='%s/%s') should not have been skipped " + "ti_current=%lld " + "c->ti_end_min=%lld", taskID_names[t->type], subtaskID_names[t->subtype], ti_current, ci->ti_end_min); @@ -1080,8 +1081,9 @@ void scheduler_start(struct scheduler *s) { if (ci->ti_end_min == ti_current && t->skip && t->type == task_type_sort && t->flags == 0) error( - "Task (type='%s/%s') should not have been skipped ti_current=%d " - "c->ti_end_min=%d t->flags=%d", + "Task (type='%s/%s') should not have been skipped " + "ti_current=%lld " + "c->ti_end_min=%lld t->flags=%d", taskID_names[t->type], subtaskID_names[t->subtype], ti_current, ci->ti_end_min, t->flags); @@ -1090,8 +1092,9 @@ void scheduler_start(struct scheduler *s) { if ((ci->ti_end_min == ti_current || cj->ti_end_min == ti_current) && t->skip) error( - "Task (type='%s/%s') should not have been skipped ti_current=%d " - "ci->ti_end_min=%d cj->ti_end_min=%d", + "Task (type='%s/%s') should not have been skipped " + "ti_current=%lld " + "ci->ti_end_min=%lld cj->ti_end_min=%lld", taskID_names[t->type], subtaskID_names[t->subtype], ti_current, ci->ti_end_min, cj->ti_end_min); } diff --git a/src/space.c b/src/space.c index 0801eeb85becf9610dd424a2149039c158c20f72..58c628c725652556660de1192a7b701044f3d795 100644 --- a/src/space.c +++ b/src/space.c @@ -1477,7 +1477,7 @@ void space_split_recursive(struct space *s, struct cell *c, int *buff) { const int depth = c->depth; int maxdepth = 0; float h_max = 0.0f; - int ti_end_min = max_nr_timesteps, ti_end_max = 0; + integertime_t ti_end_min = max_nr_timesteps, ti_end_max = 0; struct cell *temp; struct part *parts = c->parts; struct gpart *gparts = c->gparts; @@ -1565,7 +1565,8 @@ void space_split_recursive(struct space *s, struct cell *c, int *buff) { struct part *p = &parts[k]; struct xpart *xp = &xparts[k]; const float h = p->h; - const int ti_end = get_integer_time_end(e->ti_current, p->time_bin); + const integertime_t ti_end = + get_integer_time_end(e->ti_current, p->time_bin); xp->x_diff[0] = 0.f; xp->x_diff[1] = 0.f; xp->x_diff[2] = 0.f; @@ -1575,7 +1576,8 @@ void space_split_recursive(struct space *s, struct cell *c, int *buff) { } for (int k = 0; k < gcount; k++) { struct gpart *gp = &gparts[k]; - const int ti_end = get_integer_time_end(e->ti_current, gp->time_bin); + const integertime_t ti_end = + get_integer_time_end(e->ti_current, gp->time_bin); gp->x_diff[0] = 0.f; gp->x_diff[1] = 0.f; gp->x_diff[2] = 0.f; diff --git a/src/timeline.h b/src/timeline.h index 23d2e55e3c0cf59b309922b8525c4e1180b9b380..3ee8a137908fbf23f480efeba1b42a3ad812489b 100644 --- a/src/timeline.h +++ b/src/timeline.h @@ -32,13 +32,11 @@ typedef unsigned long long integertime_t; typedef char timebin_t; /*! The number of time bins */ -#define num_time_bins 20 +#define num_time_bins 50 /*! The maximal number of timesteps in a simulation */ #define max_nr_timesteps (1LL << (num_time_bins + 1)) -//#define ceil_div(x ,y) (x + y - 1) / y - /** * @brief Returns the integer time interval corresponding to a time bin * diff --git a/src/timestep.h b/src/timestep.h index 1ac934d3a385a21c04984b5fd0cbfcb722788c3e..d9778439a978ff8b05477683c6139653184e540f 100644 --- a/src/timestep.h +++ b/src/timestep.h @@ -85,8 +85,8 @@ __attribute__((always_inline)) INLINE static int get_gpart_timestep( new_dt = max(new_dt, e->dt_min); /* Convert to integer time */ - const int new_dti = make_integer_timestep(new_dt, gp->time_bin, e->ti_current, - e->timeBase_inv); + const integertime_t new_dti = make_integer_timestep( + new_dt, gp->time_bin, e->ti_current, e->timeBase_inv); return new_dti; } @@ -141,8 +141,8 @@ __attribute__((always_inline)) INLINE static int get_part_timestep( new_dt = max(new_dt, e->dt_min); /* Convert to integer time */ - const int new_dti = make_integer_timestep(new_dt, p->time_bin, e->ti_current, - e->timeBase_inv); + const integertime_t new_dti = make_integer_timestep( + new_dt, p->time_bin, e->ti_current, e->timeBase_inv); return new_dti; }