diff --git a/configure.ac b/configure.ac index f6e2ea0db8e9829b719a0190eea7a1d891bfbbd6..8cb7fd1b3f09819b7c8b57ce5d70e3b38e32a637 100644 --- a/configure.ac +++ b/configure.ac @@ -170,6 +170,18 @@ if test "x$enable_debug" = "xyes"; then fi fi +# Check if task debugging is on. +AC_ARG_ENABLE([task-debugging], + [AS_HELP_STRING([--enable-task-debugging], + [Store task timing information and generate task dump files @<:@yes/no@:>@] + )], + [enable_task_debugging="$enableval"], + [enable_task_debugging="no"] +) +if test "$enable_task_debugging" = "yes"; then + AC_DEFINE([SWIFT_DEBUG_TASKS],1,[Enable task debugging]) +fi + # Define HAVE_POSIX_MEMALIGN if it works. AX_FUNC_POSIX_MEMALIGN @@ -533,6 +545,7 @@ AC_MSG_RESULT([ libNUMA enabled : $have_numa Using tcmalloc : $have_tcmalloc CPU profiler : $have_profiler + Task debugging : $enable_task_debugging ]) # Generate output. diff --git a/examples/CoolingBox/coolingBox.yml b/examples/CoolingBox/coolingBox.yml index 1fdebd74bfff9c187d99541f44ae0e5f2582185d..b90ae61e5c862753227b82ebcec4cbf8f3083fab 100644 --- a/examples/CoolingBox/coolingBox.yml +++ b/examples/CoolingBox/coolingBox.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/CoolingHalo/cooling_halo.yml b/examples/CoolingHalo/cooling_halo.yml index fba71e2ff9490800eeb18b9b0cd3b1977a4d6cd9..c06b099eb0dd06d39040e0ecc8e8f1320a89ac6b 100644 --- a/examples/CoolingHalo/cooling_halo.yml +++ b/examples/CoolingHalo/cooling_halo.yml @@ -28,7 +28,6 @@ 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_smoothing_length: 1. # Maximal smoothing length allowed (in internal units). # Parameters related to the initial conditions InitialConditions: diff --git a/examples/CoolingHaloWithSpin/cooling_halo.yml b/examples/CoolingHaloWithSpin/cooling_halo.yml index d0fcc1c5953b1f9159da382d7cccd331fcbd2e21..b90d2fa88146dfec89170e004c6aed5ece64bc75 100644 --- a/examples/CoolingHaloWithSpin/cooling_halo.yml +++ b/examples/CoolingHaloWithSpin/cooling_halo.yml @@ -28,7 +28,6 @@ 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_smoothing_length: 1. # Maximal smoothing length allowed (in internal units). # Parameters related to the initial conditions InitialConditions: diff --git a/examples/CosmoVolume/cosmoVolume.yml b/examples/CosmoVolume/cosmoVolume.yml index 13cea318144d296183d630a53d78c69d050c1abe..46189bf25f26d46cbd1e5321b00298cd5553eb59 100644 --- a/examples/CosmoVolume/cosmoVolume.yml +++ b/examples/CosmoVolume/cosmoVolume.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.705 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/EAGLE_12/eagle_12.yml b/examples/EAGLE_12/eagle_12.yml index cd7db4f86f24f4d78db29a3dfe34bc536af6ed7d..bb5f97f029e1d50d81bbdccae9ac620e9e0e6f08 100644 --- a/examples/EAGLE_12/eagle_12.yml +++ b/examples/EAGLE_12/eagle_12.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 1.0 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/EAGLE_25/eagle_25.yml b/examples/EAGLE_25/eagle_25.yml index 9775cca83273350dfa71af009fb0f98cb19b20bf..12a413b7e2c45443601c0b9753383b90942298b0 100644 --- a/examples/EAGLE_25/eagle_25.yml +++ b/examples/EAGLE_25/eagle_25.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 1.0 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/EAGLE_50/eagle_50.yml b/examples/EAGLE_50/eagle_50.yml index 1d950088e2daa163ffebdc7efef030d2e5fad12c..b84b1eb7c362f85d8cd6a08ff2a15f72d1337396 100644 --- a/examples/EAGLE_50/eagle_50.yml +++ b/examples/EAGLE_50/eagle_50.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 2.0 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/ExternalPointMass/externalPointMass.yml b/examples/ExternalPointMass/externalPointMass.yml index ce300b32157361e7860d201c186823471a179c0a..621a66bbc39838ac8d3d8a8a3992b2a7be3157a8 100644 --- a/examples/ExternalPointMass/externalPointMass.yml +++ b/examples/ExternalPointMass/externalPointMass.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 10. # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/Feedback/feedback.yml b/examples/Feedback/feedback.yml index 9ff7eea325b43fe3c670d16bdbd4ccc66f33333e..de4f7abef1ef538a97a5e38c72b4db5ce2647976 100644 --- a/examples/Feedback/feedback.yml +++ b/examples/Feedback/feedback.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions @@ -37,8 +36,8 @@ InitialConditions: # Parameters for feedback SN: - time: 0.001 # time the SN explodes (internal units) - energy: 1.0 # energy of the explosion (internal units) - x: 0.5 # x-position of explostion (internal units) - y: 0.5 # y-position of explostion (internal units) - z: 0.5 # z-position of explostion (internal units) + time: 0.001 # time the SN explodes (internal units) + energy: 1.0 # energy of the explosion (internal units) + x: 0.5 # x-position of explostion (internal units) + y: 0.5 # y-position of explostion (internal units) + z: 0.5 # z-position of explostion (internal units) diff --git a/examples/Gradients/gradientsCartesian.yml b/examples/Gradients/gradientsCartesian.yml index 917a4803004c2ce89984beb857cb1691d9a1ec1b..61192e52393d88501408ac3982afeff2dc58f727 100644 --- a/examples/Gradients/gradientsCartesian.yml +++ b/examples/Gradients/gradientsCartesian.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.01 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/Gradients/gradientsRandom.yml b/examples/Gradients/gradientsRandom.yml index 209f30060f031f7d50a15ffbf8ad0e7fe5b013b8..75e6e65c92b79f6883616b91a9345a56ca7330c8 100644 --- a/examples/Gradients/gradientsRandom.yml +++ b/examples/Gradients/gradientsRandom.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.01 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/Gradients/gradientsStretched.yml b/examples/Gradients/gradientsStretched.yml index 592a70762988fca764c3ec7dcbc9bfcc9a8f2751..71c75533d13ff35b1f5bd707917fff116764187f 100644 --- a/examples/Gradients/gradientsStretched.yml +++ b/examples/Gradients/gradientsStretched.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.01 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/GreshoVortex_2D/gresho.yml b/examples/GreshoVortex_2D/gresho.yml index b4de5bde517556cacb94d996f5a11cbe05188bf9..d3de962b9bd37ff61e3bc293899d3b77aa6aed99 100644 --- a/examples/GreshoVortex_2D/gresho.yml +++ b/examples/GreshoVortex_2D/gresho.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.02 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/HydrostaticHalo/hydrostatic.yml b/examples/HydrostaticHalo/hydrostatic.yml index 21d1a79dd1a63a3a2ce3ff300632d6c79cb9a973..f0f07f943c768181cda459f79dc31bf18ca8d20a 100644 --- a/examples/HydrostaticHalo/hydrostatic.yml +++ b/examples/HydrostaticHalo/hydrostatic.yml @@ -28,7 +28,6 @@ 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_smoothing_length: 1. # Maximal smoothing length allowed (in internal units). # Parameters related to the initial conditions InitialConditions: diff --git a/examples/KelvinHelmholtz_2D/kelvinHelmholtz.yml b/examples/KelvinHelmholtz_2D/kelvinHelmholtz.yml index 38dd16880a209b885f7ad9c30c024988f4d8228f..4d121a6f1c484fbdef717398ee5024f98cab3751 100644 --- a/examples/KelvinHelmholtz_2D/kelvinHelmholtz.yml +++ b/examples/KelvinHelmholtz_2D/kelvinHelmholtz.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.01 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/MultiTypes/multiTypes.yml b/examples/MultiTypes/multiTypes.yml index 51a6d2b478681e2e1c61e199f758e35c507ec195..4d54f95fcdd09464b03d0f9987398cd2710b2e44 100644 --- a/examples/MultiTypes/multiTypes.yml +++ b/examples/MultiTypes/multiTypes.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/PerturbedBox_2D/perturbedPlane.yml b/examples/PerturbedBox_2D/perturbedPlane.yml index e810131cc4b1c66b46b483b1605f9d84bcf203b3..b92e29f620edc6f72399111fbe73ba6bd1485e92 100644 --- a/examples/PerturbedBox_2D/perturbedPlane.yml +++ b/examples/PerturbedBox_2D/perturbedPlane.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/PerturbedBox_3D/perturbedBox.yml b/examples/PerturbedBox_3D/perturbedBox.yml index 3a445e27e74fb83fb8deb56fde6003c22f7dedf1..71c8dece4df5505eb44511ee92291feedd7ffab1 100644 --- a/examples/PerturbedBox_3D/perturbedBox.yml +++ b/examples/PerturbedBox_3D/perturbedBox.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SedovBlast_1D/sedov.yml b/examples/SedovBlast_1D/sedov.yml index 1ecfeb32452d05f299b98124c4fdfc79126f7504..2a15d6ed22e71735c04274cee3f719b9d21f170e 100644 --- a/examples/SedovBlast_1D/sedov.yml +++ b/examples/SedovBlast_1D/sedov.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SedovBlast_2D/sedov.yml b/examples/SedovBlast_2D/sedov.yml index 6f519835d26ff5aa851ffb8999e650815c522cd3..1cc4aced9af3314cadde44f768016225426addf6 100644 --- a/examples/SedovBlast_2D/sedov.yml +++ b/examples/SedovBlast_2D/sedov.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SedovBlast_3D/sedov.yml b/examples/SedovBlast_3D/sedov.yml index 6f519835d26ff5aa851ffb8999e650815c522cd3..1cc4aced9af3314cadde44f768016225426addf6 100644 --- a/examples/SedovBlast_3D/sedov.yml +++ b/examples/SedovBlast_3D/sedov.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SodShock_1D/sodShock.yml b/examples/SodShock_1D/sodShock.yml index d5c4d0b034ff5351222d2162e37e3e40ceab834f..a5759109e48b7e7eb9cbd15957cf438edd909f1f 100644 --- a/examples/SodShock_1D/sodShock.yml +++ b/examples/SodShock_1D/sodShock.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.4 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SodShock_2D/sodShock.yml b/examples/SodShock_2D/sodShock.yml index 6805724ff58defebc41f3fb5b636d0003b0d6680..e7e01fa36bf93105371aa97336e18535e4078853 100644 --- a/examples/SodShock_2D/sodShock.yml +++ b/examples/SodShock_2D/sodShock.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.02 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SodShock_3D/sodShock.yml b/examples/SodShock_3D/sodShock.yml index 1ab6eb626db09678f66322e8f0e8674c0931ddb6..e7e01fa36bf93105371aa97336e18535e4078853 100644 --- a/examples/SodShock_3D/sodShock.yml +++ b/examples/SodShock_3D/sodShock.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.05 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/SquareTest_2D/square.yml b/examples/SquareTest_2D/square.yml index 4f39c6490899cfaafeda17fb0c28281cbadcbbea..a4a9e5dea8e31920ea0c5b63275f47e69da719e2 100644 --- a/examples/SquareTest_2D/square.yml +++ b/examples/SquareTest_2D/square.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.02 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/UniformBox_2D/uniformPlane.yml b/examples/UniformBox_2D/uniformPlane.yml index a3e2d275e50fb20f66ea6494c1202319e462dbed..0354f8e78eea17a41b3ed02e615cd3fb216f59c0 100644 --- a/examples/UniformBox_2D/uniformPlane.yml +++ b/examples/UniformBox_2D/uniformPlane.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/UniformBox_3D/uniformBox.yml b/examples/UniformBox_3D/uniformBox.yml index 8aaa802b64de46244f7066bce00f342cad8c5ef0..e75c878389be83304dbb9670e20a6aaf03c9c6e0 100644 --- a/examples/UniformBox_3D/uniformBox.yml +++ b/examples/UniformBox_3D/uniformBox.yml @@ -27,7 +27,6 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. # Parameters related to the initial conditions diff --git a/examples/main.c b/examples/main.c index 8bd591ccbd1c2fd860fa8ae2321d2e34132b287f..09b6c785a6dc29ecc1202c949b8f3d03f6f1fa78 100644 --- a/examples/main.c +++ b/examples/main.c @@ -235,6 +235,13 @@ int main(int argc, char *argv[]) { if (myrank == 0) print_help_message(); return 1; } +#ifndef SWIFT_DEBUG_TASKS + if (dump_tasks) { + error( + "Task dumping is only possible if SWIFT was configured with the " + "--enable-task-debugging option."); + } +#endif break; case '?': if (myrank == 0) print_help_message(); @@ -549,6 +556,7 @@ int main(int argc, char *argv[]) { /* Take a step. */ engine_step(&e); +#ifdef SWIFT_DEBUG_TASKS /* Dump the task data using the given frequency. */ if (dump_tasks && (dump_tasks == 1 || j % dump_tasks == 1)) { #ifdef WITH_MPI @@ -626,8 +634,9 @@ int main(int argc, char *argv[]) { } } fclose(file_thread); -#endif +#endif // WITH_MPI } +#endif // SWIFT_DEBUG_TASKS } /* Print the values of the runner histogram. */ diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index aee868f216f7f46c008dd8276d9dac1657eb20b1..ab348fb7d1d4bd86f6d57ff69a1ea439c37a4630 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -8,11 +8,12 @@ InternalUnitSystem: # Parameters for the task scheduling Scheduler: - nr_queues: 0 # (Optional) The number of task queues to use. Use 0 to let the system decide. - cell_max_size: 8000000 # (Optional) Maximal number of interactions per task if we force the split (this is the default value). - cell_sub_size: 64000000 # (Optional) Maximal number of interactions per sub-task (this is the default value). - cell_split_size: 400 # (Optional) Maximal number of particles per cell (this is the default value). - cell_max_count: 10000 # (Optional) Maximal number of particles per cell allowed before triggering a sanitizing (this is the default value). + nr_queues: 0 # (Optional) The number of task queues to use. Use 0 to let the system decide. + cell_max_size: 8000000 # (Optional) Maximal number of interactions per task if we force the split (this is the default value). + cell_sub_size: 64000000 # (Optional) Maximal number of interactions per sub-task (this is the default value). + cell_split_size: 400 # (Optional) Maximal number of particles per cell (this is the default value). + 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 TimeIntegration: @@ -43,9 +44,8 @@ Statistics: SPH: resolution_eta: 1.2348 # Target smoothing length in units of the mean inter-particle separation (1.2348 == 48Ngbs with the cubic spline kernel). delta_neighbours: 0.1 # The tolerance for the targetted number of neighbours. - max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length. - max_smoothing_length: 0.1 # Maximal smoothing length allowed (in internal units). CFL_condition: 0.1 # Courant-Friedrich-Levy condition for time integration. + max_ghost_iterations: 30 # (Optional) Maximal number of iterations allowed to converge towards the smoothing length. max_volume_change: 2. # (Optional) Maximal allowed change of kernel volume over one time-step # Parameters related to the initial conditions diff --git a/src/engine.c b/src/engine.c index aede0c38f1f06ea19a7fa212c5912ea69291591d..afb86381dc470a6965151a98c9d47379af4b30db 100644 --- a/src/engine.c +++ b/src/engine.c @@ -1379,6 +1379,9 @@ void engine_count_and_link_tasks(struct engine *e) { engine_addlink(e, &ci->grav, t); engine_addlink(e, &cj->grav, t); } + if (t->subtype == task_subtype_external_grav) { + error("Found a pair/external-gravity task..."); + } /* Link sub-self tasks to cells. */ } else if (t->type == task_type_sub_self) { @@ -1407,8 +1410,6 @@ void engine_count_and_link_tasks(struct engine *e) { } if (t->subtype == task_subtype_external_grav) { error("Found a sub-pair/external-gravity task..."); - engine_addlink(e, &ci->grav, t); - engine_addlink(e, &cj->grav, t); } } } @@ -2241,9 +2242,10 @@ void engine_rebuild(struct engine *e) { e->forcerebuild = 0; /* Re-build the space. */ - space_rebuild(e->s, 0.0, e->verbose); + space_rebuild(e->s, e->verbose); - if (e->ti_current == 0) space_sanitize(e->s); + /* Initial cleaning up session ? */ + if (e->s->sanitized == 0) space_sanitize(e->s); /* If in parallel, exchange the cell structure. */ #ifdef WITH_MPI @@ -2609,6 +2611,7 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs) { /* Ready to go */ e->step = -1; + e->forcerebuild = 1; e->wallclock_time = (float)clocks_diff(&time1, &time2); if (e->verbose) message("took %.3f %s.", e->wallclock_time, clocks_getunit()); diff --git a/src/error.h b/src/error.h index b131cb124feedc48e83427122f3a0edcb2ec81d4..92a9ce71a3d939cb2e18267848b0e2c66dd4741a 100644 --- a/src/error.h +++ b/src/error.h @@ -38,19 +38,19 @@ #ifdef WITH_MPI extern int engine_rank; #define error(s, ...) \ - { \ + ({ \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \ ##__VA_ARGS__); \ MPI_Abort(MPI_COMM_WORLD, -1); \ - } + }) #else #define error(s, ...) \ - { \ + ({ \ fprintf(stderr, "%s %s:%s():%i: " s "\n", clocks_get_timesincestart(), \ __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \ abort(); \ - } + }) #endif #ifdef WITH_MPI @@ -60,7 +60,7 @@ extern int engine_rank; * */ #define mpi_error(res, s, ...) \ - { \ + ({ \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \ ##__VA_ARGS__); \ @@ -69,10 +69,10 @@ extern int engine_rank; MPI_Error_string(res, buf, &len); \ fprintf(stderr, "%s\n\n", buf); \ MPI_Abort(MPI_COMM_WORLD, -1); \ - } + }) #define mpi_error_string(res, s, ...) \ - { \ + ({ \ fprintf(stderr, "[%04i] %s %s:%s():%i: " s "\n", engine_rank, \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__, \ ##__VA_ARGS__); \ @@ -80,7 +80,7 @@ extern int engine_rank; char buf[len]; \ MPI_Error_string(res, buf, &len); \ fprintf(stderr, "%s\n\n", buf); \ - } + }) #endif /** @@ -89,13 +89,17 @@ extern int engine_rank; */ #ifdef WITH_MPI extern int engine_rank; -#define message(s, ...) \ - printf("[%04i] %s %s: " s "\n", engine_rank, clocks_get_timesincestart(), \ - __FUNCTION__, ##__VA_ARGS__) +#define message(s, ...) \ + ({ \ + printf("[%04i] %s %s: " s "\n", engine_rank, clocks_get_timesincestart(), \ + __FUNCTION__, ##__VA_ARGS__); \ + }) #else -#define message(s, ...) \ - printf("%s %s: " s "\n", clocks_get_timesincestart(), __FUNCTION__, \ - ##__VA_ARGS__) +#define message(s, ...) \ + ({ \ + printf("%s %s: " s "\n", clocks_get_timesincestart(), __FUNCTION__, \ + ##__VA_ARGS__); \ + }) #endif /** @@ -105,7 +109,7 @@ extern int engine_rank; #ifdef WITH_MPI extern int engine_rank; #define assert(expr) \ - { \ + ({ \ if (!(expr)) { \ fprintf(stderr, "[%04i] %s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \ engine_rank, clocks_get_timesincestart(), __FILE__, \ @@ -113,17 +117,17 @@ extern int engine_rank; fflush(stderr); \ MPI_Abort(MPI_COMM_WORLD, -1); \ } \ - } + }) #else #define assert(expr) \ - { \ + ({ \ if (!(expr)) { \ fprintf(stderr, "%s %s:%s():%i: FAILED ASSERTION: " #expr " \n", \ clocks_get_timesincestart(), __FILE__, __FUNCTION__, __LINE__); \ fflush(stderr); \ abort(); \ } \ - } + }) #endif #endif /* SWIFT_ERROR_H */ diff --git a/src/hydro/Gadget2/hydro_iact.h b/src/hydro/Gadget2/hydro_iact.h index fca1bcff91a71fb2a26adc117382630a576f9090..08fb2b37db566e191bd74d82488b5d68e764573b 100644 --- a/src/hydro/Gadget2/hydro_iact.h +++ b/src/hydro/Gadget2/hydro_iact.h @@ -226,7 +226,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_density( error( "The Gadget2 serial version of runner_iact_density was called when the " - "vectorised version should have been used.") + "vectorised version should have been used."); #endif } @@ -377,7 +377,7 @@ runner_iact_nonsym_vec_density(float *R2, float *Dx, float *Hi, float *Hj, error( "The Gadget2 serial version of runner_iact_nonsym_density was called " - "when the vectorised version should have been used.") + "when the vectorised version should have been used."); #endif } @@ -656,7 +656,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_vec_force( error( "The Gadget2 serial version of runner_iact_nonsym_force was called when " - "the vectorised version should have been used.") + "the vectorised version should have been used."); #endif } @@ -917,7 +917,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_vec_force( error( "The Gadget2 serial version of runner_iact_nonsym_force was called when " - "the vectorised version should have been used.") + "the vectorised version should have been used."); #endif } diff --git a/src/partition.c b/src/partition.c index 8d17bedf0aaeadc64044b12ffe1bb8887b02d83e..3f5386154497d6901a5330b828007f86d87033a4 100644 --- a/src/partition.c +++ b/src/partition.c @@ -370,7 +370,7 @@ static void pick_metis(struct space *s, int nregions, int *vertexw, int *edgew, /* Dump graph in METIS format */ /* dumpMETISGraph("metis_graph", idx_ncells, one, xadj, adjncy, - * weights_v, weights_e, NULL); + * weights_v, NULL, weights_e); */ if (METIS_PartGraphKway(&idx_ncells, &one, xadj, adjncy, weights_v, weights_e, @@ -420,7 +420,7 @@ static void repart_edge_metis(int partweights, int bothweights, int nodeID, * assume the same graph structure as used in the part_ calls). */ int nr_cells = s->nr_cells; struct cell *cells = s->cells_top; - float wscale = 1e-3, vscale = 1e-3, wscale_buff = 0.0; + float wscale = 1.f, wscale_buff = 0.0; int wtot = 0; int wmax = 1e9 / nr_nodes; int wmin; @@ -459,15 +459,8 @@ static void repart_edge_metis(int partweights, int bothweights, int nodeID, t->type != task_type_init) continue; - /* Get the task weight. This can be slightly negative on multiple board - * computers when the runners are not pinned to cores, don't stress just - * make a report and ignore these tasks. */ - int w = (t->toc - t->tic) * wscale; - if (w < 0) { - message("Task toc before tic: -%.3f %s, (try using processor affinity).", - clocks_from_ticks(t->tic - t->toc), clocks_getunit()); - w = 0; - } + /* Get the task weight. */ + int w = t->cost * wscale; /* Do we need to re-scale? */ wtot += w; @@ -616,7 +609,7 @@ static void repart_edge_metis(int partweights, int bothweights, int nodeID, if (weights_e[k] == 0) weights_e[k] = 1; if (bothweights) for (int k = 0; k < nr_cells; k++) - if ((weights_v[k] *= vscale) == 0) weights_v[k] = 1; + if (weights_v[k] == 0) weights_v[k] = 1; /* And partition, use both weights or not as requested. */ if (bothweights) diff --git a/src/potential.c b/src/potential.c index 7c426c18cb1ac5787c563fba5e9722cce9b0c73b..6ee80900952c032d019ad5d20ec086d05d34ef29 100644 --- a/src/potential.c +++ b/src/potential.c @@ -31,6 +31,7 @@ * @param parameter_file The parsed parameter file * @param phys_const Physical constants in internal units * @param us The current internal system of units + * @param s The #space we run in. * @param potential The external potential properties to initialize */ void potential_init(const struct swift_params* parameter_file, diff --git a/src/potential/point_mass/potential.h b/src/potential/point_mass/potential.h index 7b8092d666168d3e207fe5cf94dc08b90b56e5d3..9f7533d80e713f628ebd7babe720ffd0064cea4e 100644 --- a/src/potential/point_mass/potential.h +++ b/src/potential/point_mass/potential.h @@ -143,6 +143,7 @@ external_gravity_get_potential_energy( * @param parameter_file The parsed parameter file * @param phys_const Physical constants in internal units * @param us The current internal system of units + * @param s The #space we run in. * @param potential The external potential properties to initialize */ static INLINE void potential_init_backend( diff --git a/src/runner.c b/src/runner.c index f5efc99d492be837509e50bd2674ab6923404446..3d9055183c78c3b4a3f8938a5b83091a18db8015 100644 --- a/src/runner.c +++ b/src/runner.c @@ -1231,7 +1231,9 @@ void *runner_main(void *data) { /* Get the cells. */ struct cell *ci = t->ci; struct cell *cj = t->cj; +#ifdef SWIFT_DEBUG_TASKS t->rid = r->cpuid; +#endif /* Check that we haven't scheduled an inactive task */ #ifdef SWIFT_DEBUG_CHECKS @@ -1277,7 +1279,7 @@ void *runner_main(void *data) { else if (t->subtype == task_subtype_external_grav) runner_do_grav_external(r, ci, 1); else - error("Unknown task subtype."); + error("Unknown/invalid task subtype (%d).", t->subtype); break; case task_type_pair: @@ -1292,7 +1294,7 @@ void *runner_main(void *data) { else if (t->subtype == task_subtype_grav) runner_dopair_grav(r, ci, cj, 1); else - error("Unknown task subtype."); + error("Unknown/invalid task subtype (%d).", t->subtype); break; case task_type_sub_self: @@ -1309,7 +1311,7 @@ void *runner_main(void *data) { else if (t->subtype == task_subtype_external_grav) runner_do_grav_external(r, ci, 1); else - error("Unknown task subtype."); + error("Unknown/invalid task subtype (%d).", t->subtype); break; case task_type_sub_pair: @@ -1324,7 +1326,7 @@ void *runner_main(void *data) { else if (t->subtype == task_subtype_grav) runner_dosub_grav(r, ci, cj, 1); else - error("Unknown task subtype."); + error("Unknown/invalid task subtype (%d).", t->subtype); break; case task_type_sort: @@ -1380,7 +1382,7 @@ void *runner_main(void *data) { runner_do_sourceterms(r, t->ci, 1); break; default: - error("Unknown task type."); + error("Unknown/invalid task type (%d).", t->type); } /* We're done with this task, see if we get a next one. */ diff --git a/src/scheduler.c b/src/scheduler.c index 63878040d7c62f71fd7ea0aa94ce6ec642e6ddff..77996f9657febfd82ce770ac60055bc4b48d7097 100644 --- a/src/scheduler.c +++ b/src/scheduler.c @@ -181,16 +181,19 @@ static void scheduler_splittask(struct task *t, struct scheduler *s) { ci->progeny[k], NULL, 0), s); - /* Make a task for each pair of progeny. */ - for (int j = 0; j < 8; j++) - if (ci->progeny[j] != NULL) - for (int k = j + 1; k < 8; k++) - if (ci->progeny[k] != NULL) - scheduler_splittask( - scheduler_addtask(s, task_type_pair, t->subtype, - pts[j][k], 0, ci->progeny[j], - ci->progeny[k], 0), - s); + /* Make a task for each pair of progeny unless it's ext. gravity. */ + if (t->subtype != task_subtype_external_grav) { + + for (int j = 0; j < 8; j++) + if (ci->progeny[j] != NULL) + for (int k = j + 1; k < 8; k++) + if (ci->progeny[k] != NULL) + scheduler_splittask( + scheduler_addtask(s, task_type_pair, t->subtype, + pts[j][k], 0, ci->progeny[j], + ci->progeny[k], 0), + s); + } } } @@ -709,10 +712,12 @@ struct task *scheduler_addtask(struct scheduler *s, enum task_types type, t->implicit = 0; t->weight = 0; t->rank = 0; - t->tic = 0; - t->toc = 0; t->nr_unlock_tasks = 0; +#ifdef SWIFT_DEBUG_TASKS t->rid = -1; + t->tic = 0; + t->toc = 0; +#endif /* Add an index for it. */ // lock_lock( &s->lock ); @@ -919,55 +924,56 @@ void scheduler_reweight(struct scheduler *s, int verbose) { for (int j = 0; j < t->nr_unlock_tasks; j++) if (t->unlock_tasks[j]->weight > t->weight) t->weight = t->unlock_tasks[j]->weight; - if (!t->implicit && t->tic > 0) - t->weight += wscale * (t->toc - t->tic); - else - switch (t->type) { - case task_type_sort: - t->weight += wscale * intrinsics_popcount(t->flags) * t->ci->count * - (sizeof(int) * 8 - intrinsics_clz(t->ci->count)); - break; - case task_type_self: - t->weight += 1 * wscale * t->ci->count * t->ci->count; - break; - case task_type_pair: - if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) - t->weight += + int cost = 0; + switch (t->type) { + case task_type_sort: + cost = wscale * intrinsics_popcount(t->flags) * t->ci->count * + (sizeof(int) * 8 - intrinsics_clz(t->ci->count)); + break; + case task_type_self: + cost = 1 * wscale * t->ci->count * t->ci->count; + break; + case task_type_pair: + if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) + cost = 3 * wscale * t->ci->count * t->cj->count * sid_scale[t->flags]; + else + cost = 2 * wscale * t->ci->count * t->cj->count * sid_scale[t->flags]; + break; + case task_type_sub_pair: + if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) { + if (t->flags < 0) + cost = 3 * wscale * t->ci->count * t->cj->count; + else + cost = 3 * wscale * t->ci->count * t->cj->count * sid_scale[t->flags]; + } else { + if (t->flags < 0) + cost = 2 * wscale * t->ci->count * t->cj->count; else - t->weight += + cost = 2 * wscale * t->ci->count * t->cj->count * sid_scale[t->flags]; - break; - case task_type_sub_pair: - if (t->ci->nodeID != nodeID || t->cj->nodeID != nodeID) { - if (t->flags < 0) - t->weight += 3 * wscale * t->ci->count * t->cj->count; - else - t->weight += 3 * wscale * t->ci->count * t->cj->count * - sid_scale[t->flags]; - } else { - if (t->flags < 0) - t->weight += 2 * wscale * t->ci->count * t->cj->count; - else - t->weight += 2 * wscale * t->ci->count * t->cj->count * - sid_scale[t->flags]; - } - break; - case task_type_sub_self: - t->weight += 1 * wscale * t->ci->count * t->ci->count; - break; - case task_type_ghost: - if (t->ci == t->ci->super) t->weight += wscale * t->ci->count; - break; - case task_type_kick: - t->weight += wscale * t->ci->count; - break; - case task_type_init: - t->weight += wscale * t->ci->count; - break; - default: - break; - } + } + break; + case task_type_sub_self: + cost = 1 * wscale * t->ci->count * t->ci->count; + break; + case task_type_ghost: + if (t->ci == t->ci->super) cost = wscale * t->ci->count; + break; + case task_type_kick: + cost = wscale * t->ci->count; + break; + case task_type_init: + cost = wscale * t->ci->count; + break; + default: + cost = 0; + break; + } +#if defined(WITH_MPI) && defined(HAVE_METIS) + t->cost = cost; +#endif + t->weight += cost; } if (verbose) @@ -1031,13 +1037,8 @@ void scheduler_enqueue_mapper(void *map_data, int num_elements, */ void scheduler_start(struct scheduler *s) { - /* Clear all the waits, rids, and times. */ - for (int k = 0; k < s->nr_tasks; k++) { - s->tasks[k].wait = 1; - s->tasks[k].rid = -1; - s->tasks[k].tic = 0; - s->tasks[k].toc = 0; - } + /* Clear all the waits. */ + for (int k = 0; k < s->nr_tasks; k++) s->tasks[k].wait = 1; /* Re-wait the tasks. */ threadpool_map(s->threadpool, scheduler_rewait_mapper, s->tasks, s->nr_tasks, @@ -1118,9 +1119,6 @@ void scheduler_enqueue(struct scheduler *s, struct task *t) { /* The target queue for this task. */ int qid = -1; - /* Fail if this task has already been enqueued before. */ - if (t->rid >= 0) error("Task has already been enqueued."); - /* Ignore skipped tasks */ if (t->skip) return; @@ -1245,7 +1243,9 @@ struct task *scheduler_done(struct scheduler *s, struct task *t) { /* Task definitely done, signal any sleeping runners. */ if (!t->implicit) { +#ifdef SWIFT_DEBUG_TASKS t->toc = getticks(); +#endif pthread_mutex_lock(&s->sleep_mutex); atomic_dec(&s->waiting); pthread_cond_broadcast(&s->sleep_cond); @@ -1286,7 +1286,9 @@ struct task *scheduler_unlock(struct scheduler *s, struct task *t) { /* Task definitely done. */ if (!t->implicit) { +#ifdef SWIFT_DEBUG_TASKS t->toc = getticks(); +#endif pthread_mutex_lock(&s->sleep_mutex); atomic_dec(&s->waiting); pthread_cond_broadcast(&s->sleep_cond); @@ -1369,11 +1371,13 @@ struct task *scheduler_gettask(struct scheduler *s, int qid, } } +#ifdef SWIFT_DEBUG_TASKS /* Start the timer on this task, if we got one. */ if (res != NULL) { res->tic = getticks(); res->rid = qid; } +#endif /* No milk today. */ return res; diff --git a/src/space.c b/src/space.c index e59b18795e85f77501d1245a328d8fed23bef270..a989f8c9cce4f8cd384bb8e780499d823d1c898c 100644 --- a/src/space.c +++ b/src/space.c @@ -188,10 +188,9 @@ void space_rebuild_recycle(struct space *s, struct cell *c) { * @brief Re-build the top-level cell grid. * * @param s The #space. - * @param cell_max Maximum cell edge length. * @param verbose Print messages to stdout or not. */ -void space_regrid(struct space *s, double cell_max, int verbose) { +void space_regrid(struct space *s, int verbose) { const size_t nr_parts = s->nr_parts; const ticks tic = getticks(); @@ -226,13 +225,16 @@ void space_regrid(struct space *s, double cell_max, int verbose) { h_max = buff; } #endif - if (verbose) message("h_max is %.3e (cell_max=%.3e).", h_max, cell_max); + if (verbose) message("h_max is %.3e (cell_min=%.3e).", h_max, s->cell_min); /* Get the new putative cell dimensions. */ const int cdim[3] = { - floor(s->dim[0] / fmax(h_max * kernel_gamma * space_stretch, cell_max)), - floor(s->dim[1] / fmax(h_max * kernel_gamma * space_stretch, cell_max)), - floor(s->dim[2] / fmax(h_max * kernel_gamma * space_stretch, cell_max))}; + floor(s->dim[0] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + floor(s->dim[1] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min)), + floor(s->dim[2] / + fmax(h_max * kernel_gamma * space_stretch, s->cell_min))}; /* Check if we have enough cells for periodicity. */ if (s->periodic && (cdim[0] < 3 || cdim[1] < 3 || cdim[2] < 3)) @@ -431,11 +433,10 @@ void space_regrid(struct space *s, double cell_max, int verbose) { * @brief Re-build the cells as well as the tasks. * * @param s The #space in which to update the cells. - * @param cell_max Maximal cell size. * @param verbose Print messages to stdout or not * */ -void space_rebuild(struct space *s, double cell_max, int verbose) { +void space_rebuild(struct space *s, int verbose) { const ticks tic = getticks(); @@ -443,7 +444,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) { // message("re)building space..."); fflush(stdout); /* Re-grid if necessary, or just re-set the cell data. */ - space_regrid(s, cell_max, verbose); + space_regrid(s, verbose); size_t nr_parts = s->nr_parts; size_t nr_gparts = s->nr_gparts; @@ -730,6 +731,8 @@ void space_split(struct space *s, struct cell *cells, int nr_cells, */ void space_sanitize(struct space *s) { + s->sanitized = 1; + for (int k = 0; k < s->nr_cells; k++) { struct cell *c = &s->cells_top[k]; @@ -1737,6 +1740,7 @@ void space_init(struct space *s, const struct swift_params *params, s->dim[0] = dim[0]; s->dim[1] = dim[1]; s->dim[2] = dim[2]; + s->sanitized = 0; s->periodic = periodic; s->gravity = gravity; s->nr_parts = Npart; @@ -1745,9 +1749,22 @@ void space_init(struct space *s, const struct swift_params *params, s->nr_gparts = Ngpart; s->size_gparts = Ngpart; s->gparts = gparts; - s->cell_min = parser_get_param_double(params, "SPH:max_smoothing_length"); s->nr_queues = 1; /* Temporary value until engine construction */ + /* Decide on the minimal top-level cell size */ + const double dmax = max(max(dim[0], dim[1]), dim[2]); + int maxtcells = parser_get_opt_param_int(params, + "Scheduler:max_top_level_cells", + space_max_top_level_cells_default); + s->cell_min = 0.99 * dmax / maxtcells; + + /* Check that it is big enough. */ + const double dmin = min(min(dim[0], dim[1]), dim[2]); + int needtcells = 3 * dmax / dmin; + if (maxtcells < needtcells) + error("Scheduler:max_top_level_cells is too small %d, needs to be at " + "least %d", maxtcells, needtcells); + /* Get the constants for the scheduler */ space_maxsize = parser_get_opt_param_int(params, "Scheduler:cell_max_size", space_maxsize_default); @@ -1761,14 +1778,6 @@ void space_init(struct space *s, const struct swift_params *params, message("max_size set to %d, sub_size set to %d, split_size set to %d", space_maxsize, space_subsize, space_splitsize); - /* Check that we have enough cells */ - if (s->cell_min * 3 > dim[0] || s->cell_min * 3 > dim[1] || - s->cell_min * 3 > dim[2]) - error( - "Maximal smoothing length (%e) too large. Needs to be " - "smaller than 1/3 the simulation box size [%e %e %e]", - s->cell_min, dim[0], dim[1], dim[2]); - /* Apply h scaling */ const double scaling = parser_get_opt_param_double(params, "InitialConditions:h_scaling", 1.0); @@ -1847,7 +1856,7 @@ void space_init(struct space *s, const struct swift_params *params, if (lock_init(&s->lock) != 0) error("Failed to create space spin-lock."); /* Build the cells and the tasks. */ - if (!dry_run) space_regrid(s, s->cell_min, verbose); + if (!dry_run) space_regrid(s, verbose); } /** diff --git a/src/space.h b/src/space.h index 011dfb71a6c3ac2b51093ce83bc6b65ceecc2821..975786c098dfa4d37f33e353d9678ee0cd6839e1 100644 --- a/src/space.h +++ b/src/space.h @@ -42,6 +42,7 @@ #define space_maxsize_default 8000000 #define space_subsize_default 64000000 #define space_maxcount_default 10000 +#define space_max_top_level_cells_default 12 #define space_stretch 1.10f #define space_maxreldx 0.25f @@ -122,6 +123,9 @@ struct space { /*! Number of queues in the system. */ int nr_queues; + /*! Has this space already been sanitized ? */ + int sanitized; + /*! The associated engine. */ struct engine *e; @@ -165,7 +169,7 @@ void space_parts_sort_mapper(void *map_data, int num_elements, void *extra_data); void space_gparts_sort_mapper(void *map_data, int num_elements, void *extra_data); -void space_rebuild(struct space *s, double h_max, int verbose); +void space_rebuild(struct space *s, int verbose); void space_recycle(struct space *s, struct cell *c); void space_split(struct space *s, struct cell *cells, int nr_cells, int verbose); diff --git a/src/task.h b/src/task.h index 57c198e27e03f261757daeaf36c3daf648ec8ac1..0d1befd2f337a448e8768cf629d3923e5cfc810f 100644 --- a/src/task.h +++ b/src/task.h @@ -105,9 +105,6 @@ struct task { /*! List of tasks unlocked by this one */ struct task **unlock_tasks; - /*! Start and end time of this task */ - ticks tic, toc; - #ifdef WITH_MPI /*! Buffer for this task's communications */ @@ -127,8 +124,10 @@ struct task { /*! Weight of the task */ int weight; - /*! ID of the queue or runner owning this task */ - short int rid; +#if defined(WITH_MPI) && defined(HAVE_METIS) + /*! Individual cost estimate for this task. */ + int cost; +#endif /*! Number of tasks unlocked by this one */ short int nr_unlock_tasks; @@ -151,6 +150,14 @@ struct task { /*! Is this task implicit (i.e. does not do anything) ? */ char implicit; +#ifdef SWIFT_DEBUG_TASKS + /*! ID of the queue or runner owning this task */ + short int rid; + + /*! Start and end time of this task */ + ticks tic, toc; +#endif + } SWIFT_STRUCT_ALIGN; /* Function prototypes. */ diff --git a/src/units.c b/src/units.c index 2241d441ec9af9b6d5083191e8f61010ebaccb20..05b83a3427cc40efe8a9cc3a79aa48fec4af05c1 100644 --- a/src/units.c +++ b/src/units.c @@ -320,9 +320,15 @@ void units_get_base_unit_exponants_array(float baseUnitsExp[5], case UNIT_CONV_VOLUME: baseUnitsExp[UNIT_LENGTH] = 3.f; + break; case UNIT_CONV_INV_VOLUME: baseUnitsExp[UNIT_LENGTH] = -3.f; + break; + + default: + error("Invalid choice of pre-defined units"); + break; } }