The Gaudi Framework  v38r0 (2143aa4c)
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 628 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 629 of file pTools.py.

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

Member Function Documentation

◆ checkAll()

def GaudiMP.pTools.Syncer.checkAll (   self)

Definition at line 735 of file pTools.py.

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

◆ checkLastEvents()

def GaudiMP.pTools.Syncer.checkLastEvents (   self)

Definition at line 741 of file pTools.py.

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

◆ processHang()

def GaudiMP.pTools.Syncer.processHang (   self)

Definition at line 729 of file pTools.py.

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

◆ syncAll()

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

Definition at line 647 of file pTools.py.

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

◆ syncAllRolling()

def GaudiMP.pTools.Syncer.syncAllRolling (   self)

Definition at line 674 of file pTools.py.

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

Member Data Documentation

◆ d

GaudiMP.pTools.Syncer.d

Definition at line 633 of file pTools.py.

◆ keys

GaudiMP.pTools.Syncer.keys

Definition at line 641 of file pTools.py.

◆ limit

GaudiMP.pTools.Syncer.limit

Definition at line 631 of file pTools.py.

◆ limitFirst

GaudiMP.pTools.Syncer.limitFirst

Definition at line 639 of file pTools.py.

◆ log

GaudiMP.pTools.Syncer.log

Definition at line 643 of file pTools.py.

◆ manyEvents

GaudiMP.pTools.Syncer.manyEvents

Definition at line 634 of file pTools.py.

◆ nWorkers

GaudiMP.pTools.Syncer.nWorkers

Definition at line 642 of file pTools.py.

◆ step

GaudiMP.pTools.Syncer.step

Definition at line 632 of file pTools.py.


The documentation for this class was generated from the following file:
AlgSequencer.all
all
Definition: AlgSequencer.py:55
GaudiTests.Histograms.axes_labels.check
def check(causes, result)
Definition: axes_labels.py:47
Gaudi::Monitoring::reset
void reset(T &)
default (empty) implementation of reset method for types stored into an entity
Definition: MonitoringHub.h:75
StringKeyEx.keys
keys
Definition: StringKeyEx.py:63
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: details.h:98