HavoqGT
havoqgt::environment Class Reference

Start 'new' environmet here. More...

#include <environment.hpp>

Collaboration diagram for havoqgt::environment:

Public Member Functions

 environment (int *argc, char ***argv)
 
 ~environment ()
 
const communicatorworld_comm () const
 
const communicatornode_local_comm () const
 
const communicatornode_offset_comm () const
 

Private Member Functions

MPI_Comm split_node_local_comm (MPI_Comm world_comm)
 
MPI_Comm split_node_offset_comm (MPI_Comm world_comm, MPI_Comm node_local_comm)
 
bool is_node_mapping_round_robin (MPI_Comm world_comm, MPI_Comm node_local_comm)
 
bool is_node_mapping_block (MPI_Comm world_comm, MPI_Comm node_local_comm)
 

Private Attributes

communicator m_world_comm
 
communicator m_node_local_comm
 
communicator m_node_offset_comm
 

Detailed Description

Start 'new' environmet here.

Definition at line 136 of file environment.hpp.

Constructor & Destructor Documentation

havoqgt::environment::environment ( int *  argc,
char ***  argv 
)
inline

Definition at line 138 of file environment.hpp.

138  {
139  // Init MPI
140  MPI_Init(argc, argv);
141 
142  // Create communicators
143  m_world_comm = communicator(MPI_COMM_WORLD);
144  MPI_Comm tmp_node_local_comm = split_node_local_comm(MPI_COMM_WORLD);
145  m_node_local_comm = communicator(tmp_node_local_comm);
146  MPI_Comm tmp_node_offset_comm = split_node_offset_comm(MPI_COMM_WORLD, tmp_node_local_comm);
147  m_node_offset_comm = communicator(tmp_node_offset_comm);
148  }
communicator m_node_offset_comm
MPI_Comm split_node_offset_comm(MPI_Comm world_comm, MPI_Comm node_local_comm)
communicator m_node_local_comm
MPI_Comm split_node_local_comm(MPI_Comm world_comm)
communicator m_world_comm

Here is the call graph for this function:

havoqgt::environment::~environment ( )
inline

Definition at line 150 of file environment.hpp.

150  {
152  MPI_Finalize();
153  }
void barrier() const
Definition: mpi.hpp:621
communicator m_world_comm

Here is the call graph for this function:

Member Function Documentation

bool havoqgt::environment::is_node_mapping_block ( MPI_Comm  world_comm,
MPI_Comm  node_local_comm 
)
inlineprivate

Definition at line 219 of file environment.hpp.

220  {
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);
226 
227  }
const communicator & world_comm() const
const communicator & node_local_comm() const
bool havoqgt::environment::is_node_mapping_round_robin ( MPI_Comm  world_comm,
MPI_Comm  node_local_comm 
)
inlineprivate

Definition at line 214 of file environment.hpp.

215  {
216 
217  }
const communicator& havoqgt::environment::node_local_comm ( ) const
inline

Definition at line 156 of file environment.hpp.

156 { return m_node_local_comm; }
communicator m_node_local_comm

Here is the caller graph for this function:

const communicator& havoqgt::environment::node_offset_comm ( ) const
inline

Definition at line 157 of file environment.hpp.

157 { return m_node_offset_comm; }
communicator m_node_offset_comm
MPI_Comm havoqgt::environment::split_node_local_comm ( MPI_Comm  world_comm)
inlineprivate

Definition at line 161 of file environment.hpp.

162  {
163  MPI_Comm to_return;
164  int rank;
165  MPI_Comm_rank(world_comm, &rank);
166 
167  int color = 0;
168  char* cnodeid = NULL;//getenv("SLURM_NODEID");
169  char chostname[256];
170  gethostname(chostname, 256);
171  if(cnodeid) {
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;
178  }
179 
180  int key = rank;
181  int ret = MPI_Comm_split(world_comm, color, key, &to_return);
182 
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);
186 
187  if(rank < node_local_size)
188  {
189  if(rank != node_local_rank) {
190  std::cerr << "ERROR: Only blocked task mapping is supported" << std::endl; exit(-1);
191  }
192  }
193 
194 
195 
196  return to_return;
197  }
const communicator & world_comm() const

Here is the caller graph for this function:

MPI_Comm havoqgt::environment::split_node_offset_comm ( MPI_Comm  world_comm,
MPI_Comm  node_local_comm 
)
inlineprivate

Definition at line 199 of file environment.hpp.

200  {
201  MPI_Comm to_return;
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);
205 
206  int color = node_local_rank;
207  int key = world_rank;
208 
209  int ret = MPI_Comm_split(world_comm, color, key, &to_return);
210 
211  return to_return;
212  }
const communicator & world_comm() const
const communicator & node_local_comm() const

Here is the caller graph for this function:

const communicator& havoqgt::environment::world_comm ( ) const
inline

Definition at line 155 of file environment.hpp.

155 { return m_world_comm; }
communicator m_world_comm

Here is the caller graph for this function:

Member Data Documentation

communicator havoqgt::environment::m_node_local_comm
private

Definition at line 230 of file environment.hpp.

communicator havoqgt::environment::m_node_offset_comm
private

Definition at line 231 of file environment.hpp.

communicator havoqgt::environment::m_world_comm
private

Definition at line 229 of file environment.hpp.


The documentation for this class was generated from the following file: