all_gather_test.py 896 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
  2. # Use, modification and distribution is subject to the Boost Software
  3. # License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. # http://www.boost.org/LICENSE_1_0.txt)
  5. # Test all_gather() collective.
  6. import boost.parallel.mpi as mpi
  7. from generators import *
  8. def all_gather_test(comm, generator, kind):
  9. if comm.rank == 0: print ("Gathering %s..." % (kind,)),
  10. my_value = generator(comm.rank)
  11. result = mpi.all_gather(comm, my_value)
  12. for p in range(0, comm.size):
  13. assert result[p] == generator(p)
  14. if comm.rank == 0: print "OK."
  15. return
  16. all_gather_test(mpi.world, int_generator, "integers")
  17. all_gather_test(mpi.world, gps_generator, "GPS positions")
  18. all_gather_test(mpi.world, string_generator, "strings")
  19. all_gather_test(mpi.world, string_list_generator, "list of strings")