The Gaudi Framework  v36r13 (995e4364)
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 629 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 630 of file pTools.py.

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

Member Function Documentation

◆ checkAll()

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 736 of file pTools.py.

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

◆ checkLastEvents()

def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 742 of file pTools.py.

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

◆ processHang()

def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 730 of file pTools.py.

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

◆ syncAll()

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

Definition at line 648 of file pTools.py.

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

◆ syncAllRolling()

def GaudiMP.pTools.Syncer.syncAllRolling (   self)

Definition at line 675 of file pTools.py.

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

Member Data Documentation

◆ d

GaudiMP.pTools.Syncer.d

Definition at line 634 of file pTools.py.

◆ keys

GaudiMP.pTools.Syncer.keys

Definition at line 642 of file pTools.py.

◆ limit

GaudiMP.pTools.Syncer.limit

Definition at line 632 of file pTools.py.

◆ limitFirst

GaudiMP.pTools.Syncer.limitFirst

Definition at line 640 of file pTools.py.

◆ log

GaudiMP.pTools.Syncer.log

Definition at line 644 of file pTools.py.

◆ manyEvents

GaudiMP.pTools.Syncer.manyEvents

Definition at line 635 of file pTools.py.

◆ nWorkers

GaudiMP.pTools.Syncer.nWorkers

Definition at line 643 of file pTools.py.

◆ step

GaudiMP.pTools.Syncer.step

Definition at line 633 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
StringKeyEx.keys
keys
Definition: StringKeyEx.py:64
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:102