]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpi/test/python/ring_test.py
1 # Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
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)
7 # Test basic communication.
9 import boost
.parallel
.mpi
as mpi
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
;
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
24 other_value
= comm
.recv(msg
.source
, msg
.tag
)
25 assert value
== other_value
26 comm
.send(next_peer
, 0, other_value
)
33 if mpi
.world
.size
< 2:
34 print "ERROR: ring_test.py must be executed with more than one process"
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)