aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 14:59:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 14:59:00 +0000
commitf807babfa91385dd4b949704c8761b0b71940eb3 (patch)
treee5e27c58c307c5ae26689f351b823b04e995b825 /Carpet
parentbf865f82770194f0948b6223db44233efa50bce8 (diff)
Carpet: Set number of OpenMP threads
Set the number of OpenMP threads, if desired. Output all process ids at startup. darcs-hash:20080114145939-dae7b-61536ad39e398ff03795b9c6cef226f73d40721d.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/Carpet/param.ccl8
-rw-r--r--Carpet/Carpet/src/SetupGH.cc11
2 files changed, 17 insertions, 2 deletions
diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl
index 3f5b49163..c773686c4 100644
--- a/Carpet/Carpet/param.ccl
+++ b/Carpet/Carpet/param.ccl
@@ -417,6 +417,14 @@ CCTK_REAL aspect_ratio_z "Desired aspect ratio for each processor's domain" STEE
+CCTK_INT num_threads "Number of threads per process" STEERABLE=recover
+{
+ -1 :: "use system default, probably influenced by OMP_NUM_THREADS"
+ 1:* :: "use this many threads"
+} -1
+
+
+
STRING grid_structure_filename "File name to output grid structure to (empty = no output)" STEERABLE=recover
{
".*" :: "must be a legal file name"
diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc
index e90140d53..60f121426 100644
--- a/Carpet/Carpet/src/SetupGH.cc
+++ b/Carpet/Carpet/src/SetupGH.cc
@@ -196,6 +196,7 @@ namespace Carpet {
{
int const nprocs = dist::size();
int const myproc = dist::rank();
+ dist::set_num_threads (num_threads);
int const mynthreads = dist::num_threads();
int const nthreads_total = dist::total_num_threads();
CCTK_VInfo (CCTK_THORNSTRING,
@@ -217,6 +218,12 @@ namespace Carpet {
Util_GetHostName (hostnamebuf, sizeof hostnamebuf);
string const hostname (hostnamebuf);
vector <string> hostnames = AllGatherString (dist::comm(), hostname);
+ // Collect process ids
+ int const mypid = getpid ();
+ vector <int> pids (nprocs);
+ MPI_Allgather (const_cast <int *> (& mypid), 1, MPI_INT,
+ & pids.front(), 1, MPI_INT,
+ dist::comm());
// Collect number of threads
vector <int> nthreads (nprocs);
MPI_Allgather (const_cast <int *> (& mynthreads), 1, MPI_INT,
@@ -227,8 +234,8 @@ namespace Carpet {
"Running on the following hosts:");
for (int n = 0; n < nprocs; ++ n) {
CCTK_VInfo (CCTK_THORNSTRING,
- " %4d [%d]: %s",
- n, nthreads.at(n), hostnames.at(n).c_str());
+ " %4d [%d]: %s.%d",
+ n, nthreads.at(n), hostnames.at(n).c_str(), pids.at(n));
}
}
#endif