File: test_msgzero.py

package info (click to toggle)
mpi4py 4.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,540 kB
  • sloc: python: 34,465; ansic: 16,475; makefile: 614; sh: 325; cpp: 193; f90: 178
file content (67 lines) | stat: -rw-r--r-- 1,871 bytes parent folder | download | duplicates (2)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
import mpiunittest as unittest

from mpi4py import MPI


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()