The Gaudi Framework  v36r1 (3e2fb5a8)
GaudiMP.pTools.Syncer Class Reference
Inheritance diagram for GaudiMP.pTools.Syncer:
Collaboration diagram for GaudiMP.pTools.Syncer:

Public Member Functions

def __init__ (self, nWorkers, log, manyEvents=False, limit=None, step=None, firstEvent=None)
 
def syncAll (self, step="Not specified")
 
def syncAllRolling (self)
 
def processHang (self)
 
def checkAll (self)
 
def checkLastEvents (self)
 

Public Attributes

 limit
 
 step
 
 d
 
 manyEvents
 
 limitFirst
 
 keys
 
 nWorkers
 
 log
 

Detailed Description

Definition at line 601 of file pTools.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 602 of file pTools.py.

602  def __init__(self,
603  nWorkers,
604  log,
605  manyEvents=False,
606  limit=None,
607  step=None,
608  firstEvent=None):
609  # Class to help synchronise the sub-processes
610  self.limit = limit
611  self.step = step
612  self.d = {}
613  self.manyEvents = manyEvents
614 
615  for i in range(-2, nWorkers):
616  self.d[i] = SyncMini(Event(), lastEvent=Event())
617  if self.manyEvents:
618  self.limitFirst = firstEvent
619 
620  self.keys = self.d.keys()
621  self.nWorkers = nWorkers
622  self.log = log
623 

Member Function Documentation

◆ checkAll()

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 714 of file pTools.py.

714  def checkAll(self):
715  # Check the status of each Sync object
716  # return True or False
717  currentStatus = [mini.check() for mini in self.d.values()]
718  return all(currentStatus)
719 

◆ checkLastEvents()

def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 720 of file pTools.py.

720  def checkLastEvents(self):
721  # check if all of the lastEvents are set to true in self.d[k][1]
722  stat = [sMini.checkLast() for sMini in self.d.values()]
723  return all(stat)
724 
725 
726 # =========================== Methods =========================================
727 
728 

◆ processHang()

def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 708 of file pTools.py.

708  def processHang(self):
709  self.log.critical('Some proc is hanging during Event processing!')
710  for k in self.keys:
711  self.log.critical("Proc/Stat : %i / %s" % (k, self.d[k].check()))
712  return
713 

◆ syncAll()

def GaudiMP.pTools.Syncer.syncAll (   self,
  step = "Not specified" 
)

Definition at line 624 of file pTools.py.

624  def syncAll(self, step="Not specified"):
625  # is it this method, or is it the rolling version needed?
626  # if so, drop through...
627 
628  if self.manyEvents:
629  sc = self.syncAllRolling()
630  return sc
631 
632  # Regular version ----------------------------
633  for i in range(0, self.limit, self.step):
634  if self.checkAll():
635  self.log.info('%s : All procs done @ %i s' % (step, i))
636  break
637  else:
638  time.sleep(self.step)
639 
640  # Now the time limit is up... check the status one final time
641  if self.checkAll():
642  self.log.info("All processes : %s ok." % (step))
643  return SUCCESS
644  else:
645  self.log.critical('Some process is hanging on : %s' % (step))
646  for k in self.keys:
647  hangString = "%s : Proc/Stat : %i/%s" % (step, k,
648  self.d[k].check())
649  self.log.critical(hangString)
650  return FAILURE
651 

◆ syncAllRolling()

def GaudiMP.pTools.Syncer.syncAllRolling (   self)

Definition at line 652 of file pTools.py.

652  def syncAllRolling(self):
653  # Keep track of the progress of Event processing
654  # Each process syncs after each event, so keep clearing
655  # the sync Event, and re-checking
656  # Note the time between True checks too, if the time
657  # between events exceeds singleEvent, this is considered a hang
658 
659  # set the initial time
660  begin = time.time()
661  firstEv = {}
662  timers = {}
663  for k in self.keys:
664  self.d[k].reset()
665  firstEv[k] = False
666  timers[k] = 0.0
667 
668  active = self.keys
669  while True:
670  # check the status of each sync object
671  for k in active:
672  sMini = self.d[k]
673 
674  if sMini.check() or sMini.checkLast():
675  if sMini.checkLast() and sMini.check():
676  # if last Event set,then event loop finished
677  active.remove(k)
678  alive = time.time() - begin
679  self.log.info(
680  "Audit : Node %i alive for %5.2f" % (k, alive))
681  else:
682  sMini.reset()
683  else:
684  # the event still has not been checked, how long is that?
685  # is it the first Event?
686  wait = time.time() - sMini.getTime()
687  cond = wait > self.limit
688  if not firstEv[k]:
689  cond = wait > self.limitFirst
690  firstEv[k] = True
691  if cond:
692  # It is hanging!
693  self.log.critical('Single event wait : %5.2f' % (wait))
694  self.processHang()
695  return FAILURE
696 
697  # Termination Criteria : if all procs have been removed, we're done
698  if self.checkLastEvents():
699  self.log.info('TC met for event loop')
700  break
701  else:
702  # sleep, loop again
703  time.sleep(self.step)
704 
705  self.log.info("All processes Completed all Events ok")
706  return SUCCESS
707 

Member Data Documentation

◆ d

GaudiMP.pTools.Syncer.d

Definition at line 606 of file pTools.py.

◆ keys

GaudiMP.pTools.Syncer.keys

Definition at line 614 of file pTools.py.

◆ limit

GaudiMP.pTools.Syncer.limit

Definition at line 604 of file pTools.py.

◆ limitFirst

GaudiMP.pTools.Syncer.limitFirst

Definition at line 612 of file pTools.py.

◆ log

GaudiMP.pTools.Syncer.log

Definition at line 616 of file pTools.py.

◆ manyEvents

GaudiMP.pTools.Syncer.manyEvents

Definition at line 607 of file pTools.py.

◆ nWorkers

GaudiMP.pTools.Syncer.nWorkers

Definition at line 615 of file pTools.py.

◆ step

GaudiMP.pTools.Syncer.step

Definition at line 605 of file pTools.py.


The documentation for this class was generated from the following file:
AlgSequencer.all
all
Definition: AlgSequencer.py:54
GaudiTests.Histograms.axes_labels.check
def check(causes, result)
Definition: axes_labels.py:45
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:97
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67