示例#1
0
文件: MPI.py 项目: connoryang/1v1dec
 def Sendrecv(self,
              sendbuf,
              dest=0,
              sendtag=0,
              recvbuf=None,
              source=0,
              recvtag=0,
              status=None):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.sendrecv(sendbuf, dest, sendtag, recvbuf, source, recvtag,
                       self, status)
         return
     else:
         serializer = self.SERIALIZER
         if dest != _mpi.PROC_NULL:
             sendbuf = serializer.dump(sendbuf)
         else:
             sendbuf = None
         recvbuf = _mpi.sendrecv_string(sendbuf, dest, sendtag, recvbuf,
                                        source, recvtag, self, status)
         if recvbuf is not None:
             recvbuf = serializer.load(recvbuf)
         return recvbuf
示例#2
0
文件: MPI.py 项目: connoryang/1v1dec
 def Alltoall(self, sendbuf, recvbuf=None):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.alltoall(sendbuf, recvbuf, self)
         return None
     else:
         serializer = self.SERIALIZER
         sendbuf = map(serializer.dump, sendbuf)
         recvbuf = _mpi.alltoall_string(sendbuf, recvbuf, self)
         recvbuf = map(serializer.load, recvbuf)
         return recvbuf
示例#3
0
文件: MPI.py 项目: Pluckyduck/eve
 def Alltoall(self, sendbuf, recvbuf = None):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.alltoall(sendbuf, recvbuf, self)
         return None
     else:
         serializer = self.SERIALIZER
         sendbuf = map(serializer.dump, sendbuf)
         recvbuf = _mpi.alltoall_string(sendbuf, recvbuf, self)
         recvbuf = map(serializer.load, recvbuf)
         return recvbuf
示例#4
0
文件: MPI.py 项目: connoryang/1v1dec
 def Reduce(self, sendbuf, recvbuf=None, op=SUM, root=0):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.reduce(sendbuf, recvbuf, op, root, self)
         return
     else:
         recvbuf = self.Gather(sendbuf, None, root)
         if recvbuf is not None:
             if op in (MAXLOC, MINLOC):
                 recvbuf = zip(recvbuf, xrange(len(recvbuf)))
             recvbuf = reduce(op, recvbuf)
         return recvbuf
示例#5
0
文件: MPI.py 项目: Pluckyduck/eve
 def Reduce(self, sendbuf, recvbuf = None, op = SUM, root = 0):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.reduce(sendbuf, recvbuf, op, root, self)
         return
     else:
         recvbuf = self.Gather(sendbuf, None, root)
         if recvbuf is not None:
             if op in (MAXLOC, MINLOC):
                 recvbuf = zip(recvbuf, xrange(len(recvbuf)))
             recvbuf = reduce(op, recvbuf)
         return recvbuf
示例#6
0
文件: MPI.py 项目: Pluckyduck/eve
 def Allreduce(self, sendbuf, recvbuf = None, op = SUM):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.allreduce(sendbuf, recvbuf, op, self)
         return None
     else:
         serializer = self.SERIALIZER
         sendbuf = serializer.dump(sendbuf)
         recvbuf = _mpi.allgather_string(sendbuf, recvbuf, self)
         recvbuf = map(serializer.load, recvbuf)
         if op in (MAXLOC, MINLOC):
             recvbuf = zip(recvbuf, xrange(len(recvbuf)))
         recvbuf = reduce(op, recvbuf)
         return recvbuf
示例#7
0
文件: MPI.py 项目: connoryang/1v1dec
 def Allreduce(self, sendbuf, recvbuf=None, op=SUM):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.allreduce(sendbuf, recvbuf, op, self)
         return None
     else:
         serializer = self.SERIALIZER
         sendbuf = serializer.dump(sendbuf)
         recvbuf = _mpi.allgather_string(sendbuf, recvbuf, self)
         recvbuf = map(serializer.load, recvbuf)
         if op in (MAXLOC, MINLOC):
             recvbuf = zip(recvbuf, xrange(len(recvbuf)))
         recvbuf = reduce(op, recvbuf)
         return recvbuf
示例#8
0
文件: MPI.py 项目: Pluckyduck/eve
    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
示例#9
0
文件: MPI.py 项目: Pluckyduck/eve
 def Sendrecv(self, sendbuf, dest = 0, sendtag = 0, recvbuf = None, source = 0, recvtag = 0, status = None):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.sendrecv(sendbuf, dest, sendtag, recvbuf, source, recvtag, self, status)
         return
     else:
         serializer = self.SERIALIZER
         if dest != _mpi.PROC_NULL:
             sendbuf = serializer.dump(sendbuf)
         else:
             sendbuf = None
         recvbuf = _mpi.sendrecv_string(sendbuf, dest, sendtag, recvbuf, source, recvtag, self, status)
         if recvbuf is not None:
             recvbuf = serializer.load(recvbuf)
         return recvbuf
示例#10
0
文件: MPI.py 项目: connoryang/1v1dec
    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
示例#11
0
文件: MPI.py 项目: connoryang/1v1dec
 def Gather(self, sendbuf, recvbuf=None, root=0):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.gather(sendbuf, recvbuf, root, self)
         return
     else:
         serializer = self.SERIALIZER
         if _mpi.comm_test_inter(self):
             if root != _mpi.ROOT and root != _mpi.PROC_NULL:
                 sendbuf = serializer.dump(sendbuf)
             else:
                 sendbuf = None
         else:
             sendbuf = serializer.dump(sendbuf)
         recvbuf = _mpi.gather_string(sendbuf, recvbuf, root, self)
         if recvbuf is not None:
             recvbuf = map(serializer.load, recvbuf)
         return recvbuf
示例#12
0
文件: MPI.py 项目: connoryang/1v1dec
 def Recv(self, buf=None, source=0, tag=0, status=None):
     buf, fastmode = _mpi.make_buf(buf)
     if fastmode:
         _mpi.recv(buf, source, tag, self, status)
         return None
     else:
         buf = _mpi.recv_string(buf, source, tag, self, status)
         if source != _mpi.PROC_NULL:
             buf = self.SERIALIZER.load(buf)
         return buf
示例#13
0
文件: MPI.py 项目: Pluckyduck/eve
 def Recv(self, buf = None, source = 0, tag = 0, status = None):
     buf, fastmode = _mpi.make_buf(buf)
     if fastmode:
         _mpi.recv(buf, source, tag, self, status)
         return None
     else:
         buf = _mpi.recv_string(buf, source, tag, self, status)
         if source != _mpi.PROC_NULL:
             buf = self.SERIALIZER.load(buf)
         return buf
示例#14
0
文件: MPI.py 项目: Pluckyduck/eve
 def Gather(self, sendbuf, recvbuf = None, root = 0):
     sendbuf, sfastmode = _mpi.make_buf(sendbuf)
     recvbuf, rfastmode = _mpi.make_buf(recvbuf)
     if sfastmode or rfastmode:
         _mpi.gather(sendbuf, recvbuf, root, self)
         return
     else:
         serializer = self.SERIALIZER
         if _mpi.comm_test_inter(self):
             if root != _mpi.ROOT and root != _mpi.PROC_NULL:
                 sendbuf = serializer.dump(sendbuf)
             else:
                 sendbuf = None
         else:
             sendbuf = serializer.dump(sendbuf)
         recvbuf = _mpi.gather_string(sendbuf, recvbuf, root, self)
         if recvbuf is not None:
             recvbuf = map(serializer.load, recvbuf)
         return recvbuf
示例#15
0
文件: MPI.py 项目: connoryang/1v1dec
 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
示例#16
0
文件: MPI.py 项目: Pluckyduck/eve
 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
示例#17
0
文件: MPI.py 项目: connoryang/1v1dec
 def Send(self, buf, dest=0, tag=0):
     buf, fastmode = _mpi.make_buf(buf)
     if fastmode:
         _mpi.send(buf, dest, tag, self)
         return
     else:
         if dest != _mpi.PROC_NULL:
             buf = self.SERIALIZER.dump(buf)
         else:
             buf = None
         _mpi.send_string(buf, dest, tag, self)
         return
示例#18
0
文件: MPI.py 项目: Pluckyduck/eve
 def Send(self, buf, dest = 0, tag = 0):
     buf, fastmode = _mpi.make_buf(buf)
     if fastmode:
         _mpi.send(buf, dest, tag, self)
         return
     else:
         if dest != _mpi.PROC_NULL:
             buf = self.SERIALIZER.dump(buf)
         else:
             buf = None
         _mpi.send_string(buf, dest, tag, self)
         return
示例#19
0
文件: MPI.py 项目: Pluckyduck/eve
 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
示例#20
0
文件: MPI.py 项目: connoryang/1v1dec
 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