]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/mpi/test/python/scatter_test.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / mpi / test / python / scatter_test.py
CommitLineData
7c673cae
FG
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 scatter() collective.
8
20effc67
TL
9from __future__ import print_function
10import mpi
7c673cae
FG
11from generators import *
12
13def scatter_test(comm, generator, kind, root):
14 if comm.rank == root:
15 print ("Scattering %s from root %d..." % (kind, root)),
16
17 if comm.rank == root:
18 values = list()
19 for p in range(0, comm.size):
20 values.append(generator(p))
21 result = mpi.scatter(comm, values, root = root)
22 else:
23 result = mpi.scatter(comm, root = root);
24
25 assert result == generator(comm.rank)
26
20effc67 27 if comm.rank == root: print ("OK.")
7c673cae
FG
28 return
29
30scatter_test(mpi.world, int_generator, "integers", 0)
31scatter_test(mpi.world, int_generator, "integers", 1)
32scatter_test(mpi.world, gps_generator, "GPS positions", 0)
33scatter_test(mpi.world, gps_generator, "GPS positions", 1)
34scatter_test(mpi.world, string_generator, "strings", 0)
35scatter_test(mpi.world, string_generator, "strings", 1)
36scatter_test(mpi.world, string_list_generator, "list of strings", 0)
37scatter_test(mpi.world, string_list_generator, "list of strings", 1)