52 #ifndef HAVOQGT_ENVIRONMENT_HPP_INCLUDED
53 #define HAVOQGT_ENVIRONMENT_HPP_INCLUDED
59 #include <boost/lexical_cast.hpp>
86 inline T
get_env_var(
const char* key, T default_val)
const;
107 template <
typename T>
111 char* val = std::getenv( key );
114 default_val = boost::lexical_cast<T>(val);
116 std::stringstream err;
117 err <<
"havoqgt::environment -- Unable to parse environment variable: "
118 << key <<
"=" << val << std::endl;
119 throw std::runtime_error(err.str());
140 MPI_Init(argc, argv);
165 MPI_Comm_rank(world_comm, &rank);
168 char* cnodeid = NULL;
170 gethostname(chostname, 256);
172 color = boost::lexical_cast<
int>(cnodeid);
173 }
else if(chostname) {
174 std::string shostname(chostname);
175 std::hash<std::string> hasher;
176 color = hasher(shostname);
177 if(color < 0) color *= -1;
181 int ret = MPI_Comm_split(world_comm, color, key, &to_return);
183 int node_local_rank, node_local_size;
184 MPI_Comm_rank(to_return, &node_local_rank);
185 MPI_Comm_size(to_return, &node_local_size);
187 if(rank < node_local_size)
189 if(rank != node_local_rank) {
190 std::cerr <<
"ERROR: Only blocked task mapping is supported" << std::endl; exit(-1);
202 int world_rank, node_local_rank;
203 MPI_Comm_rank(world_comm, &world_rank);
204 MPI_Comm_rank(node_local_comm, &node_local_rank);
206 int color = node_local_rank;
207 int key = world_rank;
209 int ret = MPI_Comm_split(world_comm, color, key, &to_return);
221 int world_rank, world_size, node_local_rank, node_local_size;
222 MPI_Comm_rank(world_comm, &world_rank);
223 MPI_Comm_size(world_comm, &world_size);
224 MPI_Comm_rank(node_local_comm, &node_local_rank);
225 MPI_Comm_size(node_local_comm, &node_local_size);
bool is_node_mapping_round_robin(MPI_Comm world_comm, MPI_Comm node_local_comm)
communicator m_node_offset_comm
MPI_Comm split_node_offset_comm(MPI_Comm world_comm, MPI_Comm node_local_comm)
bool is_node_mapping_block(MPI_Comm world_comm, MPI_Comm node_local_comm)
Start 'new' environmet here.
uint32_t mailbox_num_irecv() const
communicator m_node_local_comm
const communicator & world_comm() const
uint32_t mailbox_aggregation() const
MPI_Comm split_node_local_comm(MPI_Comm world_comm)
environment(int *argc, char ***argv)
bool mailbox_print_stats() const
environment * havoqgt_env()
communicator m_world_comm
uint32_t m_mailbox_tree_aggregation
uint32_t mailbox_num_isend() const
old_environment & get_environment()
uint32_t m_mailbox_aggregation
const communicator & node_local_comm() const
bool m_mailbox_print_stats
const communicator & node_offset_comm() const
environment *& priv_havoqgt_env()
uint32_t m_mailbox_num_irecv
uint32_t m_mailbox_num_isend
T get_env_var(const char *key, T default_val) const
void havoqgt_init(int *argc, char ***argv)
uint32_t mailbox_tree_aggregation() const