Commit 25ec3ee3 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'no_fixdt' into 'master'

Remove the fixdt policy. fixdt can be achieved by setting dt_min and dt_max to the same value.



See merge request !277
parents 1c74eedc c203a4db
......@@ -22,8 +22,6 @@ doc/Doxyfile
examples/swift
examples/swift_mpi
examples/swift_fixdt
examples/swift_fixdt_mpi
examples/*.xmf
examples/used_parameters.yml
examples/energy.txt
......
......@@ -13,8 +13,6 @@ See INSTALL.swift for install instructions.
Usage: swift [OPTION]... PARAMFILE
swift_mpi [OPTION]... PARAMFILE
swift_fixdt [OPTION]... PARAMFILE
swift_fixdt_mpi [OPTION]... PARAMFILE
Valid options are:
-a Pin runners using processor affinity
......
......@@ -5,7 +5,7 @@ echo "Generating initial conditions for the cooling box example..."
python makeIC.py 10
../swift_fixdt -s -C -t 16 coolingBox.yml
../swift -s -C -t 16 coolingBox.yml
#-C 2>&1 | tee output.log
......
......@@ -30,13 +30,12 @@ EXTRA_LIBS = $(HDF5_LIBS) $(FFTW_LIBS) $(PROFILER_LIBS) $(TCMALLOC_LIBS)
MPI_LIBS = $(METIS_LIBS) $(MPI_THREAD_LIBS)
MPI_FLAGS = -DWITH_MPI $(METIS_INCS)
# Programs.
bin_PROGRAMS = swift swift_fixdt
bin_PROGRAMS = swift
# Build MPI versions as well?
if HAVEMPI
bin_PROGRAMS += swift_mpi swift_fixdt_mpi
bin_PROGRAMS += swift_mpi
endif
# engine_policy_setaffinity is available?
......@@ -51,19 +50,11 @@ swift_SOURCES = main.c
swift_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_keep $(ENGINE_POLICY_SETAFFINITY)"
swift_LDADD = ../src/.libs/libswiftsim.a $(EXTRA_LIBS)
swift_fixdt_SOURCES = main.c
swift_fixdt_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep $(ENGINE_POLICY_SETAFFINITY)"
swift_fixdt_LDADD = ../src/.libs/libswiftsim.a $(EXTRA_LIBS)
# Sources for swift_mpi, do we need an affinity policy for MPI?
swift_mpi_SOURCES = main.c
swift_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_keep $(ENGINE_POLICY_SETAFFINITY)"
swift_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(MPI_LIBS) $(EXTRA_LIBS)
swift_fixdt_mpi_SOURCES = main.c
swift_fixdt_mpi_CFLAGS = $(MYFLAGS) $(AM_CFLAGS) $(MPI_FLAGS) -DENGINE_POLICY="engine_policy_fixdt | engine_policy_keep $(ENGINE_POLICY_SETAFFINITY)"
swift_fixdt_mpi_LDADD = ../src/.libs/libswiftsim_mpi.a $(MPI_LIBS) $(EXTRA_LIBS)
# Scripts to generate ICs
EXTRA_DIST = BigCosmoVolume/makeIC.py \
BigPerturbedBox/makeIC_fcc.py \
......
......@@ -52,8 +52,6 @@ void print_help_message() {
printf("\nUsage: swift [OPTION]... PARAMFILE\n");
printf(" swift_mpi [OPTION]... PARAMFILE\n");
printf(" swift_fixdt [OPTION]... PARAMFILE\n");
printf(" swift_fixdt_mpi [OPTION]... PARAMFILE\n\n");
printf("Valid options are:\n");
printf(" %2s %8s %s\n", "-a", "", "Pin runners using processor affinity");
......@@ -114,8 +112,8 @@ int main(int argc, char *argv[]) {
error("Call to MPI_Init failed with error %i.", res);
if (prov != MPI_THREAD_MULTIPLE)
error(
"MPI does not provide the level of threading required "
"(MPI_THREAD_MULTIPLE).");
"MPI does not provide the level of threading"
" required (MPI_THREAD_MULTIPLE).");
if ((res = MPI_Comm_size(MPI_COMM_WORLD, &nr_nodes)) != MPI_SUCCESS)
error("MPI_Comm_size failed with error %i.", res);
if ((res = MPI_Comm_rank(MPI_COMM_WORLD, &myrank)) != MPI_SUCCESS)
......@@ -127,9 +125,7 @@ int main(int argc, char *argv[]) {
if ((res = MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN)) !=
MPI_SUCCESS)
error("Call to MPI_Comm_set_errhandler failed with error %i.", res);
if (myrank == 0)
printf("[0000][00000.0] MPI is up and running with %i node(s).\n",
nr_nodes);
if (myrank == 0) message("MPI is up and running with %i node(s).", nr_nodes);
if (nr_nodes == 1) {
message("WARNING: you are running with one MPI rank.");
message("WARNING: you should use the non-MPI version of this program.");
......
......@@ -15,7 +15,7 @@ Scheduler:
cell_max_count: 10000 # (Optional) Maximal number of particles per cell allowed before triggering a sanitizing (this is the default value).
max_top_level_cells: 12 # (Optional) Maximal number of top-level cells in any dimension. The number of top-level cells will be the cube of this (this is the default value).
# Parameters governing the time integration
# Parameters governing the time integration (Set dt_min and dt_max to the same value for a fixed time-step run.)
TimeIntegration:
time_begin: 0. # The starting time of the simulation (in internal units).
time_end: 1. # The end time of the simulation (in internal units).
......
......@@ -49,7 +49,7 @@ hexcols = ['#332288', '#88CCEE', '#44AA99', '#117733', '#999933', '#DDCC77',
'#CC6677', '#882255', '#AA4499', '#661100', '#6699CC', '#AA4466',
'#4477AA']
linestyle = (hexcols[0],hexcols[1],hexcols[3],hexcols[5],hexcols[6],hexcols[8])
#cmdLine = './swift_fixdt -s -t 16 cosmoVolume.yml'
#cmdLine = './swift -s -t 16 cosmoVolume.yml'
#platform = 'KNL'
# Work out how many data series there are
......
......@@ -56,7 +56,7 @@ pl.rcParams.update(PLOT_PARAMS)
# Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair", "init", "ghost",
"extra_ghost", "kick", "kick_fixdt", "send", "recv",
"extra_ghost", "kick", "send", "recv",
"grav_gather_m", "grav_fft", "grav_mm", "grav_up",
"grav_external", "cooling", "count"]
......@@ -70,7 +70,6 @@ TASKCOLOURS = {"none": "black",
"ghost": "cyan",
"extra_ghost": "cyan",
"kick": "green",
"kick_fixdt": "green",
"send": "yellow",
"recv": "magenta",
"grav_gather_m": "mediumorchid",
......
......@@ -64,7 +64,7 @@ pl.rcParams.update(PLOT_PARAMS)
# Tasks and subtypes. Indexed as in tasks.h.
TASKTYPES = ["none", "sort", "self", "pair", "sub_self", "sub_pair", "init",
"ghost", "extra_ghost", "kick", "kick_fixdt", "send", "recv",
"ghost", "extra_ghost", "kick", "send", "recv",
"grav_gather_m", "grav_fft", "grav_mm", "grav_up",
"grav_external", "cooling", "count"]
......@@ -78,7 +78,6 @@ TASKCOLOURS = {"none": "black",
"ghost": "cyan",
"extra_ghost": "cyan",
"kick": "green",
"kick_fixdt": "green",
"send": "yellow",
"recv": "magenta",
"grav_gather_m": "mediumorchid",
......
......@@ -74,7 +74,6 @@ const char *engine_policy_names[16] = {"none",
"steal",
"keep",
"block",
"fix_dt",
"cpu_tight",
"mpi",
"numa_affinity",
......@@ -126,7 +125,6 @@ void engine_addlink(struct engine *e, struct link **l, struct task *t) {
void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched;
const int is_fixdt = (e->policy & engine_policy_fixdt);
const int is_hydro = (e->policy & engine_policy_hydro);
const int is_with_cooling = (e->policy & engine_policy_cooling);
const int is_with_sourceterms = (e->policy & engine_policy_sourceterms);
......@@ -141,14 +139,8 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
c->init = scheduler_addtask(s, task_type_init, task_subtype_none, 0, 0, c,
NULL, 0);
/* Add the kick task that matches the policy. */
if (is_fixdt) {
c->kick = scheduler_addtask(s, task_type_kick_fixdt, task_subtype_none,
0, 0, c, NULL, 0);
} else {
c->kick = scheduler_addtask(s, task_type_kick, task_subtype_none, 0, 0,
c, NULL, 0);
}
c->kick = scheduler_addtask(s, task_type_kick, task_subtype_none, 0, 0, c,
NULL, 0);
/* Generate the ghost task. */
if (is_hydro)
......@@ -657,9 +649,8 @@ void engine_addtasks_send(struct engine *e, struct cell *ci, struct cell *cj,
4 * ci->tag, 0, ci, cj, 0);
t_rho = scheduler_addtask(s, task_type_send, task_subtype_none,
4 * ci->tag + 1, 0, ci, cj, 0);
if (!(e->policy & engine_policy_fixdt))
t_ti = scheduler_addtask(s, task_type_send, task_subtype_tend,
4 * ci->tag + 2, 0, ci, cj, 0);
t_ti = scheduler_addtask(s, task_type_send, task_subtype_tend,
4 * ci->tag + 2, 0, ci, cj, 0);
#ifdef EXTRA_HYDRO_LOOP
t_gradient = scheduler_addtask(s, task_type_send, task_subtype_none,
4 * ci->tag + 3, 0, ci, cj, 0);
......@@ -743,9 +734,8 @@ void engine_addtasks_recv(struct engine *e, struct cell *c, struct task *t_xv,
0, c, NULL, 0);
t_rho = scheduler_addtask(s, task_type_recv, task_subtype_none,
4 * c->tag + 1, 0, c, NULL, 0);
if (!(e->policy & engine_policy_fixdt))
t_ti = scheduler_addtask(s, task_type_recv, task_subtype_tend,
4 * c->tag + 2, 0, c, NULL, 0);
t_ti = scheduler_addtask(s, task_type_recv, task_subtype_tend,
4 * c->tag + 2, 0, c, NULL, 0);
#ifdef EXTRA_HYDRO_LOOP
t_gradient = scheduler_addtask(s, task_type_recv, task_subtype_none,
4 * c->tag + 3, 0, c, NULL, 0);
......@@ -1960,52 +1950,6 @@ void engine_maketasks(struct engine *e) {
clocks_from_ticks(getticks() - tic), clocks_getunit());
}
/**
* @brief Mark tasks to be un-skipped and set the sort flags accordingly.
* Threadpool mapper function for fixdt version.
*
* @param map_data pointer to the tasks
* @param num_elements number of tasks
* @param extra_data pointer to int that will define if a rebuild is needed.
*/
void engine_marktasks_fixdt_mapper(void *map_data, int num_elements,
void *extra_data) {
/* Unpack the arguments. */
struct task *tasks = (struct task *)map_data;
size_t *rebuild_space = &((size_t *)extra_data)[0];
struct scheduler *s = (struct scheduler *)(((size_t *)extra_data)[1]);
for (int ind = 0; ind < num_elements; ind++) {
struct task *t = &tasks[ind];
/* All tasks are unskipped (we skip by default). */
scheduler_activate(s, t);
/* Pair? */
if (t->type == task_type_pair || t->type == task_type_sub_pair) {
/* Local pointers. */
const struct cell *ci = t->ci;
const struct cell *cj = t->cj;
/* Too much particle movement? */
if (t->tight &&
(max(ci->h_max, cj->h_max) + ci->dx_max + cj->dx_max > cj->dmin ||
ci->dx_max > space_maxreldx * ci->h_max ||
cj->dx_max > space_maxreldx * cj->h_max))
*rebuild_space = 1;
}
/* Sort? */
else if (t->type == task_type_sort) {
/* If all the sorts have been done, make this task implicit. */
if (!(t->flags & (t->flags ^ t->ci->sorted))) t->implicit = 1;
}
}
}
/**
* @brief Mark tasks to be un-skipped and set the sort flags accordingly.
* Threadpool mapper function.
......@@ -2161,24 +2105,11 @@ int engine_marktasks(struct engine *e) {
const ticks tic = getticks();
int rebuild_space = 0;
/* Much less to do here if we're on a fixed time-step. */
if (e->policy & engine_policy_fixdt) {
/* Run through the tasks and mark as skip or not. */
size_t extra_data[2] = {rebuild_space, (size_t)&e->sched};
threadpool_map(&e->threadpool, engine_marktasks_fixdt_mapper, s->tasks,
s->nr_tasks, sizeof(struct task), 1000, extra_data);
return rebuild_space;
/* Multiple-timestep case */
} else {
/* Run through the tasks and mark as skip or not. */
size_t extra_data[3] = {e->ti_current, rebuild_space, (size_t)&e->sched};
threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks,
s->nr_tasks, sizeof(struct task), 10000, extra_data);
rebuild_space = extra_data[1];
}
/* Run through the tasks and mark as skip or not. */
size_t extra_data[3] = {e->ti_current, rebuild_space, (size_t)&e->sched};
threadpool_map(&e->threadpool, engine_marktasks_mapper, s->tasks, s->nr_tasks,
sizeof(struct task), 10000, extra_data);
rebuild_space = extra_data[1];
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
......@@ -3311,32 +3242,19 @@ void engine_init(struct engine *e, struct space *s,
e->timeBase_inv = 1.0 / e->timeBase;
e->ti_current = 0;
/* Fixed time-step case */
if (e->policy & engine_policy_fixdt) {
e->dt_min = e->dt_max;
/* Find timestep on the timeline */
int dti_timeline = max_nr_timesteps;
while (e->dt_min < dti_timeline * e->timeBase) dti_timeline /= 2;
e->dt_min = e->dt_max = dti_timeline * e->timeBase;
if (e->nodeID == 0) message("Timestep set to %e", e->dt_max);
} else {
if (e->nodeID == 0) {
message("Absolute minimal timestep size: %e", e->timeBase);
/* Info about time-steps */
if (e->nodeID == 0) {
message("Absolute minimal timestep size: %e", e->timeBase);
float dt_min = e->timeEnd - e->timeBegin;
while (dt_min > e->dt_min) dt_min /= 2.f;
float dt_min = e->timeEnd - e->timeBegin;
while (dt_min > e->dt_min) dt_min /= 2.f;
message("Minimal timestep size (on time-line): %e", dt_min);
message("Minimal timestep size (on time-line): %e", dt_min);
float dt_max = e->timeEnd - e->timeBegin;
while (dt_max > e->dt_max) dt_max /= 2.f;
float dt_max = e->timeEnd - e->timeBegin;
while (dt_max > e->dt_max) dt_max /= 2.f;
message("Maximal timestep size (on time-line): %e", dt_max);
}
message("Maximal timestep size (on time-line): %e", dt_max);
}
if (e->dt_min < e->timeBase && e->nodeID == 0)
......
......@@ -56,17 +56,16 @@ enum engine_policy {
engine_policy_steal = (1 << 1),
engine_policy_keep = (1 << 2),
engine_policy_block = (1 << 3),
engine_policy_fixdt = (1 << 4),
engine_policy_cputight = (1 << 5),
engine_policy_mpi = (1 << 6),
engine_policy_setaffinity = (1 << 7),
engine_policy_hydro = (1 << 8),
engine_policy_self_gravity = (1 << 9),
engine_policy_external_gravity = (1 << 10),
engine_policy_cosmology = (1 << 11),
engine_policy_drift_all = (1 << 12),
engine_policy_cooling = (1 << 13),
engine_policy_sourceterms = (1 << 14)
engine_policy_cputight = (1 << 4),
engine_policy_mpi = (1 << 5),
engine_policy_setaffinity = (1 << 6),
engine_policy_hydro = (1 << 7),
engine_policy_self_gravity = (1 << 8),
engine_policy_external_gravity = (1 << 9),
engine_policy_cosmology = (1 << 10),
engine_policy_drift_all = (1 << 11),
engine_policy_cooling = (1 << 12),
engine_policy_sourceterms = (1 << 13)
};
extern const char *engine_policy_names[];
......
......@@ -889,118 +889,6 @@ void runner_do_drift_mapper(void *map_data, int num_elements,
}
}
/**
* @brief Kick particles in momentum space and collect statistics (fixed
* time-step case)
*
* @param r The runner thread.
* @param c The cell.
* @param timer Are we timing this ?
*/
void runner_do_kick_fixdt(struct runner *r, struct cell *c, int timer) {
const double global_dt = r->e->dt_max;
const double timeBase = r->e->timeBase;
const int count = c->count;
const int gcount = c->gcount;
struct part *restrict parts = c->parts;
struct xpart *restrict xparts = c->xparts;
struct gpart *restrict gparts = c->gparts;
const double const_G = r->e->physical_constants->const_newton_G;
int updated = 0, g_updated = 0;
int ti_end_min = max_nr_timesteps, ti_end_max = 0;
TIMER_TIC
#ifdef TASK_VERBOSE
OUT;
#endif
/* The new time-step */
const int new_dti = global_dt / timeBase;
/* No children? */
if (!c->split) {
/* Loop over the g-particles and kick everyone. */
for (int k = 0; k < gcount; k++) {
/* Get a handle on the part. */
struct gpart *restrict gp = &gparts[k];
/* If the g-particle has no counterpart */
if (gp->id_or_neg_offset > 0) {
/* First, finish the force calculation */
gravity_end_force(gp, const_G);
/* Kick the g-particle forward */
kick_gpart(gp, new_dti, timeBase);
/* Number of updated g-particles */
g_updated++;
/* Minimal time for next end of time-step */
ti_end_min = min(gp->ti_end, ti_end_min);
ti_end_max = max(gp->ti_end, ti_end_max);
}
}
/* Now do the hydro ones... */
/* Loop over the particles and kick everyone. */
for (int k = 0; k < count; k++) {
/* Get a handle on the part. */
struct part *restrict p = &parts[k];
struct xpart *restrict xp = &xparts[k];
/* First, finish the force loop */
hydro_end_force(p);
if (p->gpart != NULL) gravity_end_force(p->gpart, const_G);
/* Kick the particle forward */
kick_part(p, xp, new_dti, timeBase);
/* Number of updated particles */
updated++;
if (p->gpart != NULL) g_updated++;
/* Minimal time for next end of time-step */
ti_end_min = min(p->ti_end, ti_end_min);
ti_end_max = max(p->ti_end, ti_end_max);
}
}
/* Otherwise, aggregate data from children. */
else {
/* Loop over the progeny. */
for (int k = 0; k < 8; k++)
if (c->progeny[k] != NULL) {
struct cell *restrict cp = c->progeny[k];
/* Recurse */
runner_do_kick_fixdt(r, cp, 0);
/* And aggregate */
updated += cp->updated;
g_updated += cp->g_updated;
ti_end_min = min(cp->ti_end_min, ti_end_min);
ti_end_max = max(cp->ti_end_max, ti_end_max);
}
}
/* Store the values. */
c->updated = updated;
c->g_updated = g_updated;
c->ti_end_min = ti_end_min;
c->ti_end_max = ti_end_max;
if (timer) TIMER_TOC(timer_kick);
}
/**
* @brief Kick particles in momentum space and collect statistics (floating
* time-step case)
......@@ -1346,9 +1234,6 @@ void *runner_main(void *data) {
case task_type_kick:
runner_do_kick(r, ci, 1);
break;
case task_type_kick_fixdt:
runner_do_kick_fixdt(r, ci, 1);
break;
#ifdef WITH_MPI
case task_type_send:
if (t->subtype == task_subtype_tend) {
......
......@@ -51,7 +51,6 @@ struct runner {
void runner_do_ghost(struct runner *r, struct cell *c);
void runner_do_sort(struct runner *r, struct cell *c, int flag, int clock);
void runner_do_kick(struct runner *r, struct cell *c, int timer);
void runner_do_kick_fixdt(struct runner *r, struct cell *c, int timer);
void runner_do_init(struct runner *r, struct cell *c, int timer);
void runner_do_cooling(struct runner *r, struct cell *c, int timer);
void *runner_main(void *data);
......
......@@ -48,10 +48,10 @@
/* Task type names. */
const char *taskID_names[task_type_count] = {
"none", "sort", "self", "pair", "sub_self",
"sub_pair", "init", "ghost", "extra_ghost", "kick",
"kick_fixdt", "send", "recv", "grav_gather_m", "grav_fft",
"grav_mm", "grav_up", "cooling", "sourceterms"};
"none", "sort", "self", "pair", "sub_self",
"sub_pair", "init", "ghost", "extra_ghost", "kick",
"send", "recv", "grav_gather_m", "grav_fft", "grav_mm",
"grav_up", "cooling", "sourceterms"};
const char *subtaskID_names[task_subtype_count] = {
"none", "density", "gradient", "force", "grav", "external_grav", "tend"};
......@@ -148,7 +148,6 @@ __attribute__((always_inline)) INLINE static enum task_actions task_acts_on(
case task_type_init:
case task_type_kick:
case task_type_kick_fixdt:
case task_type_send:
case task_type_recv:
if (t->ci->count > 0 && t->ci->gcount > 0)
......
......@@ -46,7 +46,6 @@ enum task_types {
task_type_ghost,
task_type_extra_ghost,
task_type_kick,
task_type_kick_fixdt,
task_type_send,
task_type_recv,
task_type_grav_gather_m,
......
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