diff --git a/README b/README index 0c57e3f5656268c71bb7732af933302cbde9547b..59c362415a9199d08fb6dfbb1ed044c66e647254 100644 --- a/README +++ b/README @@ -23,6 +23,7 @@ Valid options are: -g Run with an external gravitational potential -G Run with self-gravity -s Run with SPH + -t {int} The number of threads to use on each MPI rank. Defaults to 1 if not specified. -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 diff --git a/examples/CosmoVolume/cosmoVolume.yml b/examples/CosmoVolume/cosmoVolume.yml index 20d5febb280748a208633f75351d523b79286035..2da45221043187402bb42028f4d03723cbb26688 100644 --- a/examples/CosmoVolume/cosmoVolume.yml +++ b/examples/CosmoVolume/cosmoVolume.yml @@ -9,7 +9,6 @@ UnitSystem: # 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). diff --git a/examples/CosmoVolume/run.sh b/examples/CosmoVolume/run.sh index a788a35c76a7c0b205297a7de922a9a7e833243a..412456c3cb1ae9b869afa52b1046747e32c2eefe 100755 --- a/examples/CosmoVolume/run.sh +++ b/examples/CosmoVolume/run.sh @@ -7,4 +7,4 @@ then ./getIC.sh fi -../swift -s cosmoVolume.yml +../swift -s -t 16 cosmoVolume.yml diff --git a/examples/SedovBlast/run.sh b/examples/SedovBlast/run.sh index 58646cf42eecc3f31fdb8a63ca2108c02d9580ba..f71830eb6a66a9ea84e93fd1bed1261b1cb42b7b 100755 --- a/examples/SedovBlast/run.sh +++ b/examples/SedovBlast/run.sh @@ -7,4 +7,4 @@ then python makeIC_fcc.py fi -../swift -s sedov.yml +../swift -s -t 16 sedov.yml diff --git a/examples/SedovBlast/sedov.yml b/examples/SedovBlast/sedov.yml index f354ef5679eb5b6176ab90298bb307c6c2b27f0e..55974b03b823befde8365cddab187f5a18c5bbb7 100644 --- a/examples/SedovBlast/sedov.yml +++ b/examples/SedovBlast/sedov.yml @@ -9,7 +9,6 @@ UnitSystem: # 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). diff --git a/examples/SodShock/run.sh b/examples/SodShock/run.sh index 646f1e3a337170e2e406c24e7505e42b81de364b..b8141e51543f348d6ec6be505d136aed7d803b2e 100755 --- a/examples/SodShock/run.sh +++ b/examples/SodShock/run.sh @@ -7,4 +7,4 @@ then python makeIC.py fi -../swift -s sodShock.yml +../swift -s -t 16 sodShock.yml diff --git a/examples/SodShock/sodShock.yml b/examples/SodShock/sodShock.yml index 5fe7be7b9fc13bb5bc67556d79d8ff9d9eff81d9..ab43d6682b2a16304d364784efee530ad5289cef 100644 --- a/examples/SodShock/sodShock.yml +++ b/examples/SodShock/sodShock.yml @@ -9,7 +9,6 @@ UnitSystem: # 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. diff --git a/examples/UniformBox/run.sh b/examples/UniformBox/run.sh index ca78b0ac0425bf1b3f6dd9d30bfc95d35083739f..0cb0a505915be47bafb99ed7531685bfeb3dc829 100755 --- a/examples/UniformBox/run.sh +++ b/examples/UniformBox/run.sh @@ -7,4 +7,4 @@ then python makeIC.py 100 fi -../swift -s uniformBox.yml +../swift -s -t 16 uniformBox.yml diff --git a/examples/UniformBox/uniformBox.yml b/examples/UniformBox/uniformBox.yml index 2d5512815b60511b5dbc373df43fae4658272093..0474b0f8202effa73210ee2b459806f2376a37f2 100644 --- a/examples/UniformBox/uniformBox.yml +++ b/examples/UniformBox/uniformBox.yml @@ -9,7 +9,6 @@ UnitSystem: # 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). diff --git a/examples/main.c b/examples/main.c index 5cfae5efba9157ba7b727115b03ac467287edc3d..9c98eaf1da6eaacd8ccd31b9b8d8dc6cde6b6f9c 100644 --- a/examples/main.c +++ b/examples/main.c @@ -67,6 +67,9 @@ void print_help_message() { "Run with an external gravitational potential"); printf(" %2s %8s %s\n", "-G", "", "Run with self-gravity"); printf(" %2s %8s %s\n", "-s", "", "Run with SPH"); + printf(" %2s %8s %s\n", "-t", "{int}", + "The number of threads to use on each MPI rank. Defaults to 1 if not " + "specified."); printf(" %2s %8s %s\n", "-v", "[12]", "Increase the level of verbosity 1: MPI-rank 0 writes "); printf(" %2s %8s %s\n", "", "", "2: All MPI-ranks write"); @@ -141,12 +144,13 @@ int main(int argc, char *argv[]) { int with_hydro = 0; int with_fp_exceptions = 0; int verbose = 0; + int nr_threads = 1; char paramFileName[200] = ""; unsigned long long cpufreq = 0; /* Parse the parameters */ int c; - while ((c = getopt(argc, argv, "cdef:gGhsv:y")) != -1) switch (c) { + while ((c = getopt(argc, argv, "cdef:gGhst:v:y")) != -1) switch (c) { case 'c': with_cosmology = 1; break; @@ -175,6 +179,15 @@ int main(int argc, char *argv[]) { case 's': with_hydro = 1; break; + case 't': + if (sscanf(optarg, "%d", &nr_threads) != 1) { + if (myrank == 0) + printf("Error parsing the number of threads (-t).\n"); + if (myrank == 0) print_help_message(); + return 1; + } + with_hydro = 1; + break; case 'v': if (sscanf(optarg, "%d", &verbose) != 1) { if (myrank == 0) printf("Error parsing verbosity level (-v).\n"); @@ -383,7 +396,8 @@ int main(int argc, char *argv[]) { /* Initialize the engine with the space and policies. */ if (myrank == 0) clocks_gettime(&tic); struct engine e; - engine_init(&e, &s, params, nr_nodes, myrank, engine_policies, talking); + engine_init(&e, &s, params, nr_nodes, myrank, nr_threads, engine_policies, + talking); if (myrank == 0) { clocks_gettime(&toc); message("engine_init took %.3f %s.", clocks_diff(&tic, &toc), diff --git a/examples/parameter_example.yml b/examples/parameter_example.yml index b91e99baf383a399b72bfb73f1791ab7ac6f3d91..e3cd5b209c9d36f9774364a661b77f3d649c398e 100644 --- a/examples/parameter_example.yml +++ b/examples/parameter_example.yml @@ -9,7 +9,6 @@ UnitSystem: # 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). diff --git a/src/engine.c b/src/engine.c index 5e6097981119e6501084335bf966641fabf49db3..7287f47b40b06a691c778a5f8d3b6c0f04721564 100644 --- a/src/engine.c +++ b/src/engine.c @@ -2323,20 +2323,21 @@ static bool hyperthreads_present(void) { * @param params The parsed parameter file. * @param nr_nodes The number of MPI ranks. * @param nodeID The MPI rank of this node. + * @param nr_threads The number of threads per MPI rank. * @param policy The queuing policy to use. * @param verbose Is this #engine talkative ? */ void engine_init(struct engine *e, struct space *s, const struct swift_params *params, int nr_nodes, int nodeID, - int policy, int verbose) { + int nr_threads, int policy, int verbose) { /* Clean-up everything */ bzero(e, sizeof(struct engine)); /* Store the values. */ e->s = s; - e->nr_threads = parser_get_param_int(params, "Scheduler:nr_threads"); + e->nr_threads = nr_threads; e->policy = policy; e->step = 0; e->nr_nodes = nr_nodes; diff --git a/src/engine.h b/src/engine.h index e1c3f61d1293fc01e24b9bcb0673d75fa3ce4648..c8b9d7a46f8c788237e3b9ba7cb9d7d0a6e1370d 100644 --- a/src/engine.h +++ b/src/engine.h @@ -170,7 +170,7 @@ struct engine { void engine_barrier(struct engine *e, int tid); void engine_init(struct engine *e, struct space *s, const struct swift_params *params, int nr_nodes, int nodeID, - int policy, int verbose); + int nr_threads, int policy, int verbose); void engine_launch(struct engine *e, int nr_runners, unsigned int mask, unsigned int submask); void engine_prepare(struct engine *e);