Commit 704826e2 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

The engine initialisation is now done via the parameter file

parent e9e40394
...@@ -42,11 +42,16 @@ ...@@ -42,11 +42,16 @@
#define ENGINE_POLICY engine_policy_none #define ENGINE_POLICY engine_policy_none
#endif #endif
/**
* @brief Help messages for the command line parameters.
*/
void print_help_message() { void print_help_message() {
printf("\nUsage: swift [OPTION] PARAMFILE\n\n"); printf("\nUsage: swift [OPTION] PARAMFILE\n\n");
printf("Valid options are:\n"); printf("Valid options are:\n");
printf(" %2s %8s %s\n", "-c", "", "Run with cosmological time integration"); printf(" %2s %8s %s\n", "-c", "", "Run with cosmological time integration");
printf(" %2s %8s %s\n", "-e", "",
"Enable floating-point exceptions (debugging mode)");
printf(" %2s %8s %s\n", "-f", "[value] ", printf(" %2s %8s %s\n", "-f", "[value] ",
"Overwrites the CPU frequency (Hz) to be used for time measurements"); "Overwrites the CPU frequency (Hz) to be used for time measurements");
printf(" %2s %8s %s\n", "-g", "", printf(" %2s %8s %s\n", "-g", "",
...@@ -68,13 +73,7 @@ void print_help_message() { ...@@ -68,13 +73,7 @@ void print_help_message() {
*/ */
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
int c, icount;
double time_end = DBL_MAX;
struct clocks_time tic, toc; struct clocks_time tic, toc;
float dt_max = 0.0f, dt_min = 0.0f;
int nr_nodes = 1, myrank = 0;
int with_outputs = 0;
int nr_threads, nr_queues;
#ifdef WITH_MPI #ifdef WITH_MPI
struct partition initial_partition; struct partition initial_partition;
...@@ -91,9 +90,7 @@ int main(int argc, char *argv[]) { ...@@ -91,9 +90,7 @@ int main(int argc, char *argv[]) {
#endif #endif
#endif #endif
/* Choke on FP-exceptions. */ int nr_nodes = 1, myrank = 0;
// feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
#ifdef WITH_MPI #ifdef WITH_MPI
/* Start by initializing MPI. */ /* Start by initializing MPI. */
int res = 0, prov = 0; int res = 0, prov = 0;
...@@ -147,15 +144,20 @@ int main(int argc, char *argv[]) { ...@@ -147,15 +144,20 @@ int main(int argc, char *argv[]) {
int with_external_gravity = 0; int with_external_gravity = 0;
int with_self_gravity = 0; int with_self_gravity = 0;
int with_hydro = 0; int with_hydro = 0;
int with_fp_exceptions = 0;
int verbose = 0; int verbose = 0;
char paramFileName[200] = ""; char paramFileName[200] = "";
unsigned long long cpufreq = 0; unsigned long long cpufreq = 0;
/* Parse the parameters */ /* Parse the parameters */
while ((c = getopt(argc, argv, "cf:gGhsv:y")) != -1) switch (c) { int c;
while ((c = getopt(argc, argv, "cef:gGhsv:y")) != -1) switch (c) {
case 'c': case 'c':
with_cosmology = 1; with_cosmology = 1;
break; break;
case 'e':
with_fp_exceptions = 1;
break;
case 'f': case 'f':
if (sscanf(optarg, "%llu", &cpufreq) != 1) { if (sscanf(optarg, "%llu", &cpufreq) != 1) {
if (myrank == 0) printf("Error parsing CPU frequency (-f).\n"); if (myrank == 0) printf("Error parsing CPU frequency (-f).\n");
...@@ -216,6 +218,12 @@ int main(int argc, char *argv[]) { ...@@ -216,6 +218,12 @@ int main(int argc, char *argv[]) {
message("CPU frequency used for tick conversion: %llu Hz", cpufreq); message("CPU frequency used for tick conversion: %llu Hz", cpufreq);
} }
/* Do we choke on FP-exceptions ? */
if (with_fp_exceptions) {
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
if (myrank == 0) message("Floating point exceptions will be reported.");
}
/* How large are the parts? */ /* How large are the parts? */
if (myrank == 0) { if (myrank == 0) {
message("sizeof(struct part) is %4zi bytes.", sizeof(struct part)); message("sizeof(struct part) is %4zi bytes.", sizeof(struct part));
...@@ -223,12 +231,21 @@ int main(int argc, char *argv[]) { ...@@ -223,12 +231,21 @@ int main(int argc, char *argv[]) {
message("sizeof(struct gpart) is %4zi bytes.", sizeof(struct gpart)); message("sizeof(struct gpart) is %4zi bytes.", sizeof(struct gpart));
} }
/* How vocal are we ? */
const int talking = (verbose == 1 && myrank == 0) || (verbose == 2);
/* Read the parameter file */ /* Read the parameter file */
struct swift_params params; struct swift_params params;
message("Reading parameters from file '%s'", paramFileName); if (myrank == 0) {
parser_read_file(paramFileName, &params); message("Reading parameters from file '%s'", paramFileName);
// parser_print_params(&params); parser_read_file(paramFileName, &params);
if (myrank == 0) parser_write_params_to_file(&params, "used_parameters.yml"); // parser_print_params(&params);
parser_write_params_to_file(&params, "used_parameters.yml");
}
#ifdef WITH_MPI
/* Broadcast the parameter file */
MPI_Bcast(&params, sizeof(struct swift_params), MPI_BYTE, MPI_COMM_WORLD);
#endif
/* Initialize unit system */ /* Initialize unit system */
struct UnitSystem us; struct UnitSystem us;
...@@ -284,12 +301,13 @@ int main(int argc, char *argv[]) { ...@@ -284,12 +301,13 @@ int main(int argc, char *argv[]) {
#endif #endif
if (myrank == 0) { if (myrank == 0) {
clocks_gettime(&toc); clocks_gettime(&toc);
message("Reading particle properties took %.3f %s.", message("Reading initial conditions took %.3f %s.", clocks_diff(&tic, &toc),
clocks_diff(&tic, &toc), clocks_getunit()); clocks_getunit());
fflush(stdout); fflush(stdout);
} }
/* Discard gparts if we don't have gravity */ /* Discard gparts if we don't have gravity
* (Better implementation of i/o will come)*/
if (!with_external_gravity && !with_self_gravity) { if (!with_external_gravity && !with_self_gravity) {
free(gparts); free(gparts);
gparts = NULL; gparts = NULL;
...@@ -300,18 +318,15 @@ int main(int argc, char *argv[]) { ...@@ -300,18 +318,15 @@ int main(int argc, char *argv[]) {
/* Get the total number of particles across all nodes. */ /* Get the total number of particles across all nodes. */
long long N_total[2] = {0, 0}; long long N_total[2] = {0, 0};
#if defined(WITH_MPI) #if defined(WITH_MPI)
N_long[0] = Ngas; long long N_long[2] = {Ngas, Ngpart};
N_long[1] = Ngpart;
MPI_Reduce(&N_long, &N_total, 2, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD); MPI_Reduce(&N_long, &N_total, 2, MPI_LONG_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
if (myrank == 0)
message("Read %lld gas particles and %lld gparts from the ICs", N_total[0],
N_total[1]);
#else #else
N_total[0] = Ngas; N_total[0] = Ngas;
N_total[1] = Ngpart; N_total[1] = Ngpart;
message("Read %lld gas particles and %lld gparts from the ICs", N_total[0],
N_total[1]);
#endif #endif
if (myrank == 0)
message("Read %lld gas particles and %lld gparts from the ICs.", N_total[0],
N_total[1]);
/* Apply h scaling */ /* Apply h scaling */
const double scaling = const double scaling =
...@@ -340,23 +355,13 @@ int main(int argc, char *argv[]) { ...@@ -340,23 +355,13 @@ int main(int argc, char *argv[]) {
} }
} }
return 0;
double h_max;
/* Set default number of queues. */
// if (nr_queues < 0) nr_queues = nr_threads;
/* How vocal are we ? */
const int talking = (verbose == 1 && myrank == 0) || (verbose == 2);
/* Initialize the space with this data. */ /* Initialize the space with this data. */
struct space s; struct space s;
bzero(&s, sizeof(struct space)); const double h_max =
parser_get_param_double(&params, "SPH:max_smoothing_length");
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
space_init(&s, dim, parts, gparts, Ngas, Ngpart, periodic, h_max, space_init(&s, dim, parts, gparts, Ngas, Ngpart, periodic, h_max, talking);
myrank == 0); if (talking) {
if (myrank == 0 && verbose) {
clocks_gettime(&toc); clocks_gettime(&toc);
message("space_init took %.3f %s.", clocks_diff(&tic, &toc), message("space_init took %.3f %s.", clocks_diff(&tic, &toc),
clocks_getunit()); clocks_getunit());
...@@ -364,7 +369,7 @@ int main(int argc, char *argv[]) { ...@@ -364,7 +369,7 @@ int main(int argc, char *argv[]) {
} }
/* Say a few nice things about the space we just created. */ /* Say a few nice things about the space we just created. */
if (myrank == 0) { if (talking) {
message("space dimensions are [ %.3f %.3f %.3f ].", s.dim[0], s.dim[1], message("space dimensions are [ %.3f %.3f %.3f ].", s.dim[0], s.dim[1],
s.dim[2]); s.dim[2]);
message("space %s periodic.", s.periodic ? "is" : "isn't"); message("space %s periodic.", s.periodic ? "is" : "isn't");
...@@ -376,14 +381,14 @@ int main(int argc, char *argv[]) { ...@@ -376,14 +381,14 @@ int main(int argc, char *argv[]) {
} }
/* Verify that each particle is in it's proper cell. */ /* Verify that each particle is in it's proper cell. */
if (myrank == 0) { if (talking) {
icount = 0; int icount = 0;
space_map_cells_pre(&s, 0, &map_cellcheck, &icount); space_map_cells_pre(&s, 0, &map_cellcheck, &icount);
message("map_cellcheck picked up %i parts.", icount); message("map_cellcheck picked up %i parts.", icount);
} }
/* Verify the maximal depth of cells. */ /* Verify the maximal depth of cells. */
if (myrank == 0) { if (talking) {
int data[2] = {s.maxdepth, 0}; int data[2] = {s.maxdepth, 0};
space_map_cells_pre(&s, 0, &map_maxdepth, data); space_map_cells_pre(&s, 0, &map_maxdepth, data);
message("nr of cells at depth %i is %i.", data[0], data[1]); message("nr of cells at depth %i is %i.", data[0], data[1]);
...@@ -396,14 +401,11 @@ int main(int argc, char *argv[]) { ...@@ -396,14 +401,11 @@ int main(int argc, char *argv[]) {
if (with_external_gravity) engine_policies |= engine_policy_external_gravity; if (with_external_gravity) engine_policies |= engine_policy_external_gravity;
if (with_cosmology) engine_policies |= engine_policy_cosmology; if (with_cosmology) engine_policies |= engine_policy_cosmology;
/* Initialize the engine with this space. */ /* Initialize the engine with the space and policies. */
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
if (myrank == 0) message("nr_nodes is %i.", nr_nodes);
struct engine e; struct engine e;
bzero(&e, sizeof(struct engine)); engine_init(&e, &s, &params, nr_nodes, myrank, engine_policies, talking);
engine_init(&e, &s, dt_max, nr_threads, nr_queues, nr_nodes, myrank, if (talking) {
engine_policies, 0, time_end, dt_min, dt_max, talking);
if (myrank == 0 && verbose) {
clocks_gettime(&toc); clocks_gettime(&toc);
message("engine_init took %.3f %s.", clocks_diff(&tic, &toc), message("engine_init took %.3f %s.", clocks_diff(&tic, &toc),
clocks_getunit()); clocks_getunit());
...@@ -416,6 +418,7 @@ int main(int argc, char *argv[]) { ...@@ -416,6 +418,7 @@ int main(int argc, char *argv[]) {
engine_redistribute(&e); engine_redistribute(&e);
#endif #endif
int with_outputs = 1;
if (with_outputs) { if (with_outputs) {
/* Write the state of the system before starting time integration. */ /* Write the state of the system before starting time integration. */
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
...@@ -448,7 +451,7 @@ int main(int argc, char *argv[]) { ...@@ -448,7 +451,7 @@ int main(int argc, char *argv[]) {
message( message(
"Running on %lld gas particles and %lld DM particles until t=%.3e with " "Running on %lld gas particles and %lld DM particles until t=%.3e with "
"%i threads and %i queues (dt_min=%.3e, dt_max=%.3e)...", "%i threads and %i queues (dt_min=%.3e, dt_max=%.3e)...",
N_total[0], N_total[1], time_end, e.nr_threads, e.sched.nr_queues, N_total[0], N_total[1], e.timeEnd, e.nr_threads, e.sched.nr_queues,
e.dt_min, e.dt_max); e.dt_min, e.dt_max);
fflush(stdout); fflush(stdout);
} }
...@@ -459,10 +462,12 @@ int main(int argc, char *argv[]) { ...@@ -459,10 +462,12 @@ int main(int argc, char *argv[]) {
/* Legend */ /* Legend */
if (myrank == 0) if (myrank == 0)
printf( printf(
"# Step Time time-step Number of updates Number of updates " "# Step Time time-step Number of updates Number of g-updates "
"CPU Wall-clock time [%s]\n", "CPU Wall-clock time [%s]\n",
clocks_getunit()); clocks_getunit());
return 0;
/* Let loose a runner on the space. */ /* Let loose a runner on the space. */
for (int j = 0; !engine_is_done(&e); j++) { for (int j = 0; !engine_is_done(&e); j++) {
......
...@@ -1648,7 +1648,7 @@ void engine_rebuild(struct engine *e) { ...@@ -1648,7 +1648,7 @@ void engine_rebuild(struct engine *e) {
error("engine_marktasks failed after space_rebuild."); error("engine_marktasks failed after space_rebuild.");
/* Print the status of the system */ /* Print the status of the system */
engine_print_task_counts(e); if (e->verbose) engine_print_task_counts(e);
if (e->verbose) if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic), message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
...@@ -2331,17 +2331,17 @@ static bool hyperthreads_present(void) { ...@@ -2331,17 +2331,17 @@ static bool hyperthreads_present(void) {
* @param verbose Is this #engine talkative ? * @param verbose Is this #engine talkative ?
*/ */
void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int nr_queues, int nr_nodes, int nodeID, int policy, int nr_nodes, int nodeID, int policy, int verbose) {
float timeBegin, float timeEnd, float dt_min, float dt_max,
int verbose) { /* Clean-up everything */
bzero(e, sizeof(struct engine));
/* Store the values. */ /* Store the values. */
e->s = s; e->s = s;
e->nr_threads = nr_threads; e->nr_threads = parser_get_param_int(params, "Scheduler:nr_threads");
e->policy = policy; e->policy = policy;
e->step = 0; e->step = 0;
e->nullstep = 0;
e->nr_nodes = nr_nodes; e->nr_nodes = nr_nodes;
e->nodeID = nodeID; e->nodeID = nodeID;
e->proxy_ind = NULL; e->proxy_ind = NULL;
...@@ -2350,15 +2350,15 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2350,15 +2350,15 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->forcerepart = REPART_NONE; e->forcerepart = REPART_NONE;
e->links = NULL; e->links = NULL;
e->nr_links = 0; e->nr_links = 0;
e->timeBegin = timeBegin; e->timeBegin = parser_get_param_double(params, "TimeIntegration:time_begin");
e->timeEnd = timeEnd; e->timeEnd = parser_get_param_double(params, "TimeIntegration:time_end");
e->timeOld = timeBegin; e->timeOld = e->timeBegin;
e->time = timeBegin; e->time = e->timeBegin;
e->ti_old = 0; e->ti_old = 0;
e->ti_current = 0; e->ti_current = 0;
e->timeStep = 0.; e->timeStep = 0.;
e->dt_min = dt_min; e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
e->dt_max = dt_max; e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max");
e->file_stats = NULL; e->file_stats = NULL;
e->verbose = verbose; e->verbose = verbose;
e->count_step = 0; e->count_step = 0;
...@@ -2368,6 +2368,11 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2368,6 +2368,11 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
/* Make the space link back to the engine. */ /* Make the space link back to the engine. */
s->e = e; s->e = e;
/* Get the number of queues */
int nr_queues = parser_get_param_int(params, "Scheduler:nr_queues");
if (nr_queues <= 0) nr_queues = e->nr_threads;
s->nr_queues = nr_queues;
#if defined(HAVE_SETAFFINITY) #if defined(HAVE_SETAFFINITY)
const int nr_cores = sysconf(_SC_NPROCESSORS_ONLN); const int nr_cores = sysconf(_SC_NPROCESSORS_ONLN);
int cpuid[nr_cores]; int cpuid[nr_cores];
...@@ -2466,11 +2471,11 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2466,11 +2471,11 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
if (e->nodeID == 0) message("Hydrodynamic scheme: %s", SPH_IMPLEMENTATION); if (e->nodeID == 0) message("Hydrodynamic scheme: %s", SPH_IMPLEMENTATION);
/* Check we have sensible time bounds */ /* Check we have sensible time bounds */
if (timeBegin >= timeEnd) if (e->timeBegin >= e->timeEnd)
error( error(
"Final simulation time (t_end = %e) must be larger than the start time " "Final simulation time (t_end = %e) must be larger than the start time "
"(t_beg = %e)", "(t_beg = %e)",
timeEnd, timeBegin); e->timeEnd, e->timeBegin);
/* Check we have sensible time-step values */ /* Check we have sensible time-step values */
if (e->dt_min > e->dt_max) if (e->dt_min > e->dt_max)
...@@ -2480,7 +2485,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2480,7 +2485,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->dt_min, e->dt_max); e->dt_min, e->dt_max);
/* Deal with timestep */ /* Deal with timestep */
e->timeBase = (timeEnd - timeBegin) / max_nr_timesteps; e->timeBase = (e->timeEnd - e->timeBegin) / max_nr_timesteps;
e->ti_current = 0; e->ti_current = 0;
/* Fixed time-step case */ /* Fixed time-step case */
...@@ -2499,12 +2504,12 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2499,12 +2504,12 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
if (e->nodeID == 0) { if (e->nodeID == 0) {
message("Absolute minimal timestep size: %e", e->timeBase); message("Absolute minimal timestep size: %e", e->timeBase);
float dt_min = timeEnd - timeBegin; float dt_min = e->timeEnd - e->timeBegin;
while (dt_min > e->dt_min) dt_min /= 2.f; 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 = timeEnd - timeBegin; float dt_max = e->timeEnd - e->timeBegin;
while (dt_max > e->dt_max) dt_max /= 2.f; 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);
...@@ -2538,10 +2543,9 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2538,10 +2543,9 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->barrier_launchcount = 0; e->barrier_launchcount = 0;
/* Init the scheduler with enough tasks for the initial sorting tasks. */ /* Init the scheduler with enough tasks for the initial sorting tasks. */
int nr_tasks = 2 * s->tot_cells + e->nr_threads; const int nr_tasks = 2 * s->tot_cells + e->nr_threads;
scheduler_init(&e->sched, e->s, nr_tasks, nr_queues, scheduler_flag_steal, scheduler_init(&e->sched, e->s, nr_tasks, nr_queues, scheduler_flag_steal,
e->nodeID); e->nodeID);
s->nr_queues = nr_queues;
/* Create the sorting tasks. */ /* Create the sorting tasks. */
for (int i = 0; i < e->nr_threads; i++) for (int i = 0; i < e->nr_threads; i++)
...@@ -2551,10 +2555,10 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2551,10 +2555,10 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
scheduler_ranktasks(&e->sched); scheduler_ranktasks(&e->sched);
/* Allocate and init the threads. */ /* Allocate and init the threads. */
if ((e->runners = if ((e->runners = (struct runner *)malloc(sizeof(struct runner) *
(struct runner *)malloc(sizeof(struct runner) * nr_threads)) == NULL) e->nr_threads)) == NULL)
error("Failed to allocate threads array."); error("Failed to allocate threads array.");
for (int k = 0; k < nr_threads; k++) { for (int k = 0; k < e->nr_threads; k++) {
e->runners[k].id = k; e->runners[k].id = k;
e->runners[k].e = e; e->runners[k].e = e;
e->barrier_running += 1; e->barrier_running += 1;
...@@ -2566,7 +2570,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2566,7 +2570,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
/* Set a reasonable queue ID. */ /* Set a reasonable queue ID. */
e->runners[k].cpuid = cpuid[k % nr_cores]; e->runners[k].cpuid = cpuid[k % nr_cores];
if (nr_queues < nr_threads) if (nr_queues < e->nr_threads)
e->runners[k].qid = cpuid[k % nr_cores] * nr_queues / nr_cores; e->runners[k].qid = cpuid[k % nr_cores] * nr_queues / nr_cores;
else else
e->runners[k].qid = k; e->runners[k].qid = k;
...@@ -2585,7 +2589,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, ...@@ -2585,7 +2589,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
#endif #endif
} else { } else {
e->runners[k].cpuid = k; e->runners[k].cpuid = k;
e->runners[k].qid = k * nr_queues / nr_threads; e->runners[k].qid = k * nr_queues / e->nr_threads;
} }
// message( "runner %i on cpuid=%i with qid=%i." , e->runners[k].id , // message( "runner %i on cpuid=%i with qid=%i." , e->runners[k].id ,
// e->runners[k].cpuid , e->runners[k].qid ); // e->runners[k].cpuid , e->runners[k].qid );
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "scheduler.h" #include "scheduler.h"
#include "space.h" #include "space.h"
#include "task.h" #include "task.h"
#include "parser.h"
#include "partition.h" #include "partition.h"
/* Some constants. */ /* Some constants. */
...@@ -127,7 +128,7 @@ struct engine { ...@@ -127,7 +128,7 @@ struct engine {
FILE *file_stats; FILE *file_stats;
/* The current step number. */ /* The current step number. */
int step, nullstep; int step;
/* The number of particles updated in the previous step. */ /* The number of particles updated in the previous step. */
int count_step; int count_step;
...@@ -167,10 +168,8 @@ struct engine { ...@@ -167,10 +168,8 @@ struct engine {
/* Function prototypes. */ /* Function prototypes. */
void engine_barrier(struct engine *e, int tid); void engine_barrier(struct engine *e, int tid);
void engine_init(struct engine *e, struct space *s, float dt, int nr_threads, void engine_init(struct engine *e, struct space *s, struct swift_params *params,
int nr_queues, int nr_nodes, int nodeID, int policy, int nr_nodes, int nodeID, int policy, int verbose);
float timeBegin, float timeEnd, float dt_min, float dt_max,
int verbose);
void engine_launch(struct engine *e, int nr_runners, unsigned int mask, void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
unsigned int submask); unsigned int submask);
void engine_prepare(struct engine *e); void engine_prepare(struct engine *e);
......
...@@ -1281,6 +1281,9 @@ void space_init(struct space *s, double dim[3], struct part *parts, ...@@ -1281,6 +1281,9 @@ void space_init(struct space *s, double dim[3], struct part *parts,
struct gpart *gparts, size_t Ngas, size_t Ngpart, int periodic, struct gpart *gparts, size_t Ngas, size_t Ngpart, int periodic,
double h_max, int verbose) { double h_max, int verbose) {
/* Clean-up everything */
bzero(s, sizeof(struct space));
/* Store everything in the space. */ /* Store everything in the space. */
s->dim[0] = dim[0]; s->dim[0] = dim[0];
s->dim[1] = dim[1]; s->dim[1] = dim[1];
...@@ -1293,7 +1296,7 @@ void space_init(struct space *s, double dim[3], struct part *parts, ...@@ -1293,7 +1296,7 @@ void space_init(struct space *s, double dim[3], struct part *parts,
s->size_gparts = Ngpart; s->size_gparts = Ngpart;
s->gparts = gparts; s->gparts = gparts;
s->cell_min = h_max; s->cell_min = h_max;
s->nr_queues = 1; s->nr_queues = 1; /* Temporary value until engine construction */
s->size_parts_foreign = 0; s->size_parts_foreign = 0;
/* Check that all the gas particle positions are reasonable, wrap if periodic.