diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-01-14 14:59:00 +0000 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2008-01-14 14:59:00 +0000 |
commit | 5efeed6cad5bc6045cf1c54215a4274153963a17 (patch) | |
tree | e5e27c58c307c5ae26689f351b823b04e995b825 | |
parent | 4c898678af3ecb97aec8bfb27d1d82be227f4ac9 (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
-rw-r--r-- | Carpet/Carpet/param.ccl | 8 | ||||
-rw-r--r-- | Carpet/Carpet/src/SetupGH.cc | 11 |
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 |