]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpi/test/python/ring_test.py
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / mpi / test / python / ring_test.py
1 # Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
2
3 # Use, modification and distribution is subject to the Boost Software
4 # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 # http://www.boost.org/LICENSE_1_0.txt)
6
7 # Test basic communication.
8
9 import boost.parallel.mpi as mpi
10
11 def ring_test(comm, value, kind, root):
12 next_peer = (comm.rank + 1) % comm.size;
13 prior_peer = (comm.rank + comm.size - 1) % comm.size;
14
15 if comm.rank == root:
16 print ("Passing %s around a ring from root %d..." % (kind, root)),
17 comm.send(next_peer, 0, value)
18 (other_value, stat) = comm.recv(return_status = True)
19 assert value == other_value
20 assert stat.source == prior_peer
21 assert stat.tag == 0
22 else:
23 msg = comm.probe()
24 other_value = comm.recv(msg.source, msg.tag)
25 assert value == other_value
26 comm.send(next_peer, 0, other_value)
27
28 comm.barrier()
29 if comm.rank == root:
30 print "OK"
31 pass
32
33 if mpi.world.size < 2:
34 print "ERROR: ring_test.py must be executed with more than one process"
35 mpi.world.abort(-1);
36
37 ring_test(mpi.world, 17, 'integers', 0)
38 ring_test(mpi.world, 17, 'integers', 1)
39 ring_test(mpi.world, 'Hello, World!', 'string', 0)
40 ring_test(mpi.world, 'Hello, World!', 'string', 1)
41 ring_test(mpi.world, ['Hello', 'MPI', 'Python', 'World'], 'list of strings', 0)
42 ring_test(mpi.world, ['Hello', 'MPI', 'Python', 'World'], 'list of strings', 1)