]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/mpi/test/python/broadcast_test.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / mpi / test / python / broadcast_test.py
1 #!/usr/bin/env python
2 # Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
3
4 # Use, modification and distribution is subject to the Boost Software
5 # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 # http://www.boost.org/LICENSE_1_0.txt)
7
8 # Test broadcast() collective.
9
10 from __future__ import print_function
11 import mpi
12
13 def broadcast_test(comm, value, kind, root):
14 if comm.rank == 0:
15 print ("Broadcasting %s from root %d..." % (kind, root)),
16 got_value = None
17 got_value = mpi.broadcast(comm, value, root)
18 if comm.rank == 0:
19 print ("OK.")
20 return
21
22 broadcast_test(mpi.world, 17, 'integer', 0)
23 broadcast_test(mpi.world, 'Hello, World!', 'string', 0)
24 broadcast_test(mpi.world, ['Hello', 'MPI', 'Python', 'World'],
25 'list of strings', 0)
26 if mpi.world.size > 1:
27 broadcast_test(mpi.world, 17, 'integer', 1)
28 broadcast_test(mpi.world, 'Hello, World!', 'string', 1)
29 broadcast_test(mpi.world, ['Hello', 'MPI', 'Python', 'World'],
30 'list of strings', 1)
31
32