| # Gaudi Framework, version v22r0 |

Home |  | Generated: 9 Feb 2011

# 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 1016 of file GMPBase.py.

## Member Function Documentation

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

Definition at line 1017 of file GMPBase.py.

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

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

Definition at line 1073 of file GMPBase.py.

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

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

Definition at line 1067 of file GMPBase.py.

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

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

Definition at line 1079 of file GMPBase.py.

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

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

Definition at line 1123 of file GMPBase.py.

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

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

Definition at line 1116 of file GMPBase.py.

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

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

Definition at line 1110 of file GMPBase.py.

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

## Member Data Documentation

GaudiMP::GMPBase::Coord::config

Definition at line 1020 of file GMPBase.py.

GaudiMP::GMPBase::Coord::fq

Definition at line 1034 of file GMPBase.py.

GaudiMP::GMPBase::Coord::histSyncEvent

Definition at line 1049 of file GMPBase.py.

GaudiMP::GMPBase::Coord::hq

Definition at line 1033 of file GMPBase.py.

GaudiMP::GMPBase::Coord::log

Definition at line 1019 of file GMPBase.py.

GaudiMP::GMPBase::Coord::nWorkers

Definition at line 1027 of file GMPBase.py.

GaudiMP::GMPBase::Coord::qs

Definition at line 1032 of file GMPBase.py.

GaudiMP::GMPBase::Coord::reader

Definition at line 1055 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sFin

Definition at line 1045 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sInit

Definition at line 1037 of file GMPBase.py.

GaudiMP::GMPBase::Coord::sRun

Definition at line 1040 of file GMPBase.py.

GaudiMP::GMPBase::Coord::system

Definition at line 1062 of file GMPBase.py.

GaudiMP::GMPBase::Coord::workers

Definition at line 1056 of file GMPBase.py.

GaudiMP::GMPBase::Coord::writer

Definition at line 1060 of file GMPBase.py.

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

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

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