Commit 354bc99a authored by Peter W. Draper's avatar Peter W. Draper
Browse files

Merge branch 'master' into GravityParticles

Conflicts:
	examples/main.c
	src/engine.c
	src/engine.h

Use of threads as command-line option.
parents c0aa3063 622ad2b6
...@@ -23,6 +23,7 @@ Valid options are: ...@@ -23,6 +23,7 @@ Valid options are:
-g Run with an external gravitational potential -g Run with an external gravitational potential
-G Run with self-gravity -G Run with self-gravity
-s Run with SPH -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 -v [12] Increase the level of verbosity 1: MPI-rank 0 writes
2: All MPI-ranks write 2: All MPI-ranks write
-y {int} Time-step frequency at which task graphs are dumped -y {int} Time-step frequency at which task graphs are dumped
......
...@@ -9,7 +9,6 @@ UnitSystem: ...@@ -9,7 +9,6 @@ UnitSystem:
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: 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. 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_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_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
......
...@@ -7,4 +7,4 @@ then ...@@ -7,4 +7,4 @@ then
./getIC.sh ./getIC.sh
fi fi
../swift -s cosmoVolume.yml ../swift -s -t 16 cosmoVolume.yml
...@@ -7,4 +7,4 @@ then ...@@ -7,4 +7,4 @@ then
python makeIC_fcc.py python makeIC_fcc.py
fi fi
../swift -s sedov.yml ../swift -s -t 16 sedov.yml
...@@ -9,7 +9,6 @@ UnitSystem: ...@@ -9,7 +9,6 @@ UnitSystem:
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: 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. 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_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_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
......
...@@ -7,4 +7,4 @@ then ...@@ -7,4 +7,4 @@ then
python makeIC.py python makeIC.py
fi fi
../swift -s sodShock.yml ../swift -s -t 16 sodShock.yml
...@@ -9,7 +9,6 @@ UnitSystem: ...@@ -9,7 +9,6 @@ UnitSystem:
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: 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. 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_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_sub_size: 5000 # Maximal number of interactions per sub-task.
......
...@@ -7,4 +7,4 @@ then ...@@ -7,4 +7,4 @@ then
python makeIC.py 100 python makeIC.py 100
fi fi
../swift -s uniformBox.yml ../swift -s -t 16 uniformBox.yml
...@@ -9,7 +9,6 @@ UnitSystem: ...@@ -9,7 +9,6 @@ UnitSystem:
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: 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. 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_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_sub_size: 5000 # Maximal number of interactions per sub-task (this is the default value).
......
...@@ -70,6 +70,9 @@ void print_help_message() { ...@@ -70,6 +70,9 @@ void print_help_message() {
"Run with an external gravitational potential"); "Run with an external gravitational potential");
printf(" %2s %8s %s\n", "-G", "", "Run with self-gravity"); printf(" %2s %8s %s\n", "-G", "", "Run with self-gravity");
printf(" %2s %8s %s\n", "-s", "", "Run with SPH"); 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]", printf(" %2s %8s %s\n", "-v", "[12]",
"Increase the level of verbosity 1: MPI-rank 0 writes "); "Increase the level of verbosity 1: MPI-rank 0 writes ");
printf(" %2s %8s %s\n", "", "", "2: All MPI-ranks write"); printf(" %2s %8s %s\n", "", "", "2: All MPI-ranks write");
...@@ -144,12 +147,13 @@ int main(int argc, char *argv[]) { ...@@ -144,12 +147,13 @@ int main(int argc, char *argv[]) {
int with_hydro = 0; int with_hydro = 0;
int with_fp_exceptions = 0; int with_fp_exceptions = 0;
int verbose = 0; int verbose = 0;
int nr_threads = 1;
char paramFileName[200] = ""; char paramFileName[200] = "";
unsigned long long cpufreq = 0; unsigned long long cpufreq = 0;
/* Parse the parameters */ /* Parse the parameters */
int c; 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': case 'c':
with_cosmology = 1; with_cosmology = 1;
break; break;
...@@ -178,6 +182,14 @@ int main(int argc, char *argv[]) { ...@@ -178,6 +182,14 @@ int main(int argc, char *argv[]) {
case 's': case 's':
with_hydro = 1; with_hydro = 1;
break; 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': case 'v':
if (sscanf(optarg, "%d", &verbose) != 1) { if (sscanf(optarg, "%d", &verbose) != 1) {
if (myrank == 0) printf("Error parsing verbosity level (-v).\n"); if (myrank == 0) printf("Error parsing verbosity level (-v).\n");
...@@ -394,8 +406,8 @@ int main(int argc, char *argv[]) { ...@@ -394,8 +406,8 @@ int main(int argc, char *argv[]) {
/* Initialize the engine with the space and policies. */ /* Initialize the engine with the space and policies. */
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
struct engine e; 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,
&prog_const, &potential); talking, &prog_const, &potential);
if (myrank == 0) { if (myrank == 0) {
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),
......
...@@ -9,7 +9,6 @@ UnitSystem: ...@@ -9,7 +9,6 @@ UnitSystem:
# Parameters for the task scheduling # Parameters for the task scheduling
Scheduler: 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. 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_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_sub_size: 8000000 # Maximal number of interactions per sub-task (this is the default value).
......
...@@ -2324,6 +2324,7 @@ static bool hyperthreads_present(void) { ...@@ -2324,6 +2324,7 @@ static bool hyperthreads_present(void) {
* @param params The parsed parameter file. * @param params The parsed parameter file.
* @param nr_nodes The number of MPI ranks. * @param nr_nodes The number of MPI ranks.
* @param nodeID The MPI rank of this node. * @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 policy The queuing policy to use.
* @param verbose Is this #engine talkative ? * @param verbose Is this #engine talkative ?
* @param physical_constants The #phys_const used for this run. * @param physical_constants The #phys_const used for this run.
...@@ -2332,7 +2333,7 @@ static bool hyperthreads_present(void) { ...@@ -2332,7 +2333,7 @@ static bool hyperthreads_present(void) {
void engine_init(struct engine *e, struct space *s, void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID, const struct swift_params *params, int nr_nodes, int nodeID,
int policy, int verbose, int nr_threads, int policy, int verbose,
const struct phys_const *physical_constants, const struct phys_const *physical_constants,
const struct external_potential *potential) { const struct external_potential *potential) {
...@@ -2341,7 +2342,7 @@ void engine_init(struct engine *e, struct space *s, ...@@ -2341,7 +2342,7 @@ void engine_init(struct engine *e, struct space *s,
/* Store the values. */ /* Store the values. */
e->s = s; e->s = s;
e->nr_threads = parser_get_param_int(params, "Scheduler:nr_threads"); e->nr_threads = nr_threads;
e->policy = policy; e->policy = policy;
e->step = 0; e->step = 0;
e->nr_nodes = nr_nodes; e->nr_nodes = nr_nodes;
......
...@@ -183,7 +183,7 @@ struct engine { ...@@ -183,7 +183,7 @@ struct engine {
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, void engine_init(struct engine *e, struct space *s,
const struct swift_params *params, int nr_nodes, int nodeID, const struct swift_params *params, int nr_nodes, int nodeID,
int policy, int verbose, int nr_threads, int policy, int verbose,
const struct phys_const *physical_constants, const struct phys_const *physical_constants,
const struct external_potential *potential); const struct external_potential *potential);
void engine_launch(struct engine *e, int nr_runners, unsigned int mask, void engine_launch(struct engine *e, int nr_runners, unsigned int mask,
......
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