]>
Commit | Line | Data |
---|---|---|
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 all_to_all() collective. | |
8 | ||
20effc67 TL |
9 | from __future__ import print_function |
10 | import mpi | |
7c673cae FG |
11 | from generators import * |
12 | ||
13 | def all_to_all_test(comm, generator, kind): | |
14 | if comm.rank == 0: | |
15 | print ("All-to-all transmission of %s..." % (kind,)), | |
16 | ||
17 | values = list() | |
18 | for p in range(0, comm.size): | |
19 | values.append(generator(p)) | |
20 | result = mpi.all_to_all(comm, values) | |
21 | ||
22 | for p in range(0, comm.size): | |
23 | assert result[p] == generator(comm.rank) | |
24 | ||
20effc67 | 25 | if comm.rank == 0: print ("OK.") |
7c673cae FG |
26 | return |
27 | ||
28 | all_to_all_test(mpi.world, int_generator, "integers") | |
29 | all_to_all_test(mpi.world, gps_generator, "GPS positions") | |
30 | all_to_all_test(mpi.world, string_generator, "strings") | |
31 | all_to_all_test(mpi.world, string_list_generator, "list of strings") |