| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | List of all members
GaudiMP.GMPBase.Coord Class Reference
Inheritance diagram for GaudiMP.GMPBase.Coord:
[legend]
Collaboration diagram for GaudiMP.GMPBase.Coord:
[legend]

## 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
| subworkers
| reader
| workers
| writer
| system

## Detailed Description

Definition at line 1286 of file GMPBase.py.

## Constructor & Destructor Documentation

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

Definition at line 1287 of file GMPBase.py.

1287
1288 def __init__( self, nWorkers, config, log ) :
1289
1290 self.log = log
1291 self.config = config
1292 # set up Logging
1293 self.log.name = 'GaudiPython-Parallel-Logger'
1294 self.log.info( 'GaudiPython Parallel Process Co-ordinator beginning' )
1295
1296 if nWorkers == -1 :
1297 # The user has requested all available cpus in the machine
1298 self.nWorkers = cpu_count()
1299 else :
1300 self.nWorkers = nWorkers
1301
1302
1303 self.qs = self.SetupQueues( ) # a dictionary of queues (for Events)
1304 self.hq = JoinableQueue( ) # for Histogram data
1305 self.fq = JoinableQueue( ) # for FileRecords data
1306
1307 # Make a Syncer for Initalise, Run, and Finalise
1308 self.sInit = Syncer( self.nWorkers, self.log,
1309 limit=WAIT_INITIALISE,
1310 step=STEP_INITIALISE )
1311 self.sRun = Syncer( self.nWorkers, self.log,
1312 manyEvents=True,
1313 limit=WAIT_SINGLE_EVENT,
1314 step=STEP_EVENT,
1315 firstEvent=WAIT_FIRST_EVENT )
1316 self.sFin = Syncer( self.nWorkers, self.log,
1317 limit=WAIT_FINALISE,
1318 step=STEP_FINALISE )
1319 # and one final one for Histogram Transfer
1320 self.histSyncEvent = Event()
1321
1322 # params are common to al subprocesses
1323 params = (self.nWorkers, self.histSyncEvent, self.config, self.log)
1324
1325 self.subworkers = []
1326 # Declare SubProcesses!
1327 for i in range(1, self.nWorkers ) :
1328 sub = Subworker( i, self.getQueues(i), self.getSyncEvents(i), params, self.subworkers )
1329 self.subworkers.append( sub )
1330 self.reader= Reader(self.getQueues(-1), self.getSyncEvents(-1), params, self.subworkers)
1331 self.workers = []
1332 wk = Worker( 0, self.getQueues(0), self.getSyncEvents(0), params, self.subworkers )
1333 self.writer= Writer(self.getQueues(-2), self.getSyncEvents(-2), params, self.subworkers)
1334
1335 self.system = []
1336 self.system.append(self.writer)
1337 self.system.append(wk)
1338 self.system.append(self.reader)

## Member Function Documentation

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

Definition at line 1345 of file GMPBase.py.

1345
1346 def getQueues( self, nodeID ) :
1347 eventQ = self.qs[ nodeID ]
1348 histQ = self.hq
1349 fsrQ = self.fq
1350 return ( eventQ, histQ, fsrQ )

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

Definition at line 1339 of file GMPBase.py.

1339
1340 def getSyncEvents( self, nodeID ) :
1341 init = self.sInit.d[nodeID].event
1342 run = ( self.sRun.d[nodeID].event, self.sRun.d[nodeID].lastEvent )
1343 fin = self.sFin.d[nodeID].event
1344 return ( init, run, fin )

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

Definition at line 1351 of file GMPBase.py.

1351
1352 def Go( self ) :
1353
1354 # Initialise
1355 self.log.name = 'GaudiPython-Parallel-Logger'
1356 self.log.info( 'INITIALISING SYSTEM' )
1357
1358 # Start reader, writer and main worker
1359 for p in self.system :
1360 p.Start()
1361
1362 sc = self.sInit.syncAll(step="Initialise")
1363 if sc == SUCCESS: pass
1364 else : self.Terminate() ; return FAILURE
1365
1366 # Run
1367 self.log.name = 'GaudiPython-Parallel-Logger'
1368 self.log.info( 'RUNNING SYSTEM' )
1369 sc = self.sRun.syncAll(step="Run")
1370 if sc == SUCCESS: pass
1371 else : self.Terminate() ; return FAILURE
1372
1373 # Finalise
1374 self.log.name = 'GaudiPython-Parallel-Logger'
1375 self.log.info( 'FINALISING SYSTEM' )
1376 sc = self.sFin.syncAll(step="Finalise")
1377 if sc == SUCCESS: pass
1378 else : self.Terminate() ; return FAILURE
1379
1380 # if we've got this far, finally report SUCCESS
1381 self.log.info( "Cleanly join all Processes" )
1382 self.Stop()
1383 self.log.info( "Report Total Success to Main.py" )
1384 return SUCCESS

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

Definition at line 1402 of file GMPBase.py.

1402
1403 def SetupQueues( self ) :
1404 # This method will set up the network of Queues needed
1405 # N Queues = nWorkers + 1
1406 # Each Worker has a Queue in, and a Queue out
1407 # Reader has Queue out only
1408 # Writer has nWorkers Queues in
1409
1410 # one queue from Reader-Workers
1411 rwk = JoinableQueue()
1412 # one queue from each worker to writer
1413 workersWriter = [ JoinableQueue() for i in xrange(self.nWorkers) ]
1414 d = {}
1415 d[-1] = (None, rwk) # Reader
1416 d[-2] = (workersWriter, None) # Writer
1417 for i in xrange(self.nWorkers) : d[i] = (rwk, workersWriter[i])
1418 return d
1419
1420 # ============================= EOF ===========================================

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

Definition at line 1395 of file GMPBase.py.

1395
1396 def Stop( self ) :
1397 # procs should be joined in reverse order to launch
1398 self.system.reverse()
1399 for s in self.system :
1400 s.proc.join()
1401 return SUCCESS

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

Definition at line 1385 of file GMPBase.py.

1385
1386 def Terminate( self ) :
1387 # Brutally kill sub-processes
1388 children = multiprocessing.active_children()
1389 for i in children:
1390 i.terminate()
1391
1392 #self.writer.proc.terminate()
1393 #[ w.proc.terminate() for w in self.workers]
1394 #self.reader.proc.terminate()

## Member Data Documentation

GaudiMP.GMPBase.Coord.config

Definition at line 1290 of file GMPBase.py.

GaudiMP.GMPBase.Coord.fq

Definition at line 1304 of file GMPBase.py.

GaudiMP.GMPBase.Coord.histSyncEvent

Definition at line 1319 of file GMPBase.py.

GaudiMP.GMPBase.Coord.hq

Definition at line 1303 of file GMPBase.py.

GaudiMP.GMPBase.Coord.log

Definition at line 1289 of file GMPBase.py.

GaudiMP.GMPBase.Coord.nWorkers

Definition at line 1297 of file GMPBase.py.

GaudiMP.GMPBase.Coord.qs

Definition at line 1302 of file GMPBase.py.

GaudiMP.GMPBase.Coord.reader

Definition at line 1329 of file GMPBase.py.

GaudiMP.GMPBase.Coord.sFin

Definition at line 1315 of file GMPBase.py.

GaudiMP.GMPBase.Coord.sInit

Definition at line 1307 of file GMPBase.py.

GaudiMP.GMPBase.Coord.sRun

Definition at line 1310 of file GMPBase.py.

GaudiMP.GMPBase.Coord.subworkers

Definition at line 1324 of file GMPBase.py.

GaudiMP.GMPBase.Coord.system

Definition at line 1334 of file GMPBase.py.

GaudiMP.GMPBase.Coord.workers

Definition at line 1330 of file GMPBase.py.

GaudiMP.GMPBase.Coord.writer

Definition at line 1332 of file GMPBase.py.

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

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