1 /* skeleton for a broadcast routine from node 0 */
5 int main(int argc, char *argv[])
11 /* scan over a hypothetical virtual machine of 15 nodes */
13 for (rank = 0; rank < size; rank++) {
14 printf("rank %d", rank);
16 /* two_to_generation reflects the steps in the tree broadcast */
17 two_to_generation = 1;
18 while (two_to_generation < size) {
21 if (rank >= two_to_generation
22 && rank < two_to_generation * 2) {
23 from = rank - two_to_generation;
25 printf(" -- from %d", from);
29 if (rank < two_to_generation) {
30 to = rank + two_to_generation;
32 printf(" -- to %d", to);
34 two_to_generation = 2 * two_to_generation;
37 /* done for a given rank */