Commit 5d91cae2 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Started moving towards 50 time bins. Time-step of size 0 is assigned.

parent 70b8fb72
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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. */
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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
*
......
......@@ -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;
}
......
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