Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / fairness / fairness-euih.c
1 /* 
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.
9  *
10  * This program should be run with at least 8 nodes just to be (un)fair
11  *
12  * Patrick Bridges * bridges@mcs.anl.gov * patrick@CS.MsState.Edu 
13  */
14
15 #include <stdio.h>
16 #include "test.h"
17 #define MPG 200
18 #define MSZ 1
19
20 int 
21 main(argc, argv)
22 int argc;
23 char **argv;
24 {
25     int rank, size, an_int[MSZ]; 
26     int dummy[4], d1, d2;
27     char *Current_Test = NULL;
28     int *num_array, i, j;
29     int dontcare, allgrp;
30     
31     /* Initialize the environment */
32     mp_environ(&size,&rank);
33
34     /* Get allgrp from the task */
35     d1 = 4; d2 = 3;
36     mp_task_query(dummy,&d1,&d2);
37     allgrp = dummy[3];
38     dontcare = dummy[0];
39
40     Test_Init("fairness", rank);
41
42     /* Wait for everyone to be ready */
43     if (rank == 0) { 
44         /* Initialize an array to keep statistics in */
45         num_array = (int *)malloc((size - 1) * sizeof(int));
46
47         mp_sync(&allgrp);
48         
49         for (i = 0; i < size - 1; i++) {
50             /* Clear the buffer of counts */
51             memset(num_array, 0, (size - 1) * sizeof(int));
52             for (j = 0; j < MPG; j++) {
53                 d1 = sizeof(int)*MSZ;
54                 d2 = 2000;
55                 mp_brecv(an_int, &d1, &dontcare, &d2);
56                 num_array[d1 - 1]++;
57             }
58             Test_Printf("Statistics for message group %d:\n", i + 1);
59             for (j = 0; j < size -1 ; j++)
60                 Test_Printf("%f%% of last %d messages received \
61 were from source %d.\n",
62                             num_array[j]*100.0/MPG, MPG, j + 1);
63         }
64         free(num_array);
65         (void)Summarize_Test_Results();
66     } else {
67         mp_sync(&allgrp);
68         for (i = 0; i < MPG; i++) {
69             int d3, d4;
70
71             d1 = MSZ*sizeof(int);
72             d2 = 0;
73             d3 = 2000;
74             d4 = 0;
75             mp_bend(an_int, &d1, &d2, &d3, &d4);
76         }
77     }
78
79     return 0;
80 }