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 all_gather() collective. 8 9from __future__ import print_function 10import mpi 11from generators import * 12 13def all_gather_test(comm, generator, kind): 14 if comm.rank == 0: print ("Gathering %s..." % (kind,)), 15 my_value = generator(comm.rank) 16 result = mpi.all_gather(comm, my_value) 17 for p in range(0, comm.size): 18 assert result[p] == generator(p) 19 if comm.rank == 0: print( "OK.") 20 21 return 22 23all_gather_test(mpi.world, int_generator, "integers") 24all_gather_test(mpi.world, gps_generator, "GPS positions") 25all_gather_test(mpi.world, string_generator, "strings") 26all_gather_test(mpi.world, string_list_generator, "list of strings") 27