• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 gather() collective.
8 
9 from __future__ import print_function
10 import mpi
11 from generators import *
12 
13 def gather_test(comm, generator, kind, root):
14     if comm.rank == root:
15         print ("Gathering %s to root %d..." % (kind, root)),
16     my_value = generator(comm.rank)
17     result = mpi.gather(comm, my_value, root)
18     if comm.rank == root:
19         for p in range(0, comm.size):
20             assert result[p] == generator(p)
21         print ("OK.")
22     else:
23         assert result == None
24     return
25 
26 gather_test(mpi.world, int_generator, "integers", 0)
27 gather_test(mpi.world, int_generator, "integers", 1)
28 gather_test(mpi.world, gps_generator, "GPS positions", 0)
29 gather_test(mpi.world, gps_generator, "GPS positions", 1)
30 gather_test(mpi.world, string_generator, "strings", 0)
31 gather_test(mpi.world, string_generator, "strings", 1)
32 gather_test(mpi.world, string_list_generator, "list of strings", 0)
33 gather_test(mpi.world, string_list_generator, "list of strings", 1)
34