Commit 6547b9ad authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'master' into GravityParticles

Conflicts:
	examples/main.c
	src/const.h
	src/engine.c
	src/engine.h
	src/space.c
	src/units.c
	src/units.h
parents 7797d781 93ce6618
......@@ -43,6 +43,7 @@ tests/testTimeIntegration
tests/testSPHStep
tests/testKernel
tests/testParser
tests/parser_output.yml
theory/latex/swift.pdf
theory/kernel/kernels.pdf
......
Welcome to the cosmological code
Welcome to the cosmological hydrodynamical code
______ _________________
/ ___/ | / / _/ ___/_ __/
\__ \| | /| / // // /_ / /
......@@ -6,8 +6,26 @@
/____/ |__/|__/___/_/ /_/
SPH With Inter-dependent Fine-grained Tasking
Website: www.swiftsim.com
Twitter: @SwiftSimulation
Website: www.swiftsim.com
Twitter: @SwiftSimulation
See INSTALL.swift for instructions.
See INSTALL.swift for install instructions.
Usage: swift [OPTION] PARAMFILE
Valid options are:
-c Run with cosmological time integration
-d Dry run. Read the parameter file, allocate memory but does not read
the particles from ICs and exit before the start of time integration.
Allows user to check validy of parameter and IC files as well as memory limits.
-e Enable floating-point exceptions (debugging mode)
-f {int} Overwrite the CPU frequency (Hz) to be used for time measurements
-g Run with an external gravitational potential
-G Run with self-gravity
-s Run with SPH
-v [12] Increase the level of verbosity 1: MPI-rank 0 writes
2: All MPI-ranks write
-y {int} Time-step frequency at which task graphs are dumped
-h Print this help message and exit
See the file examples/parameter_example.yml for an example of parameter file.
......@@ -287,11 +287,11 @@ AC_SUBST([METIS_LIBS])
AC_SUBST([METIS_INCS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LIBS"])
# Check for zlib.
AC_CHECK_LIB([z],[gzopen],[
AC_DEFINE([HAVE_LIBZ],[1],[Set to 1 if zlib is installed.])
LDFLAGS="$LDFLAGS -lz"
],[])
# # Check for zlib.
# AC_CHECK_LIB([z],[gzopen],[
# AC_DEFINE([HAVE_LIBZ],[1],[Set to 1 if zlib is installed.])
# LDFLAGS="$LDFLAGS -lz"
# ],[])
# Check for HDF5. This is required.
......
# Define the system of units to use internally.
UnitSystem:
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling
Scheduler:
nr_threads: 16 # The number of threads per MPI rank to use.
nr_queues: 0 # The number of task queues to use. Use 0 to let the system decide.
cell_max_size: 8000000 # Maximal number of interactions per task (this is the default value).
cell_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
cell_split_size: 400 # Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
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).
dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2349 # Target smoothing length in units of the mean inter-particle separation (1.2349 == 48Ngbs with the cubic spline kernel).
delta_neighbours: 1. # The tolerance for the targetted number of neighbours.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations: 30 # Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length: 0.6 # Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions:
file_name: ./cosmoVolume.hdf5 # The file to read
h_scaling: 1. # A scaling factor to apply to all smoothing lengths in the ICs.
shift_x: 0. # A shift to apply to all particles read from the ICs (in internal units).
shift_y: 0.
shift_z: 0.
# Parameters govering domain decomposition
DomainDecomposition:
initial_type: m # The initial strategy ("g", "m", "w", or "v"). See documentation for details.
initial_grid_x: 10 # Grid size if the 'g' strategy is chosen.
initial_grid_y: 10
initial_grid_z: 10
repartition_type: b # The re-decomposition strategy ("n", "b", "v", "e" or "x"). See documentation for details.
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e cosmoVolume.hdf5 ]
then
echo "Fetching initial conditions for the cosmo volume example..."
./getIC.sh
fi
../swift -s cosmoVolume.yml
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e sedov.hdf5 ]
then
echo "Generating initial conditions for the SedovBlast example..."
python makeIC_fcc.py
fi
../swift -s sedov.yml
# Define the system of units to use internally.
UnitSystem:
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling
Scheduler:
nr_threads: 16 # The number of threads per MPI rank to use.
nr_queues: 0 # The number of task queues to use. Use 0 to let the system decide.
cell_max_size: 8000000 # Maximal number of interactions per task (this is the default value).
cell_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
cell_split_size: 400 # Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
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).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2349 # Target smoothing length in units of the mean inter-particle separation (1.2349 == 48Ngbs with the cubic spline kernel).
delta_neighbours: 1. # The tolerance for the targetted number of neighbours.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations: 30 # Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length: 1. # Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions:
file_name: ./sedov.hdf5 # The file to read
h_scaling: 1. # A scaling factor to apply to all smoothing lengths in the ICs.
shift_x: 0. # A shift to apply to all particles read from the ICs (in internal units).
shift_y: 0.
shift_z: 0.
# Parameters govering domain decomposition
DomainDecomposition:
initial_type: m # The initial strategy ("g", "m", "w", or "v"). See documentation for details.
initial_grid_x: 10 # Grid size if the 'g' strategy is chosen.
initial_grid_y: 10
initial_grid_z: 10
repartition_type: b # The re-decomposition strategy ("n", "b", "v", "e" or "x"). See documentation for details.
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e sodShock.hdf5 ]
then
echo "Generating initial conditions for the SodShock example..."
python makeIC.py
fi
../swift -s sodShock.yml
# Define the system of units to use internally.
UnitSystem:
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling
Scheduler:
nr_threads: 16 # The number of threads per MPI rank to use.
nr_queues: 0 # The number of task queues to use. Use 0 to let the system decide.
cell_max_size: 8000000 # Maximal number of interactions per task (this is the default value).
cell_sub_size: 5000 # Maximal number of interactions per sub-task.
cell_split_size: 400 # Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
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).
dt_min: 1e-7 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2349 # Target smoothing length in units of the mean inter-particle separation (1.2349 == 48Ngbs with the cubic spline kernel).
delta_neighbours: 1. # The tolerance for the targetted number of neighbours.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations: 30 # Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length: 0.01 # Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions:
file_name: ./sodShock.hdf5 # The file to read
h_scaling: 1. # A scaling factor to apply to all smoothing lengths in the ICs.
shift_x: 0. # A shift to apply to all particles read from the ICs (in internal units).
shift_y: 0.
shift_z: 0.
# Parameters govering domain decomposition
DomainDecomposition:
initial_type: m # The initial strategy ("g", "m", "w", or "v"). See documentation for details.
initial_grid_x: 10 # Grid size if the 'g' strategy is chosen.
initial_grid_y: 10
initial_grid_z: 10
repartition_type: b # The re-decomposition strategy ("n", "b", "v", "e" or "x"). See documentation for details.
#!/bin/bash
# Generate the initial conditions if they are not present.
if [ ! -e uniformBox.hdf5 ]
then
echo "Generating initial conditions for the uniform box example..."
python makeIC.py 100
fi
../swift -s uniformBox.yml
# Define the system of units to use internally.
UnitSystem:
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling
Scheduler:
nr_threads: 16 # The number of threads per MPI rank to use.
nr_queues: 0 # The number of task queues to use. Use 0 to let the system decide.
cell_max_size: 8000000 # Maximal number of interactions per task (this is the default value).
cell_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
cell_split_size: 400 # Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
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).
dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2349 # Target smoothing length in units of the mean inter-particle separation (1.2349 == 48Ngbs with the cubic spline kernel).
delta_neighbours: 1. # The tolerance for the targetted number of neighbours.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations: 30 # Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions:
file_name: ./uniformBox.hdf5 # The file to read
h_scaling: 1. # A scaling factor to apply to all smoothing lengths in the ICs.
shift_x: 0. # A shift to apply to all particles read from the ICs (in internal units).
shift_y: 0.
shift_z: 0.
# Parameters govering domain decomposition
DomainDecomposition:
initial_type: m # The initial strategy ("g", "m", "w", or "v"). See documentation for details.
initial_grid_x: 10 # Grid size if the 'g' strategy is chosen.
initial_grid_y: 10
initial_grid_z: 10
repartition_type: b # The re-decomposition strategy ("n", "b", "v", "e" or "x"). See documentation for details.
This diff is collapsed.
# Define the system of units to use internally.
UnitSystem:
UnitMass_in_cgs: 1 # Grams
UnitLength_in_cgs: 1 # Centimeters
UnitVelocity_in_cgs: 1 # Centimeters per second
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Parameters for the task scheduling
Scheduler:
nr_threads: 2 # The number of threads per MPI rank to use.
nr_queues: 0 # The number of task queues to use. Use 0 to let the system decide.
cell_max_size: 8000000 # Maximal number of interactions per task (this is the default value).
cell_sub_size: 8000000 # Maximal number of interactions per sub-task (this is the default value).
cell_split_size: 400 # Maximal number of particles per cell (this is the default value).
# Parameters governing the time integration
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).
dt_min: 1e-6 # The minimal time-step size of the simulation (in internal units).
dt_max: 1e-2 # The maximal time-step size of the simulation (in internal units).
# Parameters for the hydrodynamics scheme
SPH:
resolution_eta: 1.2349 # Target smoothing length in units of the mean inter-particle separation (1.2349 == 48Ngbs with the cubic spline kernel).
delta_neighbours: 1. # The tolerance for the targetted number of neighbours.
CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration.
max_ghost_iterations: 30 # Maximal number of iterations allowed to converge towards the smoothing length.
max_smoothing_length: 3. # Maximal smoothing length allowed (in internal units).
# Parameters related to the initial conditions
InitialConditions:
file_name: SedovBlast/sedov.hdf5 # The file to read
h_scaling: 1. # A scaling factor to apply to all smoothing lengths in the ICs.
shift_x: 0. # A shift to apply to all particles read from the ICs (in internal units).
shift_y: 0.
shift_z: 0.
# Parameters govering domain decomposition
DomainDecomposition:
initial_type: m # The initial strategy ("g", "m", "w", or "v"). See documentation for details.
initial_grid_x: 10 # Grid size if the 'g' strategy is chosen.
initial_grid_y: 10
initial_grid_z: 10
repartition_type: b # The re-decomposition strategy ("n", "b", "v", "e" or "x"). See documentation for details.
#!/bin/bash
# Set some global stuff
export OMP_WAIT_POLICY=PASSIVE
# Generate the initial conditions if they are not present.
if [ ! -e SodShock/sodShock.hdf5 ]
then
echo "Generating initial conditions for the SodShock example..."
cd SodShock
python makeIC.py
cd ..
fi
if [ ! -e SedovBlast/sedov.hdf5 ]
then
echo "Generating initial conditions for the SedovBlast example..."
cd SedovBlast/
python makeIC_fcc.py
cd ..
fi
if [ ! -e CosmoVolume/cosmoVolume.hdf5 ]
then
echo "Downloading initial conditions for the CosmoVolume example..."
cd CosmoVolume
./getIC.sh
cd ..
fi
# Loop over number of cores
for cpu in {1..32}
do
# Sod-Shock runs
if [ ! -e SodShock_${cpu}.dump ]
then
./swift -t $cpu -f SodShock/sodShock.hdf5 -m 0.01 -w 5000 -c 1. -d 1e-7 -e 0.01 > SodShock_fixed_${cpu}.dump
fi
# Sedov blast
if [ ! -e SedovBlast_${cpu}.dump ]
then
./swift -t $cpu -f SedovBlast/sedov.hdf5 -m 0.02 -w 5000 -c 1. -d 1e-7 -e 0.01 > SedovBlast_fixed_${cpu}.dump
fi
# Cosmological volume
if [ ! -e CosmoVolume_${cpu}.dump ]
then
./swift -t $cpu -f CosmoVolume/cosmoVolume.hdf5 -m 0.6 -w 5000 -c 1. -d 1e-7 -e 0.01 > CosmoVolume_fixed_${cpu}.dump
fi
done
......@@ -282,15 +282,15 @@ void writeUnitSystem(hid_t h_file, struct UnitSystem* us) {
if (h_grpunit < 0) error("Error while creating Unit System group");
writeAttribute_d(h_grpunit, "Unit mass in cgs (U_M)",
getBaseUnit(us, UNIT_MASS));
units_get_base_unit(us, UNIT_MASS));
writeAttribute_d(h_grpunit, "Unit length in cgs (U_L)",
getBaseUnit(us, UNIT_LENGTH));
units_get_base_unit(us, UNIT_LENGTH));
writeAttribute_d(h_grpunit, "Unit time in cgs (U_t)",
getBaseUnit(us, UNIT_TIME));
units_get_base_unit(us, UNIT_TIME));
writeAttribute_d(h_grpunit, "Unit current in cgs (U_I)",
getBaseUnit(us, UNIT_CURRENT));
units_get_base_unit(us, UNIT_CURRENT));
writeAttribute_d(h_grpunit, "Unit temperature in cgs (U_T)",
getBaseUnit(us, UNIT_TEMPERATURE));
units_get_base_unit(us, UNIT_TEMPERATURE));
H5Gclose(h_grpunit);
}
......
......@@ -60,10 +60,11 @@
#include "partition.h"
#include "timers.h"
const char *engine_policy_names[12] = {
"none", "rand", "steal", "keep",
"block", "fix_dt", "cpu_tight", "mpi",
"numa_affinity", "hydro", "self_gravity", "external_gravity"};
const char *engine_policy_names[13] = {
"none", "rand", "steal", "keep",
"block", "fix_dt", "cpu_tight", "mpi",
"numa_affinity", "hydro", "self_gravity", "external_gravity",
"cosmology_integration"};
/** The rank of the engine as a global variable (for messages). */
int engine_rank;
......@@ -412,7 +413,6 @@ void engine_redistribute(struct engine *e) {
if ((res = MPI_Waitall(6 * nr_nodes, reqs, stats)) != MPI_SUCCESS) {
for (int k = 0; k < 6 * nr_nodes; k++) {
char buff[MPI_MAX_ERROR_STRING];
int res;
MPI_Error_string(stats[k].MPI_ERROR, buff, &res);
message("request %i has error '%s'.", k, buff);
}
......@@ -1671,7 +1671,7 @@ void engine_rebuild(struct engine *e) {
error("engine_marktasks failed after space_rebuild.");
/* Print the status of the system */
engine_print_task_counts(e);
if (e->verbose) engine_print_task_counts(e);
if (e->verbose)
message("took %.3f %s.", clocks_from_ticks(getticks() - tic),
......@@ -2041,8 +2041,8 @@ void engine_step(struct engine *e) {
if (e->nodeID == 0) {
/* Print some information to the screen */
printf("%d %e %e %d %d %.3f\n", e->step, e->time, e->timeStep, updates,
g_updates, e->wallclock_time);
printf(" %6d %14e %14e %10d %10d %21.3f\n", e->step, e->time, e->timeStep,
updates, g_updates, e->wallclock_time);
fflush(stdout);
/* Write some energy statistics */
......@@ -2334,31 +2334,27 @@ static bool hyperthreads_present(void) {
*
* @param e The #engine.
* @param s The #space in which this #runner will run.
* @param dt The initial time step to use.
* @param nr_threads The number of threads to spawn.
* @param nr_queues The number of task queues to create.
* @param params The parsed parameter file.
* @param nr_nodes The number of MPI ranks.
* @param nodeID The MPI rank of this node.
* @param policy The queuing policy to use.
* @param timeBegin Time at the begininning of the simulation.
* @param timeEnd Time at the end of the simulation.
* @param dt_min Minimal allowed timestep (unsed with fixdt policy)
* @param dt_max Maximal allowed timestep
* @param verbose Is this #engine talkative ?
*/
void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
int nr_queues, int nr_nodes, int nodeID, int policy,
float timeBegin, float timeEnd, float dt_min, float dt_max,
int verbose, const struct phys_const *physical_constants,
void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID,
int policy, int verbose,
const struct phys_const *physical_constants,
const struct external_potential *potential) {
/* Clean-up everything */
bzero(e, sizeof(struct engine));
/* Store the values. */
e->s = s;
e->nr_threads = nr_threads;
e->nr_threads = parser_get_param_int(params, "Scheduler:nr_threads");
e->policy = policy;
e->step = 0;
e->nullstep = 0;
e->nr_nodes = nr_nodes;
e->nodeID = nodeID;
e->proxy_ind = NULL;
......@@ -2367,15 +2363,15 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->forcerepart = REPART_NONE;
e->links = NULL;
e->nr_links = 0;
e->timeBegin = timeBegin;
e->timeEnd = timeEnd;
e->timeOld = timeBegin;
e->time = timeBegin;
e->timeBegin = parser_get_param_double(params, "TimeIntegration:time_begin");
e->timeEnd = parser_get_param_double(params, "TimeIntegration:time_end");
e->timeOld = e->timeBegin;
e->time = e->timeBegin;
e->ti_old = 0;
e->ti_current = 0;
e->timeStep = 0.;
e->dt_min = dt_min;
e->dt_max = dt_max;
e->dt_min = parser_get_param_double(params, "TimeIntegration:dt_min");
e->dt_max = parser_get_param_double(params, "TimeIntegration:dt_max");
e->file_stats = NULL;
e->verbose = verbose;
e->count_step = 0;
......@@ -2387,6 +2383,11 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
/* Make the space link back to the engine. */
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)
const int nr_cores = sysconf(_SC_NPROCESSORS_ONLN);
int cpuid[nr_cores];
......@@ -2482,15 +2483,19 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
engine_print_policy(e);
/* Print information about the hydro scheme */
if (e->nodeID == 0) message("Hydrodynamic scheme: %s", SPH_IMPLEMENTATION);
if (e->nodeID == 0) message("Hydrodynamic kernel: %s", kernel_name);
if ((e->policy & engine_policy_hydro) == engine_policy_hydro) {
if (e->nodeID == 0) message("Hydrodynamic scheme: %s.", SPH_IMPLEMENTATION);
if (e->nodeID == 0)
message("Hydrodynamic kernel: %s with %.2f +/- %.2f neighbours.",
kernel_name, kernel_nwneigh, const_delta_nwneigh);
}
/* Check we have sensible time bounds */
if (timeBegin >= timeEnd)
if (e->timeBegin >= e->timeEnd)
error(
"Final simulation time (t_end = %e) must be larger than the start time "
"(t_beg = %e)",
timeEnd, timeBegin);
e->timeEnd, e->timeBegin);
/* Check we have sensible time-step values */
if (e->dt_min > e->dt_max)
......@@ -2500,7 +2505,7 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->dt_min, e->dt_max);
/* Deal with timestep */
e->timeBase = (timeEnd - timeBegin) / max_nr_timesteps;
e->timeBase = (e->timeEnd - e->timeBegin) / max_nr_timesteps;
e->ti_current = 0;
/* Fixed time-step case */
......@@ -2519,12 +2524,12 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
if (e->nodeID == 0) {
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;
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;
message("Maximal timestep size (on time-line): %e", dt_max);
......@@ -2558,10 +2563,9 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
e->barrier_launchcount = 0;
/* 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 + 2 * e->nr_threads;
scheduler_init(&e->sched, e->s, nr_tasks, nr_queues, scheduler_flag_steal,
e->nodeID);
s->nr_queues = nr_queues;
/* Create the sorting tasks. */
for (int i = 0; i < e->nr_threads; i++) {
......@@ -2575,10 +2579,10 @@ void engine_init(struct engine *e, struct space *s, float dt, int nr_threads,
scheduler_ranktasks(&e->sched);
/* Allocate and init the threads. */
if ((e->runners =
(struct runner *)malloc(sizeof(struct runner) * nr_threads)) == NULL)
if ((e->runners = (struct runner *)malloc(sizeof(struct runner) *
e->nr_threads)) == NULL)
error("Failed to allocate threads array.");
for (int k = 0; k < nr_threads; k++) {