The Gaudi Framework  v36r7 (7f57a304)
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 630 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 631 of file pTools.py.

631  def __init__(
632  self, nWorkers, log, manyEvents=False, limit=None, step=None, firstEvent=None
633  ):
634  # Class to help synchronise the sub-processes
635  self.limit = limit
636  self.step = step
637  self.d = {}
638  self.manyEvents = manyEvents
639 
640  for i in range(-2, nWorkers):
641  self.d[i] = SyncMini(Event(), lastEvent=Event())
642  if self.manyEvents:
643  self.limitFirst = firstEvent
644 
645  self.keys = self.d.keys()
646  self.nWorkers = nWorkers
647  self.log = log
648 

Member Function Documentation

◆ checkAll()

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 737 of file pTools.py.

737  def checkAll(self):
738  # Check the status of each Sync object
739  # return True or False
740  currentStatus = [mini.check() for mini in self.d.values()]
741  return all(currentStatus)
742 

◆ checkLastEvents()

def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 743 of file pTools.py.

743  def checkLastEvents(self):
744  # check if all of the lastEvents are set to true in self.d[k][1]
745  stat = [sMini.checkLast() for sMini in self.d.values()]
746  return all(stat)
747 
748 
749 # =========================== Methods =========================================
750 
751 

◆ processHang()

def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 731 of file pTools.py.

731  def processHang(self):
732  self.log.critical("Some proc is hanging during Event processing!")
733  for k in self.keys:
734  self.log.critical("Proc/Stat : %i / %s" % (k, self.d[k].check()))
735  return
736 

◆ syncAll()

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

Definition at line 649 of file pTools.py.

649  def syncAll(self, step="Not specified"):
650  # is it this method, or is it the rolling version needed?
651  # if so, drop through...
652 
653  if self.manyEvents:
654  sc = self.syncAllRolling()
655  return sc
656 
657  # Regular version ----------------------------
658  for i in range(0, self.limit, self.step):
659  if self.checkAll():
660  self.log.info("%s : All procs done @ %i s" % (step, i))
661  break
662  else:
663  time.sleep(self.step)
664 
665  # Now the time limit is up... check the status one final time
666  if self.checkAll():
667  self.log.info("All processes : %s ok." % (step))
668  return SUCCESS
669  else:
670  self.log.critical("Some process is hanging on : %s" % (step))
671  for k in self.keys:
672  hangString = "%s : Proc/Stat : %i/%s" % (step, k, self.d[k].check())
673  self.log.critical(hangString)
674  return FAILURE
675 

◆ syncAllRolling()

def GaudiMP.pTools.Syncer.syncAllRolling (   self)

Definition at line 676 of file pTools.py.

676  def syncAllRolling(self):
677  # Keep track of the progress of Event processing
678  # Each process syncs after each event, so keep clearing
679  # the sync Event, and re-checking
680  # Note the time between True checks too, if the time
681  # between events exceeds singleEvent, this is considered a hang
682 
683  # set the initial time
684  begin = time.time()
685  firstEv = {}
686  timers = {}
687  for k in self.keys:
688  self.d[k].reset()
689  firstEv[k] = False
690  timers[k] = 0.0
691 
692  active = self.keys
693  while True:
694  # check the status of each sync object
695  for k in active:
696  sMini = self.d[k]
697 
698  if sMini.check() or sMini.checkLast():
699  if sMini.checkLast() and sMini.check():
700  # if last Event set,then event loop finished
701  active.remove(k)
702  alive = time.time() - begin
703  self.log.info("Audit : Node %i alive for %5.2f" % (k, alive))
704  else:
705  sMini.reset()
706  else:
707  # the event still has not been checked, how long is that?
708  # is it the first Event?
709  wait = time.time() - sMini.getTime()
710  cond = wait > self.limit
711  if not firstEv[k]:
712  cond = wait > self.limitFirst
713  firstEv[k] = True
714  if cond:
715  # It is hanging!
716  self.log.critical("Single event wait : %5.2f" % (wait))
717  self.processHang()
718  return FAILURE
719 
720  # Termination Criteria : if all procs have been removed, we're done
721  if self.checkLastEvents():
722  self.log.info("TC met for event loop")
723  break
724  else:
725  # sleep, loop again
726  time.sleep(self.step)
727 
728  self.log.info("All processes Completed all Events ok")
729  return SUCCESS
730 

Member Data Documentation

◆ d

GaudiMP.pTools.Syncer.d

Definition at line 635 of file pTools.py.

◆ keys

GaudiMP.pTools.Syncer.keys

Definition at line 643 of file pTools.py.

◆ limit

GaudiMP.pTools.Syncer.limit

Definition at line 633 of file pTools.py.

◆ limitFirst

GaudiMP.pTools.Syncer.limitFirst

Definition at line 641 of file pTools.py.

◆ log

GaudiMP.pTools.Syncer.log

Definition at line 645 of file pTools.py.

◆ manyEvents

GaudiMP.pTools.Syncer.manyEvents

Definition at line 636 of file pTools.py.

◆ nWorkers

GaudiMP.pTools.Syncer.nWorkers

Definition at line 644 of file pTools.py.

◆ step

GaudiMP.pTools.Syncer.step

Definition at line 634 of file pTools.py.


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