HavoqGT
havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph > Class Template Reference

#include <visitor_queue.hpp>

Collaboration diagram for havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >:

Classes

class  visitor_queue_inserter
 
struct  visitor_wrapper
 

Public Member Functions

 visitor_queue (TGraph *_graph)
 
 ~visitor_queue ()
 
void init_visitor_traversal (vertex_locator _source_v)
 
void do_visit (visitor_type &this_visitor)
 
void init_visitor_traversal ()
 
void queue_visitor (const visitor_type &v)
 

Private Types

typedef TVisitor visitor_type
 
typedef termination_detection< uint64_t > termination_detection_type
 
typedef TGraph graph_type
 
typedef TGraph::vertex_locator vertex_locator
 
typedef Queue< visitor_typelocal_queue_type
 
typedef mailbox_routed< visitor_wrappermailbox_type
 

Private Member Functions

void local_delegate_visit (const visitor_type &v)
 
void process_pending_controllers ()
 
void handle_mailbox_receive (visitor_wrapper vw)
 
void push (const visitor_type &v)
 
visitor_type pop_top ()
 
void check_mailbox ()
 
bool empty ()
 

Private Attributes

mailbox_type m_mailbox
 
termination_detection_type m_termination_detection
 
local_queue_type m_localqueue_owned
 
local_queue_type m_localqueue_delegates
 
TGraph * m_ptr_graph
 
std::queue< TVisitor > m_local_controller_queue
 

Detailed Description

template<typename TVisitor, template< typename T > class Queue, typename TGraph>
class havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >

Definition at line 68 of file visitor_queue.hpp.

Member Typedef Documentation

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef TGraph havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::graph_type
private

Definition at line 72 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef Queue<visitor_type> havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::local_queue_type
private

Definition at line 76 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef mailbox_routed<visitor_wrapper> havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::mailbox_type
private

Definition at line 91 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef termination_detection<uint64_t> havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::termination_detection_type
private

Definition at line 71 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef TGraph::vertex_locator havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::vertex_locator
private

Definition at line 73 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
typedef TVisitor havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::visitor_type
private

Definition at line 69 of file visitor_queue.hpp.

Constructor & Destructor Documentation

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::visitor_queue ( TGraph *  _graph)
inline

Definition at line 96 of file visitor_queue.hpp.

97  : m_mailbox(MPI_COMM_WORLD, 0)
98  , m_termination_detection(MPI_COMM_WORLD, 2, 2, 3, 4)
99  , m_ptr_graph(_graph) {
100  //m_localqueue_owned.reserve(_graph->num_local_vertices());
101  //m_localqueue_delegates.reserve(_graph->num_delegates() * 4);
102  }
termination_detection_type m_termination_detection
template<typename TVisitor , template< typename T > class Queue, typename TGraph >
havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::~visitor_queue ( )
inline

Definition at line 104 of file visitor_queue.hpp.

104  {
105  // if(m_mailbox.comm_rank() == 0) {
106  // std::cout << "*************** Visitor Queue Statistics *****************" << std::endl;
107  // std::cout << "m_localqueue_owned.reserve = " << m_ptr_graph->num_local_vertices() << std::endl;
108  // std::cout << "m_localqueue_owned.capacity = " << m_localqueue_owned.capacity() << std::endl;
109  // std::cout << "m_localqueue_delegates.reserve = " << 0/*m_ptr_graph->num_delegates()*/ << std::endl;
110  // std::cout << "m_localqueue_delegates.capacity = " << m_localqueue_delegates.capacity() << std::endl;
111  // std::cout << "***********************************************************" << std::endl;
112  // }
113  }

Member Function Documentation

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::check_mailbox ( )
inlineprivate

Definition at line 391 of file visitor_queue.hpp.

391  {
392  m_mailbox.receive(visitor_queue_inserter(this));
393  }
void receive(OutputIterator _oitr, bool aggregsive=false)
Definition: mailbox.hpp:364

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::do_visit ( visitor_type this_visitor)
inline

Definition at line 180 of file visitor_queue.hpp.

180  {
181  vertex_locator v = this_visitor.vertex;
182  bool ret = this_visitor.visit(*m_ptr_graph, this);
183  if(ret && v.is_delegate() && m_ptr_graph->master(v) == m_mailbox.comm_rank()) {
184  visitor_wrapper vw;
185  vw.m_visitor = this_visitor;
186  vw.set_bcast(true);
187  m_mailbox.bcast(vw, visitor_queue_inserter(this));
189  }
190  }
TGraph::vertex_locator vertex_locator
void bcast(TMsg _raw_msg, OutputIterator _oitr)
Definition: mailbox.hpp:288
termination_detection_type m_termination_detection

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
bool havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::empty ( )
inlineprivate

Definition at line 395 of file visitor_queue.hpp.

395  {
396  if(m_localqueue_owned.empty() && m_localqueue_delegates.empty()) {
397  check_mailbox();
398  }
399  return m_localqueue_owned.empty() && m_localqueue_delegates.empty();
400  }
local_queue_type m_localqueue_delegates
local_queue_type m_localqueue_owned

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::handle_mailbox_receive ( visitor_wrapper  vw)
inlineprivate

Definition at line 309 of file visitor_queue.hpp.

309  {
310  if(vw.m_visitor.vertex.is_delegate()) {
311  if(vw.m_visitor.vertex.get_bcast()) {
312  //delegate_bcast(vw.m_visitor);
313  if(m_ptr_graph->master(vw.m_visitor.vertex) == uint32_t(m_mailbox.comm_rank())) {
314  //This is because the mailbox bcast returns to self -- this should be fixed!
316  } else {
317  //vw.m_visitor.pre_visit();
318  //push(vw.m_visitor);
319  /* 2013.10.11 -- this causes too much recursion in mailbox, trying something new....
320  vw.m_visitor.visit(*m_ptr_graph, this);
321  m_termination_detection.inc_completed();
322  */
323  m_local_controller_queue.push(vw.m_visitor);
324  }
325  } else {
326  assert(m_ptr_graph->master(vw.m_visitor.vertex) == uint32_t(m_mailbox.comm_rank()));
327  if(vw.m_visitor.pre_visit()) {
328  //if(m_ptr_graph->master(vw.m_visitor.vertex) == m_mailbox.comm_rank()) {
329  //delegate_bcast(vw.m_visitor);
330  push(vw.m_visitor);
331  /* This was working, trying new way for master bcast
332  vw.set_bcast(true);
333  vw.set_intercept(false);
334  m_mailbox.bcast(vw, visitor_queue_inserter(this));
335  m_termination_detection.inc_queued(m_mailbox.comm_size());*/
336  //} else {
337  // delegate_parent(vw.m_visitor);
338  //}
339  } else {
341  }
342  }
343  } else {
344  assert(vw.m_visitor.vertex.owner() == uint32_t(m_mailbox.comm_rank()));
345  //
346  // Now handle owned vertices
347  if(vw.m_visitor.pre_visit()) {
348  push(vw.m_visitor);
349  } else {
351  }
352  }
353  }
std::queue< TVisitor > m_local_controller_queue
termination_detection_type m_termination_detection
void push(const visitor_type &v)

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::init_visitor_traversal ( vertex_locator  _source_v)
inline

Definition at line 152 of file visitor_queue.hpp.

152  {
153  if(0 /*_source_v.owner()*/ == m_mailbox.comm_rank()) {
154  queue_visitor(visitor_type(_source_v));
155  }
156  do {
157  do {
159  while(!empty()) {
161  visitor_type this_visitor = pop_top();
162  vertex_locator v = this_visitor.vertex;
163  bool ret = this_visitor.visit(*m_ptr_graph, this);
164  if(ret && v.is_delegate() && m_ptr_graph->master(v) == m_mailbox.comm_rank()) {
165  visitor_wrapper vw;
166  vw.m_visitor = this_visitor;
167  vw.set_bcast(true);
168  m_mailbox.bcast(vw, visitor_queue_inserter(this));
170  }
172  }
174  } while(!m_local_controller_queue.empty() || !m_mailbox.is_idle() );
175  sched_yield();
177  }
std::queue< TVisitor > m_local_controller_queue
TGraph::vertex_locator vertex_locator
void queue_visitor(const visitor_type &v)
void bcast(TMsg _raw_msg, OutputIterator _oitr)
Definition: mailbox.hpp:288
termination_detection_type m_termination_detection

Here is the call graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::init_visitor_traversal ( )
inline

Definition at line 192 of file visitor_queue.hpp.

192  {
193  typename TGraph::controller_iterator citr = m_ptr_graph->controller_begin();
194  for(; citr != m_ptr_graph->controller_end(); ++citr) {
195  visitor_type v(*citr);
196  if(v.pre_visit()) { //RECENTLY ADDED 2013.10.10
197  do_visit( v );
198  check_mailbox();
199  }
200  }
201  typename TGraph::vertex_iterator vitr = m_ptr_graph->vertices_begin();
202  for(; vitr != m_ptr_graph->vertices_end(); ++vitr) {
203  visitor_type v(*vitr);
204  if(v.pre_visit()) { //RECENTLY ADDED 2013.10.10
205  do_visit( v );
206  check_mailbox();
207  }
208  }
209  do {
210  do {
212  while(!empty()) {
214  visitor_type this_visitor = pop_top();
215  do_visit(this_visitor);
217  }
219  } while(!m_local_controller_queue.empty() || !m_mailbox.is_idle() );
221  }
std::queue< TVisitor > m_local_controller_queue
void do_visit(visitor_type &this_visitor)
termination_detection_type m_termination_detection

Here is the call graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::local_delegate_visit ( const visitor_type v)
inlineprivate

Definition at line 244 of file visitor_queue.hpp.

244  {
245  if(v.pre_visit()) {
246  if(m_ptr_graph->master(v.vertex) == uint32_t(m_mailbox.comm_rank())) {
247  //delegate_bcast(v);
248  push(v);
250  /* THIS was working, but trying to change how delegates are bcast from the master
251  visitor_wrapper vw;
252  vw.m_visitor = v;
253  vw.set_bcast(true);
254  m_mailbox.bcast(vw, visitor_queue_inserter(this));
255  m_termination_detection.inc_queued(m_mailbox.comm_size());*/
256  } else { //send interceptable to parent
257  visitor_wrapper vw;
258  vw.m_visitor = v;
259  vw.set_intercept(true);
260  uint32_t master_rank = m_ptr_graph->master(v.vertex);
261  vw.set_dest(master_rank);
262  m_mailbox.send(master_rank, vw, visitor_queue_inserter(this));
263  //delegate_parent(v);
265  }
266  }
267  }
void send(int raw_dest, const TMsg &_raw_msg, OutputIterator _oitr, bool fast=true)
Definition: mailbox.hpp:330
termination_detection_type m_termination_detection
void push(const visitor_type &v)

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
visitor_type havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::pop_top ( )
inlineprivate

Definition at line 364 of file visitor_queue.hpp.

364  {
365  check_mailbox();
366  visitor_type to_return;
367  assert(!(m_localqueue_delegates.empty() && m_localqueue_owned.empty()));
368 
369  /*if(m_localqueue_delegates.empty()) {
370  to_return = m_localqueue_owned.top();
371  m_localqueue_owned.pop();
372  } else {
373  if(m_localqueue_owned.empty()) {
374  to_return = m_localqueue_delegates.top();
375  m_localqueue_delegates.pop();
376  } else {
377  if(m_localqueue_delegates.top() < m_localqueue_owned.top()) {
378  to_return = m_localqueue_delegates.top();
379  m_localqueue_delegates.pop();
380  } else {
381  to_return = m_localqueue_owned.top();
382  m_localqueue_owned.pop();
383  }
384  }
385  }*/
386  to_return = m_localqueue_owned.top(); m_localqueue_owned.pop();
387  return to_return;
388  }
local_queue_type m_localqueue_delegates
local_queue_type m_localqueue_owned

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::process_pending_controllers ( )
inlineprivate

Definition at line 299 of file visitor_queue.hpp.

300  {
301  while(!m_local_controller_queue.empty()) {
302  TVisitor v = m_local_controller_queue.front();
304  v.visit(*m_ptr_graph, this);
306  }
307  }
std::queue< TVisitor > m_local_controller_queue
termination_detection_type m_termination_detection

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::push ( const visitor_type v)
inlineprivate

Definition at line 355 of file visitor_queue.hpp.

355  {
356  /*if(v.vertex.is_delegate()) {
357  m_localqueue_delegates.push(v);
358  } else {
359  m_localqueue_owned.push(v);
360  }*/
361  m_localqueue_owned.push(v);
362  }
local_queue_type m_localqueue_owned

Here is the caller graph for this function:

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
void havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::queue_visitor ( const visitor_type v)
inline

Definition at line 223 of file visitor_queue.hpp.

223  {
224  if(v.vertex.is_delegate()) {
226  } else {
227  if(v.vertex.owner() == uint32_t(m_mailbox.comm_rank())) {
228  if(v.pre_visit()) {
229  push(v);
231  }
232  } else {
233  visitor_wrapper vw;
234  //vw.m_dest = v.vertex.owner();
235  vw.m_visitor = v;
236  m_mailbox.send(v.vertex.owner(), vw, visitor_queue_inserter(this));
238  }
239  }
240  }
void local_delegate_visit(const visitor_type &v)
void send(int raw_dest, const TMsg &_raw_msg, OutputIterator _oitr, bool fast=true)
Definition: mailbox.hpp:330
termination_detection_type m_termination_detection
void push(const visitor_type &v)

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
std::queue<TVisitor> havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_local_controller_queue
private

Definition at line 439 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
local_queue_type havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_localqueue_delegates
private

Definition at line 437 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
local_queue_type havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_localqueue_owned
private

Definition at line 436 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
mailbox_type havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_mailbox
private

Definition at line 434 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
TGraph* havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_ptr_graph
private

Definition at line 438 of file visitor_queue.hpp.

template<typename TVisitor , template< typename T > class Queue, typename TGraph >
termination_detection_type havoqgt::mpi::visitor_queue< TVisitor, Queue, TGraph >::m_termination_detection
private

Definition at line 435 of file visitor_queue.hpp.


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