File: test_msgzero.py

package info (click to toggle)
mpi4py 4.0.3-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,196 kB
  • sloc: python: 32,170; ansic: 13,449; makefile: 602; sh: 314; f90: 178; cpp: 148
file content (54 lines) | stat: -rw-r--r-- 1,766 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from mpi4py import MPI
import mpiunittest as unittest


class BaseTestMessageZero:

    null_b = [None, MPI.INT]
    null_v = [None, (0, None), MPI.INT]

    def testPointToPoint(self):
        comm = self.COMM
        comm.Sendrecv(sendbuf=self.null_b,   dest=comm.rank,
                      recvbuf=self.null_b, source=comm.rank)
        r2 = comm.Irecv(self.null_b, comm.rank)
        r1 = comm.Isend(self.null_b, comm.rank)
        MPI.Request.Waitall([r1, r2])

    def testCollectivesBlock(self):
        comm = self.COMM
        comm.Bcast(self.null_b)
        comm.Gather(self.null_b, self.null_b)
        comm.Scatter(self.null_b, self.null_b)
        comm.Allgather(self.null_b, self.null_b)
        comm.Alltoall(self.null_b, self.null_b)

    def testCollectivesVector(self):
        comm = self.COMM
        comm.Gatherv(self.null_b, self.null_v)
        comm.Scatterv(self.null_v, self.null_b)
        comm.Allgatherv(self.null_b, self.null_v)
        comm.Alltoallv(self.null_v, self.null_v)

    @unittest.skipMPI('openmpi')
    def testReductions(self):
        comm = self.COMM
        comm.Reduce(self.null_b, self.null_b)
        comm.Allreduce(self.null_b, self.null_b)
        comm.Reduce_scatter_block(self.null_b, self.null_b)
        rcnt = [0]*comm.Get_size()
        comm.Reduce_scatter(self.null_b, self.null_b, rcnt)
        try: comm.Scan(self.null_b, self.null_b)
        except NotImplementedError: pass
        try: comm.Exscan(self.null_b, self.null_b)
        except NotImplementedError: pass

class TestMessageZeroSelf(BaseTestMessageZero, unittest.TestCase):
    COMM = MPI.COMM_SELF

class TestMessageZeroWorld(BaseTestMessageZero, unittest.TestCase):
    COMM = MPI.COMM_WORLD


if __name__ == '__main__':
    unittest.main()