| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Member Functions | Public Attributes

# GaudiMP::GMPBase::Coord Class Reference

List of all members.

## Public Member Functions
def | __init__
def | getSyncEvents
def | getQueues
def | Go
def | Terminate
def | Stop
def | SetupQueues
## Public Attributes
| log
| config
| nWorkers
| qs
| hq
| fq
| sInit
| sRun
| sFin
| histSyncEvent
| reader
| workers
| writer
| system

## Detailed Description

Definition at line 1018 of file GMPBase.py.

## Constructor & Destructor Documentation

def GaudiMP::GMPBase::Coord::__init__ | ( |  | self,
|  |  | nWorkers,
|  |  | config,
|  |  | log
| ) |  |

Definition at line 1019 of file GMPBase.py.

    01020                                                 :
    01021
    01022         self.log = log
    01023         self.config = config
    01024         # set up Logging
    01025         self.log.name = 'GaudiPython-Parallel-Logger'
    01026         self.log.info( 'GaudiPython Parallel Process Co-ordinator beginning' )
    01027
    01028         if nWorkers == -1 :
    01029             # The user has requested all available cpus in the machine
    01030             self.nWorkers = cpu_count()
    01031         else :
    01032             self.nWorkers = nWorkers
    01033
    01034
    01035         self.qs = self.SetupQueues( )    # a dictionary of queues (for Events)
    01036         self.hq = JoinableQueue( )       # for Histogram data
    01037         self.fq = JoinableQueue( )       # for FileRecords data
    01038
    01039         # Make a Syncer for Initalise, Run, and Finalise
    01040         self.sInit = Syncer( self.nWorkers, self.log,
    01041                              limit=WAIT_INITIALISE,
    01042                              step=STEP_INITIALISE    )
    01043         self.sRun  = Syncer( self.nWorkers, self.log,
    01044                              manyEvents=True,
    01045                              limit=WAIT_SINGLE_EVENT,
    01046                              step=STEP_EVENT,
    01047                              firstEvent=WAIT_FIRST_EVENT )
    01048         self.sFin  = Syncer( self.nWorkers, self.log,
    01049                              limit=WAIT_FINALISE,
    01050                              step=STEP_FINALISE )
    01051         # and one final one for Histogram Transfer
    01052         self.histSyncEvent = Event()
    01053
    01054         # params are common to al subprocesses
    01055         params = (self.nWorkers, self.histSyncEvent, self.config, self.log)
    01056
    01057         # Declare SubProcesses!
    01058         self.reader= Reader(self.getQueues(-1), self.getSyncEvents(-1), params)
    01059         self.workers = []
    01060         for i in xrange( self.nWorkers ) :
    01061             wk = Worker( i, self.getQueues(i), self.getSyncEvents(i), params )
    01062             self.workers.append( wk )
    01063         self.writer= Writer(self.getQueues(-2), self.getSyncEvents(-2), params)
    01064
    01065         self.system = []
    01066         self.system.append(self.writer)
    01067         [ self.system.append(w) for w in self.workers ]
    01068         self.system.append(self.reader)

## Member Function Documentation

def GaudiMP::GMPBase::Coord::getQueues | ( |  | self,
|  |  | nodeID
| ) |  |

Definition at line 1075 of file GMPBase.py.

    01076                                   :
    01077         eventQ = self.qs[ nodeID ]
    01078         histQ  = self.hq
    01079         fsrQ   = self.fq
    01080         return ( eventQ, histQ, fsrQ )

def GaudiMP::GMPBase::Coord::getSyncEvents | ( |  | self,
|  |  | nodeID
| ) |  |

Definition at line 1069 of file GMPBase.py.

    01070                                       :
    01071         init = self.sInit.d[nodeID].event
    01072         run  = ( self.sRun.d[nodeID].event, self.sRun.d[nodeID].lastEvent )
    01073         fin  = self.sFin.d[nodeID].event
    01074         return ( init, run, fin )

def GaudiMP::GMPBase::Coord::Go | ( |  | self ) |

Definition at line 1081 of file GMPBase.py.

    01082                    :
    01083
    01084         # Initialise
    01085         self.log.name = 'GaudiPython-Parallel-Logger'
    01086         self.log.info( 'INITIALISING SYSTEM' )
    01087         for p in self.system :
    01088             p.Start()
    01089         sc = self.sInit.syncAll(step="Initialise")
    01090         if sc : pass
    01091         else  : self.Terminate() ; return FAILURE
    01092
    01093         # Run
    01094         self.log.name = 'GaudiPython-Parallel-Logger'
    01095         self.log.info( 'RUNNING SYSTEM' )
    01096         sc = self.sRun.syncAll(step="Run")
    01097         if sc : pass
    01098         else  : self.Terminate() ; return FAILURE
    01099
    01100         # Finalise
    01101         self.log.name = 'GaudiPython-Parallel-Logger'
    01102         self.log.info( 'FINALISING SYSTEM' )
    01103         sc = self.sFin.syncAll(step="Finalise")
    01104         if sc : pass
    01105         else  : self.Terminate() ; return FAILURE
    01106
    01107         # if we've got this far, finally report SUCCESS
    01108         self.log.info( "Cleanly join all Processes" )
    01109         self.Stop()
    01110         self.log.info( "Report Total Success to Main.py" )
    01111         return SUCCESS

def GaudiMP::GMPBase::Coord::SetupQueues | ( |  | self ) |

Definition at line 1125 of file GMPBase.py.

    01126                             :
    01127         # This method will set up the network of Queues needed
    01128         # N Queues = nWorkers + 1
    01129         # Each Worker has a Queue in, and a Queue out
    01130         # Reader has Queue out only
    01131         # Writer has nWorkers Queues in
    01132
    01133         # one queue from Reader-Workers
    01134         rwk = JoinableQueue()
    01135         # one queue from each worker to writer
    01136         workersWriter = [ JoinableQueue() for i in xrange(self.nWorkers) ]
    01137         d = {}
    01138         d[-1] = (None, rwk)              # Reader
    01139         d[-2] = (workersWriter, None)    # Writer
    01140         for i in xrange(self.nWorkers) : d[i] =  (rwk, workersWriter[i])
    01141         return d
    01142
    # ============================= EOF ===========================================

def GaudiMP::GMPBase::Coord::Stop | ( |  | self ) |

Definition at line 1118 of file GMPBase.py.

    01119                      :
    01120         # procs should be joined in reverse order to launch
    01121         self.system.reverse()
    01122         for s in self.system :
    01123             s.proc.join()
    01124         return SUCCESS

def GaudiMP::GMPBase::Coord::Terminate | ( |  | self ) |

Definition at line 1112 of file GMPBase.py.

    01113                           :
    01114         # Brutally kill sub-processes
    01115         self.writer.proc.terminate()
    01116         [ w.proc.terminate() for w in self.workers]
    01117         self.reader.proc.terminate()

## Member Data Documentation

GaudiMP::GMPBase::Coord::config

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::fq

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::histSyncEvent

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::hq

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::log

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::nWorkers

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::qs

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::reader

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sFin

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sInit

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sRun

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::system

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::workers

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::writer

Definition at line 1019 of file GMPBase.py.

The documentation for this class was generated from the following file:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r4/GaudiMP/python/GaudiMP/GMPBase.py

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines