aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2012-02-27 20:31:58 -0500
committerBarry Wardell <barry.wardell@gmail.com>2012-09-11 18:23:08 +0100
commit91c6fb2a157e8357dc510dfd67d7859e55427136 (patch)
tree125d9ceb39748d47d367af8e94edf6aba1b878fb
parent194b184ec05d796b0fd836da6ef9fd898f8be14f (diff)
Carpet: Correct representation of host and model names
-rw-r--r--Carpet/Carpet/src/Hosts.cc34
-rw-r--r--Carpet/Carpet/src/MultiModel.cc28
-rw-r--r--Carpet/Carpet/src/SetupGH.cc2
-rw-r--r--Carpet/Carpet/src/functions.hh12
-rw-r--r--Carpet/Carpet/src/helpers.cc2
5 files changed, 41 insertions, 37 deletions
diff --git a/Carpet/Carpet/src/Hosts.cc b/Carpet/Carpet/src/Hosts.cc
index a9f01031c..b8243cab0 100644
--- a/Carpet/Carpet/src/Hosts.cc
+++ b/Carpet/Carpet/src/Hosts.cc
@@ -26,24 +26,24 @@ namespace Carpet
- vector <string> hosts; // Host id to host name
- std::map <string, int> host_map; // Host name to host id
- vector <int> host_ids; // Process to host id
- vector <vector <int> > host_procs; // Host id to processes
+ vector <string> host_names; // Host id to host name
+ std::map <string, int> host_map; // Host name to host id
+ vector <int> host_ids; // Process to host id
+ vector <vector <int> > host_procs; // Host id to processes
- vector <string> const & Hosts () { return hosts; }
+ vector <string> const & HostNames () { return host_names; }
std::map <string, int> const & HostMap () { return host_map; }
vector <int> const & HostIds () { return host_ids; }
vector <vector <int> > const & HostProcs () { return host_procs; }
- string Host (int const id)
+ string HostName (int const id)
{
- return hosts.at (id);
+ return host_names.AT(id);
}
- int HostMap (string const name)
+ int HostId (string const name)
{
if (host_map.find (name) != host_map.end())
{
@@ -57,12 +57,12 @@ namespace Carpet
int HostId (int const proc)
{
- return host_ids.at (proc);
+ return host_ids.AT(proc);
}
vector <int> const & HostProcs (int const id)
{
- return host_procs.at (id);
+ return host_procs.AT(id);
}
@@ -77,7 +77,7 @@ namespace Carpet
MPI_Comm_rank (dist::comm(), & my_proc);
// Gather all host names
- hosts = allgather_string (dist::comm(), host);
+ vector <string> const hosts (allgather_string (dist::comm(), host));
// Map host strings to small integers
int num_hosts = 0;
@@ -101,9 +101,10 @@ namespace Carpet
vector <int> num_host_procs (num_hosts, 0);
for (int n = 0; n < num_procs; ++ n)
{
- ++ num_host_procs.at (host_ids.AT(n));
+ ++ num_host_procs.AT(host_ids.AT(n));
}
+ host_names.resize (num_hosts);
host_procs.resize (num_hosts);
for (int m = 0; m < num_hosts; ++ m)
{
@@ -111,7 +112,8 @@ namespace Carpet
}
for (int n = 0; n < num_procs; ++ n)
{
- host_procs.at (host_ids.AT(n)).push_back (n);
+ host_names.AT(host_ids.AT(n)) = hosts.AT(n);
+ host_procs.AT(host_ids.AT(n)).push_back (n);
}
for (int m = 0; m < num_hosts; ++ m)
{
@@ -124,7 +126,7 @@ namespace Carpet
CCTK_INFO ("Host listing:");
for (int m = 0; m < num_hosts; ++ m)
{
- cout << " host " << m << ": \"" << hosts.AT(m) << "\"" << endl;
+ cout << " host " << m << ": \"" << host_names.AT(m) << "\"" << endl;
}
CCTK_INFO ("Host/process mapping:");
for (int n = 0; n < num_procs; ++ n)
@@ -147,10 +149,10 @@ namespace Carpet
// This process has the same host as the previous one:
// finish a partial line
cout << n << ": "
- << "host " << m << " \"" << hosts.AT(m) << "\"" << endl;
+ << "host " << m << " \"" << host_names.AT(m) << "\"" << endl;
} else {
cout << " process " << n << ": "
- << "host " << m << " \"" << hosts.AT(m) << "\"" << endl;
+ << "host " << m << " \"" << host_names.AT(m) << "\"" << endl;
}
}
}
diff --git a/Carpet/Carpet/src/MultiModel.cc b/Carpet/Carpet/src/MultiModel.cc
index 0de480051..cc0335bee 100644
--- a/Carpet/Carpet/src/MultiModel.cc
+++ b/Carpet/Carpet/src/MultiModel.cc
@@ -25,24 +25,24 @@ namespace Carpet
- vector <string> models; // Model id to model name
+ vector <string> model_names; // Model id to model name
std::map <string, int> model_map; // Model name to model id
vector <int> model_ids; // Process to model id
vector <vector <int> > model_procs; // Model id to processes
- vector <string> const & Models () { return models; }
+ vector <string> const & ModelNames () { return model_names; }
std::map <string, int> const & ModelMap () { return model_map; }
vector <int> const & ModelIds () { return model_ids; }
vector <vector <int> > const & ModelProcs () { return model_procs; }
- string Model (int const id)
+ string ModelName (int const id)
{
- return models.at (id);
+ return model_names.AT(id);
}
- int ModelMap (string const name)
+ int ModelId (string const name)
{
if (model_map.find (name) != model_map.end())
{
@@ -56,12 +56,12 @@ namespace Carpet
int ModelId (int const proc)
{
- return model_ids.at (proc);
+ return model_ids.AT(proc);
}
vector <int> const & ModelProcs (int const id)
{
- return model_procs.at (id);
+ return model_procs.AT(id);
}
@@ -77,7 +77,7 @@ namespace Carpet
MPI_Comm_rank (world, & my_proc);
// Gather all model names
- models = allgather_string (world, model);
+ vector <string> const models (allgather_string (world, model));
// Map model strings to small integers
int num_models = 0;
@@ -101,9 +101,10 @@ namespace Carpet
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_names.resize (num_models);
model_procs.resize (num_models);
for (int m = 0; m < num_models; ++ m)
{
@@ -111,7 +112,8 @@ namespace Carpet
}
for (int n = 0; n < num_procs; ++ n)
{
- model_procs.at (model_ids.AT(n)).push_back (n);
+ model_names.AT(model_ids.AT(n)) = models.AT(n);
+ model_procs.AT(model_ids.AT(n)).push_back (n);
}
for (int m = 0; m < num_models; ++ m)
{
@@ -127,7 +129,7 @@ namespace Carpet
CCTK_INFO ("Multi-Model listing:");
for (int m = 0; m < num_models; ++ m)
{
- cout << " model " << m << ": \"" << models.AT(m) << "\"" << endl;
+ cout << " model " << m << ": \"" << model_names.AT(m) << "\"" << endl;
}
CCTK_INFO ("Multi-Model process distribution:");
for (int n = 0; n < num_procs; ++ n)
@@ -150,10 +152,10 @@ namespace Carpet
// This process has the same model as the previous one:
// finish a partial line
cout << n << ": "
- << "model " << m << " \"" << models.AT(m) << "\"" << endl;
+ << "model " << m << " \"" << model_names.AT(m) << "\"" << endl;
} else {
cout << " process " << n << ": "
- << "model " << m << " \"" << models.AT(m) << "\"" << endl;
+ << "model " << m << " \"" << model_names.AT(m) << "\"" << endl;
}
}
}
diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc
index 7e1bebf19..48718ea59 100644
--- a/Carpet/Carpet/src/SetupGH.cc
+++ b/Carpet/Carpet/src/SetupGH.cc
@@ -318,7 +318,7 @@ namespace Carpet {
int const host_id = HostId(n);
CCTK_VInfo (CCTK_THORNSTRING,
" %6d: hid=%d (%s), pid=%d, num_threads=%d",
- n, host_id, Host(host_id).c_str(),
+ n, host_id, HostName(host_id).c_str(),
pids.AT(n), nthreads.AT(n));
}
}
diff --git a/Carpet/Carpet/src/functions.hh b/Carpet/Carpet/src/functions.hh
index 84d735723..d513d154b 100644
--- a/Carpet/Carpet/src/functions.hh
+++ b/Carpet/Carpet/src/functions.hh
@@ -58,12 +58,12 @@ namespace Carpet {
bool verbose);
// Model id to model name
- vector <string> const & Models ();
- string Model (int id);
+ vector <string> const & ModelNames ();
+ string ModelName (int id);
// Model name to model id
std::map <string, int> const & ModelMap ();
- int ModelMap (string name);
+ int ModelId (string name);
// Processor to model id
vector <int> const & ModelIds ();
@@ -81,12 +81,12 @@ namespace Carpet {
bool verbose);
// Host id to host name
- vector <string> const & Hosts ();
- string Host (int id);
+ vector <string> const & HostNames ();
+ string HostName (int id);
// Host name to host id
std::map <string, int> const & HostMap ();
- int HostMap (string name);
+ int HostId (string name);
// Processor to host id
vector <int> const & HostIds ();
diff --git a/Carpet/Carpet/src/helpers.cc b/Carpet/Carpet/src/helpers.cc
index 760558368..f2f07f12e 100644
--- a/Carpet/Carpet/src/helpers.cc
+++ b/Carpet/Carpet/src/helpers.cc
@@ -160,7 +160,7 @@ namespace Carpet {
extern "C"
CCTK_INT Carpet_nHosts(CCTK_POINTER_TO_CONST const cctkGH_)
{
- return Hosts().size();
+ return HostNames().size();
}
extern "C"