Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
GaudiMP.pTools.Syncer Class Reference
Inheritance diagram for GaudiMP.pTools.Syncer:
Inheritance graph
[legend]
Collaboration diagram for GaudiMP.pTools.Syncer:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def syncAll
 
def syncAllRolling
 
def processHang
 
def checkAll
 
def checkLastEvents
 

Public Attributes

 limit
 
 step
 
 d
 
 manyEvents
 
 limitFirst
 
 keys
 
 nWorkers
 
 log
 

Detailed Description

Definition at line 564 of file pTools.py.

Constructor & Destructor Documentation

def GaudiMP.pTools.Syncer.__init__ (   self,
  nWorkers,
  log,
  manyEvents = False,
  limit = None,
  step = None,
  firstEvent = None 
)

Definition at line 566 of file pTools.py.

567  limit=None, step=None, firstEvent=None ) :
568  # Class to help synchronise the sub-processes
569  self.limit = limit
570  self.step = step
571  self.d = {}
572  self.manyEvents = manyEvents
573  for i in xrange(-2, nWorkers) :
574  self.d[ i ] = SyncMini( Event(), lastEvent=Event() )
575  if self.manyEvents :
576  self.limitFirst = firstEvent
577  self.keys = self.d.keys()
578  self.nWorkers = nWorkers
579  self.log = log

Member Function Documentation

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 669 of file pTools.py.

670  def checkAll( self ) :
671  # Check the status of each Sync object
672  # return True or False
673  currentStatus = [ mini.check() for mini in self.d.values() ]
674  return all( currentStatus )
def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 675 of file pTools.py.

676  def checkLastEvents( self ) :
677  # check if all of the lastEvents are set to true in self.d[k][1]
678  stat = [ sMini.checkLast() for sMini in self.d.values() ]
679  return all(stat)
680 
681 # =========================== Methods =========================================
def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 663 of file pTools.py.

664  def processHang( self ) :
665  self.log.critical('Some proc is hanging during Event processing!')
666  for k in self.keys :
667  self.log.critical( "Proc/Stat : %i / %s"%(k,self.d[k].check()) )
668  return
def GaudiMP.pTools.Syncer.syncAll (   self,
  step = "Not specified" 
)

Definition at line 580 of file pTools.py.

581  def syncAll( self, step="Not specified" ) :
582  # is it this method, or is it the rolling version needed?
583  # if so, drop through...
584 
585  if self.manyEvents :
586  sc = self.syncAllRolling( )
587  return sc
588 
589  # Regular version ----------------------------
590  for i in xrange( 0, self.limit, self.step ) :
591  if self.checkAll( ) :
592  self.log.info('%s : All procs done @ %i s'%(step,i))
593  break
594  else :
595  time.sleep(self.step)
596 
597  # Now the time limit is up... check the status one final time
598  if self.checkAll() :
599  self.log.info("All processes : %s ok."%(step))
600  return SUCCESS
601  else :
602  self.log.critical('Some process is hanging on : %s'%(step))
603  for k in self.keys :
604  hangString= "%s : Proc/Stat : %i/%s"%(step,k,self.d[k].check())
605  self.log.critical( hangString )
606  return FAILURE
def GaudiMP.pTools.Syncer.syncAllRolling (   self)

Definition at line 607 of file pTools.py.

608  def syncAllRolling( self ) :
609  # Keep track of the progress of Event processing
610  # Each process syncs after each event, so keep clearing
611  # the sync Event, and re-checking
612  # Note the time between True checks too, if the time
613  # between events exceeds singleEvent, this is considered a hang
614 
615  # set the initial time
616  begin = time.time()
617  firstEv = {}
618  timers = {}
619  for k in self.keys :
620  self.d[k].reset()
621  firstEv[k] = False
622  timers[k] = 0.0
623 
624  active = self.keys
625  while True :
626  # check the status of each sync object
627  for k in active :
628  sMini = self.d[k]
629 
630  if sMini.check() or sMini.checkLast():
631  if sMini.checkLast() and sMini.check() :
632  # if last Event set,then event loop finished
633  active.remove( k )
634  alive = time.time()-begin
635  self.log.info( "Audit : Node %i alive for %5.2f"\
636  %(k,alive) )
637  else :
638  sMini.reset()
639  else :
640  # the event still has not been checked, how long is that?
641  # is it the first Event?
642  wait = time.time()-sMini.getTime()
643  cond = wait > self.limit
644  if not firstEv[k] :
645  cond = wait > self.limitFirst
646  firstEv[k] = True
647  if cond :
648  # It is hanging!
649  self.log.critical('Single event wait : %5.2f'%(wait))
650  self.processHang()
651  return FAILURE
652 
653  # Termination Criteria : if all procs have been removed, we're done
654  if self.checkLastEvents() :
655  self.log.info('TC met for event loop')
656  break
657  else :
658  # sleep, loop again
659  time.sleep(self.step)
660 
661  self.log.info("All processes Completed all Events ok")
662  return SUCCESS

Member Data Documentation

GaudiMP.pTools.Syncer.d

Definition at line 570 of file pTools.py.

GaudiMP.pTools.Syncer.keys

Definition at line 576 of file pTools.py.

GaudiMP.pTools.Syncer.limit

Definition at line 568 of file pTools.py.

GaudiMP.pTools.Syncer.limitFirst

Definition at line 575 of file pTools.py.

GaudiMP.pTools.Syncer.log

Definition at line 578 of file pTools.py.

GaudiMP.pTools.Syncer.manyEvents

Definition at line 571 of file pTools.py.

GaudiMP.pTools.Syncer.nWorkers

Definition at line 577 of file pTools.py.

GaudiMP.pTools.Syncer.step

Definition at line 569 of file pTools.py.


The documentation for this class was generated from the following file:
Generated at Wed Nov 28 2012 12:17:39 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004