-/* skeleton for a broadcast routine from node 0 */\r
-\r
-#include <stdio.h>\r
-#include <math.h>\r
-\r
-int main(int argc, char *argv[])\r
-{\r
- int two_to_generation;\r
- int rank, size;\r
- int to, from;\r
-\r
- /* scan over a hypothetical virtual machine of 15 nodes */\r
- size = 15;\r
- for (rank=0; rank < size; rank++)\r
- {\r
- printf("rank %d", rank);\r
-\r
- /* two_to_generation reflects the steps in the tree broadcast */\r
- two_to_generation = 1;\r
- while(two_to_generation < size)\r
- {\r
- /* receive message */\r
- if (rank >= two_to_generation && rank < two_to_generation*2)\r
- {\r
- from = rank - two_to_generation;\r
- if ( from < size )\r
- printf(" -- from %d", from);\r
- }\r
- /* send message */\r
- if (rank < two_to_generation)\r
- {\r
- to = rank + two_to_generation;\r
- if ( to < size )\r
- printf(" -- to %d", to);\r
- }\r
- two_to_generation = 2 * two_to_generation;\r
- }\r
- /* done for a given rank */\r
- printf("\n");\r
- }\r
-}\r
+/* skeleton for a broadcast routine from node 0 */
+
+#include <stdio.h>
+#include <math.h>
+int main(int argc, char *argv[])
+{
+ int two_to_generation;
+ int rank, size;
+ int to, from;
+
+ /* scan over a hypothetical virtual machine of 15 nodes */
+ size = 15;
+ for (rank = 0; rank < size; rank++) {
+ printf("rank %d", rank);
+
+ /* two_to_generation reflects the steps in the tree broadcast */
+ two_to_generation = 1;
+ while (two_to_generation < size) {
+
+ /* receive message */
+ if (rank >= two_to_generation
+ && rank < two_to_generation * 2) {
+ from = rank - two_to_generation;
+ if (from < size)
+ printf(" -- from %d", from);
+ }
+
+ /* send message */
+ if (rank < two_to_generation) {
+ to = rank + two_to_generation;
+ if (to < size)
+ printf(" -- to %d", to);
+ }
+ two_to_generation = 2 * two_to_generation;
+ }
+
+ /* done for a given rank */
+ printf("\n");
+ }
+}