all_to_all_test.py 976 B

123456789101112131415161718192021222324252627282930
  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_to_all() collective.
  6. import boost.parallel.mpi as mpi
  7. from generators import *
  8. def all_to_all_test(comm, generator, kind):
  9. if comm.rank == 0:
  10. print ("All-to-all transmission of %s..." % (kind,)),
  11. values = list()
  12. for p in range(0, comm.size):
  13. values.append(generator(p))
  14. result = mpi.all_to_all(comm, values)
  15. for p in range(0, comm.size):
  16. assert result[p] == generator(comm.rank)
  17. if comm.rank == 0: print "OK."
  18. return
  19. all_to_all_test(mpi.world, int_generator, "integers")
  20. all_to_all_test(mpi.world, gps_generator, "GPS positions")
  21. all_to_all_test(mpi.world, string_generator, "strings")
  22. all_to_all_test(mpi.world, string_list_generator, "list of strings")