def Scan(self, sendbuf, recvbuf=None, op=SUM): sendbuf, sfastmode = _mpi.make_buf(sendbuf) recvbuf, rfastmode = _mpi.make_buf(recvbuf) if sfastmode or rfastmode: _mpi.scan(sendbuf, recvbuf, op, self) return None else: recvbuf = self.Gather(sendbuf, root=0) if _mpi.comm_rank(self) == 0: if op in (MAXLOC, MINLOC): recvbuf = zip(recvbuf, xrange(len(recvbuf))) for i in xrange(1, len(recvbuf)): recvbuf[i] = op(recvbuf[i - 1], recvbuf[i]) recvbuf = self.Scatter(recvbuf, root=0) return recvbuf
def Scan(self, sendbuf, recvbuf = None, op = SUM): sendbuf, sfastmode = _mpi.make_buf(sendbuf) recvbuf, rfastmode = _mpi.make_buf(recvbuf) if sfastmode or rfastmode: _mpi.scan(sendbuf, recvbuf, op, self) return None else: recvbuf = self.Gather(sendbuf, root=0) if _mpi.comm_rank(self) == 0: if op in (MAXLOC, MINLOC): recvbuf = zip(recvbuf, xrange(len(recvbuf))) for i in xrange(1, len(recvbuf)): recvbuf[i] = op(recvbuf[i - 1], recvbuf[i]) recvbuf = self.Scatter(recvbuf, root=0) return recvbuf
def Bcast(self, buf=None, root=0): buf, fastmode = _mpi.make_buf(buf) if fastmode: _mpi.bcast(buf, root, self) return else: serializer = self.SERIALIZER if _mpi.comm_test_inter(self): if root == _mpi.ROOT: buf = serializer.dump(buf) else: buf = None elif root == _mpi.comm_rank(self): buf = serializer.dump(buf) else: buf = None buf = _mpi.bcast_string(buf, root, self) if buf is not None: buf = serializer.load(buf) return buf
def Bcast(self, buf = None, root = 0): buf, fastmode = _mpi.make_buf(buf) if fastmode: _mpi.bcast(buf, root, self) return else: serializer = self.SERIALIZER if _mpi.comm_test_inter(self): if root == _mpi.ROOT: buf = serializer.dump(buf) else: buf = None elif root == _mpi.comm_rank(self): buf = serializer.dump(buf) else: buf = None buf = _mpi.bcast_string(buf, root, self) if buf is not None: buf = serializer.load(buf) return buf
def Scatter(self, sendbuf=None, recvbuf=None, root=0): sendbuf, sfastmode = _mpi.make_buf(sendbuf) recvbuf, rfastmode = _mpi.make_buf(recvbuf) if sfastmode or rfastmode: _mpi.scatter(sendbuf, recvbuf, root, self) return else: serializer = self.SERIALIZER if _mpi.comm_test_inter(self): if root == _mpi.ROOT: sendbuf = map(serializer.dump, sendbuf) else: sendbuf = None elif root == _mpi.comm_rank(self): sendbuf = map(serializer.dump, sendbuf) else: sendbuf = None recvbuf = _mpi.scatter_string(sendbuf, recvbuf, root, self) if recvbuf is not None: recvbuf = serializer.load(recvbuf) return recvbuf
def Scatter(self, sendbuf = None, recvbuf = None, root = 0): sendbuf, sfastmode = _mpi.make_buf(sendbuf) recvbuf, rfastmode = _mpi.make_buf(recvbuf) if sfastmode or rfastmode: _mpi.scatter(sendbuf, recvbuf, root, self) return else: serializer = self.SERIALIZER if _mpi.comm_test_inter(self): if root == _mpi.ROOT: sendbuf = map(serializer.dump, sendbuf) else: sendbuf = None elif root == _mpi.comm_rank(self): sendbuf = map(serializer.dump, sendbuf) else: sendbuf = None recvbuf = _mpi.scatter_string(sendbuf, recvbuf, root, self) if recvbuf is not None: recvbuf = serializer.load(recvbuf) return recvbuf
def Get_rank(self): return _mpi.comm_rank(self)