diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2009-09-03 16:19:15 -0500 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2011-12-14 16:42:31 +0000 |
commit | 11c4d98017cbb86d08e15fd1b549180184b58a26 (patch) | |
tree | 2546a154c6f7bc0bec87de7316125ae7d1453569 /Carpet/Carpet/src/MultiModel.cc | |
parent | f520477b1c14e02f1495cfa8d3e09f4e21ab34d0 (diff) |
Import Carpet
Ignore-this: 309b4dd613f4af2b84aa5d6743fdb6b3
Diffstat (limited to 'Carpet/Carpet/src/MultiModel.cc')
-rw-r--r-- | Carpet/Carpet/src/MultiModel.cc | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/Carpet/Carpet/src/MultiModel.cc b/Carpet/Carpet/src/MultiModel.cc index 975e48aec..c59eb44aa 100644 --- a/Carpet/Carpet/src/MultiModel.cc +++ b/Carpet/Carpet/src/MultiModel.cc @@ -7,9 +7,10 @@ #include <mpi.h> -#include "cctk.h" +#include <cctk.h> -#include "functions.hh" +#include <functions.hh> +#include <mpi_string.hh> @@ -22,8 +23,8 @@ namespace Carpet vector <string> models; // Model id to model name std::map <string, int> model_map; // Model name to model id - vector <int> model_ids; // Processor to model id - vector <vector <int> > model_procs; // Model id to processors + vector <int> model_ids; // Process to model id + vector <vector <int> > model_procs; // Model id to processes @@ -65,14 +66,14 @@ namespace Carpet SplitUniverse (MPI_Comm const world, string const model, MPI_Comm & comm, bool const verbose) { - // Get the total number of processors + // Get the total number of processes int num_procs; MPI_Comm_size (world, & num_procs); int my_proc; MPI_Comm_rank (world, & my_proc); // Gather all model names - models = AllGatherString (world, model); + models = allgather_string (world, model); // Map model strings to small integers int num_models = 0; @@ -80,81 +81,81 @@ namespace Carpet model_map.clear (); for (int n = 0; n < num_procs; ++ n) { - if (model_map.find (models.at(n)) != model_map.end()) + if (model_map.find (models.AT(n)) != model_map.end()) { - model_ids.at(n) = model_map[models.at(n)]; + model_ids.AT(n) = model_map[models.AT(n)]; } else { - model_map[models.at(n)] = num_models; - model_ids.at(n) = num_models; + model_map[models.AT(n)] = num_models; + model_ids.AT(n) = num_models; ++ num_models; } } - // Determine processors per model + // Determine processes per model vector <int> num_model_procs (num_models, 0); for (int n = 0; n < num_procs; ++ n) { - ++ num_model_procs.at (model_ids.at(n)); + ++ num_model_procs.at (model_ids.AT(n)); } model_procs.resize (num_models); for (int m = 0; m < num_models; ++ m) { - model_procs.at(m).reserve (num_model_procs.at(m)); + model_procs.AT(m).reserve (num_model_procs.AT(m)); } for (int n = 0; n < num_procs; ++ n) { - model_procs.at (model_ids.at(n)).push_back (n); + model_procs.at (model_ids.AT(n)).push_back (n); } for (int m = 0; m < num_models; ++ m) { - assert (static_cast<int> (model_procs.at(m).size()) - == num_model_procs.at(m)); + assert (static_cast<int> (model_procs.AT(m).size()) + == num_model_procs.AT(m)); } // Create a new communicator for each model - MPI_Comm_split (world, model_ids.at(my_proc), my_proc, & comm); + MPI_Comm_split (world, model_ids.AT(my_proc), my_proc, & comm); if (verbose) { CCTK_INFO ("Multi-Model listing:"); for (int m = 0; m < num_models; ++ m) { - cout << " model " << m << ": \"" << models.at(m) << "\"" << endl; + cout << " model " << m << ": \"" << models.AT(m) << "\"" << endl; } - CCTK_INFO ("Multi-Model processor distribution:"); + CCTK_INFO ("Multi-Model process distribution:"); for (int n = 0; n < num_procs; ++ n) { - int const m = model_ids.at(n); + int const m = model_ids.AT(n); bool const same_model_as_prev = - n-1 >= 0 and model_ids.at(n-1) == m; + n-1 >= 0 and model_ids.AT(n-1) == m; bool const same_model_as_next = - n+1 < num_procs and model_ids.at(n+1) == m; + n+1 < num_procs and model_ids.AT(n+1) == m; if (same_model_as_next) { if (same_model_as_prev) { // Output nothing } else { - // This processor has the same model as the next one: + // This process has the same model as the next one: // output only a partial line - cout << " processors " << n << "-"; + cout << " processes " << n << "-"; } } else { if (same_model_as_prev) { - // This processor has the same model as the previous one: + // This process has the same model as the previous one: // finish a partial line cout << n << ": " - << "model " << m << " \"" << models.at(m) << "\"" << endl; + << "model " << m << " \"" << models.AT(m) << "\"" << endl; } else { - cout << " processor " << n << ": " - << "model " << m << " \"" << models.at(m) << "\"" << endl; + cout << " process " << n << ": " + << "model " << m << " \"" << models.AT(m) << "\"" << endl; } } } - int const my_model = model_ids.at(my_proc); + int const my_model = model_ids.AT(my_proc); CCTK_VInfo (CCTK_THORNSTRING, - "Multi-Model: This is processor %d, model %d \"%s\"", + "Multi-Model: This is process %d, model %d \"%s\"", my_proc, my_model, model.c_str()); } } |