def new(klass, *args, **kwargs): proxy = ppp.Proxy(klass) if scatterargs is None: scatteredargs = [((klass, proxy.__id__) + args,kwargs)]*(comm.size-1) else: scatteredargs = [((klass, proxy.__id__) + s[0], s[1]) for s in scatterargs(comm.size-1)(*args, **kwargs)] ppm.scatterfncall(ppp.createproxy, scatteredargs) for name, m in inspect.getmembers(klass, inspect.ismethod): pmdata = parallelmethods.get(m.im_func) if pmdata is not None: (mscatterargs, reduceop) = pmdata mw = memberwrapper(mscatterargs, m, reduceop) proxy.__setattr__(name, types.MethodType(mw, proxy, ppp.Proxy)) return proxy
def __call__(self, *margs, **mkwargs): if self.mscatterargs is None: scatteredargs = [(margs,mkwargs)]*(comm.size-1) else: scatteredargs = self.mscatterargs(comm.size-1)(*margs, **mkwargs) return ppm.scatterfncall(methodwrapper(self.m.im_func), scatteredargs, self.reduceop)
def parallelwrapper(*arg, **kw): if scatterargs is None: scatteredargs = [(arg,kw)]*(comm.size-1) else: scatteredargs = scatterargs(comm.size-1)(*arg, **kw) return ppm.scatterfncall(wrapfn(fn), scatteredargs, reduceop)
def new(klass, *arg, **kw): obj = object.__new__(klass) obj.__init__(*arg, **kw) proxy = ppp.Proxy(klass, obj) ppm.scatterfncall(ppp.registerproxy, [((proxy.__id__, obj),{})] * (comm.size-1)) return proxy