Gaudi Framework, version v25r1

Home   Generated: Mon Mar 24 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
GaudiMP.Parallel.WorkManager Class Reference
Inheritance diagram for GaudiMP.Parallel.WorkManager:
Inheritance graph
[legend]
Collaboration diagram for GaudiMP.Parallel.WorkManager:
Collaboration graph
[legend]

Public Member Functions

def __init__
 
def __del__
 
def process
 

Public Attributes

 ncpus
 
 ppservers
 
 sessions
 
 server
 
 mode
 
 pool
 
 stats
 

Private Member Functions

def _printStatistics
 
def _mergeStatistics
 

Detailed Description

Class to in charge of managing the tasks and distributing them to
    the workers. They can be local (using other cores) or remote
    using other nodes in the local cluster 

Definition at line 101 of file Parallel.py.

Constructor & Destructor Documentation

def GaudiMP.Parallel.WorkManager.__init__ (   self,
  ncpus = 'autodetect',
  ppservers = None 
)

Definition at line 106 of file Parallel.py.

107  def __init__( self, ncpus='autodetect', ppservers=None) :
108  if ncpus == 'autodetect' : self.ncpus = multiprocessing.cpu_count()
109  else : self.ncpus = ncpus
110  if ppservers :
111  import pp
112  self.ppservers = ppservers
113  self.sessions = [ SshSession(srv) for srv in ppservers ]
114  self.server = pp.Server(ncpus=self.ncpus, ppservers=self.ppservers)
115  self.mode = 'cluster'
116  else :
117  self.pool = multiprocessing.Pool(self.ncpus)
118  self.mode = 'multicore'
119  self.stats = {}
def GaudiMP.Parallel.WorkManager.__del__ (   self)

Definition at line 120 of file Parallel.py.

121  def __del__(self):
122  if hasattr(self,'server') : self.server.destroy()

Member Function Documentation

def GaudiMP.Parallel.WorkManager._mergeStatistics (   self,
  stat 
)
private

Definition at line 157 of file Parallel.py.

158  def _mergeStatistics(self, stat):
159  if stat.name not in self.stats : self.stats[stat.name] = Statistics()
160  s = self.stats[stat.name]
161  s.time += stat.time
162  s.njob += 1
163 
def GaudiMP.Parallel.WorkManager._printStatistics (   self)
private

Definition at line 148 of file Parallel.py.

149  def _printStatistics(self):
150  njobs = 0
151  for stat in self.stats.values():
152  njobs += stat.njob
153  print 'Job execution statistics:'
154  print 'job count | % of all jobs | job time sum | time per job | job server'
155  for name, stat in self.stats.items():
156  print ' %d | %6.2f | %8.3f | %8.3f | %s' % (stat.njob, 100.*stat.njob/njobs, stat.time, stat.time/stat.njob, name)
def GaudiMP.Parallel.WorkManager.process (   self,
  task,
  items,
  timeout = 90000 
)

Definition at line 123 of file Parallel.py.

124  def process(self, task, items, timeout=90000):
125  if not isinstance(task,Task) :
126  raise TypeError("task argument needs to be an 'Task' instance")
127  # --- Call the Local initialialization
128  task.initializeLocal()
129  # --- Schedule all the jobs ....
130  if self.mode == 'cluster' :
131  jobs = [self.server.submit(_prefunction, (_ppfunction, task, item), (), ('GaudiMP.Parallel','time')) for item in items]
132  for job in jobs :
133  result, stat = job()
134  task._mergeResults(result)
135  self._mergeStatistics(stat)
136  self._printStatistics()
137  self.server.print_stats()
138  elif self.mode == 'multicore' :
139  start = time.time()
140  jobs = self.pool.map_async(_ppfunction, zip([task for i in items] , items ))
141  for result, stat in jobs.get(timeout) :
142  task._mergeResults(result)
143  self._mergeStatistics(stat)
144  end = time.time()
145  self._printStatistics()
146  print 'Time elapsed since server creation %f' %(end-start)
147  # --- Call the Local Finalize
task.finalize()

Member Data Documentation

GaudiMP.Parallel.WorkManager.mode

Definition at line 114 of file Parallel.py.

GaudiMP.Parallel.WorkManager.ncpus

Definition at line 107 of file Parallel.py.

GaudiMP.Parallel.WorkManager.pool

Definition at line 116 of file Parallel.py.

GaudiMP.Parallel.WorkManager.ppservers

Definition at line 111 of file Parallel.py.

GaudiMP.Parallel.WorkManager.server

Definition at line 113 of file Parallel.py.

GaudiMP.Parallel.WorkManager.sessions

Definition at line 112 of file Parallel.py.

GaudiMP.Parallel.WorkManager.stats

Definition at line 118 of file Parallel.py.


The documentation for this class was generated from the following file:
Generated at Mon Mar 24 2014 18:27:53 for Gaudi Framework, version v25r1 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004