2 * Program to test the fairness of the MPI implementation over source.
3 * All of the programs wait on a barrier, then node 0 starts receiving
4 * small messages using ANY_SOURCE from all of the other nodes who
5 * send as much as they can. Node 0 collects statistics on the rate
6 * messages are received from each source. (Every N messages it
7 * prints out what percentage of the last N received were from each
8 * source. It does this for <size-1> times.
10 * This program should be run with at least 8 nodes just to be (un)fair
12 * Patrick Bridges * bridges@mcs.anl.gov * patrick@CS.MsState.Edu
26 int rank, size, an_int[MSZ];
27 char *Current_Test = NULL;
31 MPI_Init(&argc, &argv);
33 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
34 MPI_Comm_size(MPI_COMM_WORLD, &size);
35 Test_Init("fairnessm", rank);
37 /* Wait for everyone to be ready */
40 /* Initialize an array to keep statistics in */
41 num_array = (int *)malloc((size - 1) * sizeof(int));
42 MPID_SetRecvDebugFlag(1);
43 MPI_Barrier(MPI_COMM_WORLD);
45 for (i = 0; i < size - 1; i++) {
46 /* Clear the buffer of counts */
47 memset(num_array, 0, (size - 1) * sizeof(int));
48 for (j = 0; j < MPG; j++) {
49 MPI_Recv(an_int, MSZ, MPI_INT, MPI_ANY_SOURCE, 2000,
50 MPI_COMM_WORLD, &Status);
51 MPE_Log_receive(Status.MPI_SOURCE, 2000, MSZ * sizeof(int));
52 num_array[Status.MPI_SOURCE - 1]++;
54 Test_Printf("Statistics for message group %d:\n", i + 1);
55 for (j = 0; j < size -1 ; j++)
56 Test_Printf("%f%% of last %d messages received \
57 were from source %d.\n",
58 num_array[j]/2.0, MPG, j + 1);
61 (void)Summarize_Test_Results();
62 MPE_Finish_log("/home/bridges/fairness.log");
66 MPI_Barrier(MPI_COMM_WORLD);
67 for (i = 0; i < MPG; i++) {
68 MPI_Send(an_int, MSZ, MPI_INT, 0, 2000, MPI_COMM_WORLD);
69 MPE_Log_send(0, 2000, MSZ * sizeof(int));
71 MPE_Finish_log("/home/bridges/fairness.log");