Commit 622ad2b6 authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'number_threads_as_command_line' into 'master'

Made the number of threads a command-line parameter again.

I have restored the `-t` command-line parameter and removed the parameter from all the yaml files. I have also updated the run.sh scripts with a default value of 16. 

That fixes #144 and the branch can be removed if you are happy with the changes. Thanks !

See merge request !144
parents ce5e778a 765f10a5
......@@ -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
......
......@@ -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).
......
......@@ -7,4 +7,4 @@ then
./getIC.sh
fi
../swift -s cosmoVolume.yml
../swift -s -t 16 cosmoVolume.yml
......@@ -7,4 +7,4 @@ then
python makeIC_fcc.py
fi
../swift -s sedov.yml
../swift -s -t 16 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).
......
......@@ -7,4 +7,4 @@ then
python makeIC.py
fi
../swift -s sodShock.yml
../swift -s -t 16 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.
......
......@@ -7,4 +7,4 @@ then
python makeIC.py 100
fi
../swift -s uniformBox.yml
../swift -s -t 16 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).
......
......@@ -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,14 @@ 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;
}
break;
case 'v':
if (sscanf(optarg, "%d", &verbose) != 1) {
if (myrank == 0) printf("Error parsing verbosity level (-v).\n");
......@@ -383,7 +395,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),
......
......@@ -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).
......
......@@ -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;
......
......@@ -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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment