This material is part of the course Practical Introduction to Parallel Programming and meant for educational purposes only.
Task
Implement a game in which two groups of processes compete with each other by drawing random numbers.
The game proceeds in \(N\) rounds in which the two groups of processes generate a random number. The group with the largest number wins that round.
To generate a number per group, all processes in that group generate a random number independently. The largest number across all processes in the group is compared with the random number generated in a similar way by the other group.
The process with rank zero (within MPI_COMM_WORLD
) should keep track of the number of wins for each group.
Hints
Use the provided function next_random
to generate the stream of random numbers.
Test the program with 2, 3, 4, 5, 6, 7 and 8 processes. Do the results match your expectations?
Note that this exercise is not so much about performance but about correctness.