| The Gaudi Framework v29r1 (5cd95fa2)

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

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

Public Member Functions | Public Attributes | Private Member Functions | Static Private Attributes | List of all members
GaudiMP.Parallel.Task Class Reference
Inheritance diagram for GaudiMP.Parallel.Task:
[legend]
Collaboration diagram for GaudiMP.Parallel.Task:
[legend]

## Public Member Functions
def | __new__ (cls, args, kwargs)
def | initializeLocal (self)
def | initializeRemote (self)
def | process (self, item)
def | finalize (self)

## Public Attributes
| output

## Private Member Functions
def | _mergeResults (self, result)
def | _resetOutput (self)

## Static Private Attributes
bool | _initializeDone = False

## Detailed Description

    Basic base class to encapsulate any processing that is going to be porcessed in parallel.
        User class much inherit from it and implement the methods initializeLocal,
        initializeRemote, process and finalize.

Definition at line 57 of file Parallel.py.

## Member Function Documentation

def GaudiMP.Parallel.Task.__new__ | ( |  | cls,
|  |  | args,
|  |  | kwargs
| ) |  |

Definition at line 63 of file Parallel.py.

63 def __new__(cls, *args, **kwargs):
64 task = object.__new__(cls)
65 task.output = ()
66 task.environ = {}
67 for k, v in os.environ.items():
68 task.environ[k] = v
69 task.cwd = os.getcwd()
70 return task
71
GaudiMP.Parallel.Task.__new__
def __new__(cls, args, kwargs)
Definition: Parallel.py:63

def GaudiMP.Parallel.Task._mergeResults | ( |  | self,
|  |  | result
| ) |  |
| private

Definition at line 84 of file Parallel.py.

84 def _mergeResults(self, result):
85 if type(result) is not type(self.output):
86 raise TypeError("output type is not same as obtained result")
87 #--No iteratable---
88 if not hasattr(result, '__iter__'):
89 if hasattr(self.output, 'Add'):
90 self.output.Add(result)
91 elif hasattr(self.output, '__iadd__'):
92 self.output += result
93 elif hasattr(self.output, '__add__'):
94 self.output = self.output + result
95 else:
96 raise TypeError('result cannot be added')
97 #--Dictionary---
98 elif type(result) is dict:
99 if self.output.keys() <= result.keys():
100 minkeys = self.output.keys()
101 else:
102 minkeys = result.keys()
103 for key in result.keys():
104 if key in self.output:
105 if hasattr(self.output[key], 'Add'):
106 self.output[key].Add(result[key])
107 elif hasattr(self.output[key], '__iadd__'):
108 self.output[key] += result[key]
109 elif hasattr(self.output[key], '__add__'):
110 self.output[key] = self.output[key] + result[key]
111 else:
112 raise TypeError('result cannot be added')
113 else:
114 self.output[key] = result[key]
115 #--Anything else (list)
116 else:
117 for i in range(min(len(self.output), len(result))):
118 if hasattr(self.output[i], 'Add'):
119 self.output[i].Add(result[i])
120 elif hasattr(self.output[i], '__iadd__'):
121 self.output[i] += result[i]
122 elif hasattr(self.output[i], '__add__'):
123 self.output[i] = self.output[i] + result[i]
124 else:
125 raise TypeError('result cannot be added')
126
GaudiMP.Parallel.Task.output
output
Definition: Parallel.py:94
gaudirun.type
type
Definition: gaudirun.py:133
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:85
GaudiMP.Parallel.Task._mergeResults
def _mergeResults(self, result)
Definition: Parallel.py:84

def GaudiMP.Parallel.Task._resetOutput | ( |  | self | ) |
| private

Definition at line 127 of file Parallel.py.

127 def _resetOutput(self):
128 output = (type(self.output)
129 is dict) and self.output.values() or self.output
130 for o in output:
131 if hasattr(o, 'Reset'):
132 o.Reset()
133
134
GaudiMP.Parallel.Task.output
output
Definition: Parallel.py:94
gaudirun.type
type
Definition: gaudirun.py:133
GaudiMP.Parallel.Task._resetOutput
def _resetOutput(self)
Definition: Parallel.py:127

def GaudiMP.Parallel.Task.finalize | ( |  | self | ) |

Definition at line 81 of file Parallel.py.

81 def finalize(self):
82 pass
83
GaudiMP.Parallel.Task.finalize
def finalize(self)
Definition: Parallel.py:81

def GaudiMP.Parallel.Task.initializeLocal | ( |  | self | ) |

Definition at line 72 of file Parallel.py.

72 def initializeLocal(self):
73 pass
74
GaudiMP.Parallel.Task.initializeLocal
def initializeLocal(self)
Definition: Parallel.py:72

def GaudiMP.Parallel.Task.initializeRemote | ( |  | self | ) |

Definition at line 75 of file Parallel.py.

75 def initializeRemote(self):
76 pass
77
GaudiMP.Parallel.Task.initializeRemote
def initializeRemote(self)
Definition: Parallel.py:75

def GaudiMP.Parallel.Task.process | ( |  | self,
|  |  | item
| ) |  |

Definition at line 78 of file Parallel.py.

78 def process(self, item):
79 pass
80
GaudiMP.Parallel.Task.process
def process(self, item)
Definition: Parallel.py:78

## Member Data Documentation

bool GaudiMP.Parallel.Task._initializeDone = False
| static private

Definition at line 61 of file Parallel.py.

GaudiMP.Parallel.Task.output

Definition at line 94 of file Parallel.py.

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

- GaudiMP/python/GaudiMP/Parallel.py