4 from generator_utils import *
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
11 Description: @{shortdesc}@
14 Version of MPI: Conforms to MPI 1.1, does not require MPI 2 implementation
17 P2P!basic: @{p2pfeature}@
18 P2P!nonblocking: @{ip2pfeature}@
19 P2P!persistent: Lacking
21 COLL!nonblocking: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
39 int main(int argc, char **argv) {
47 MPI_Init(&argc, &argv);
48 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
49 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
50 printf("Hello from rank %d \\n", rank);
53 printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
55 MPI_Comm newcom = MPI_COMM_WORLD;
56 MPI_Datatype type = MPI_INT;
67 @{operation1a}@ /* MBIERROR1 */
75 @{operation2a}@ /* MBIERROR2 */
90 printf("Rank %d finished normally\\n", rank);
97 for s in send + isend:
98 for r in recv + irecv:
100 patterns = {'p':p, 's': s, 'r': r}
101 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
102 patterns['p2pfeature'] = 'Yes' if s in send or r in recv else 'Lacking'
103 patterns['ip2pfeature'] = 'Yes' if s in isend or r in irecv else 'Lacking'
107 patterns['init1a'] = init[p]("1")
108 patterns['init1b'] = init[s]("1")
109 patterns['init1c'] = init[r]("2")
110 patterns['init2a'] = init[p]("1")
111 patterns['init2b'] = init[r]("3")
112 patterns['init2c'] = init[s]("4")
113 patterns['fini1a'] = fini[p]("1")
114 patterns['fini1b'] = fini[s]("1")
115 patterns['fini1c'] = fini[r]("2")
116 patterns['fini2a'] = fini[p]("1")
117 patterns['fini2b'] = fini[r]("3")
118 patterns['fini2c'] = fini[s]("4")
119 patterns['free1a'] = free[p]("1")
120 patterns['free1b'] = free[s]("1")
121 patterns['free1c'] = free[r]("2")
122 patterns['free2a'] = free[p]("1")
123 patterns['free2b'] = free[r]("3")
124 patterns['free2c'] = free[s]("4")
125 patterns['operation1a'] = operation[p]("1")
126 patterns['operation1b'] = operation[s]("1")
127 patterns['operation1c'] = operation[r]("2")
128 patterns['operation2a'] = operation[p]("1")
129 patterns['operation2b'] = operation[r]("3")
130 patterns['operation2c'] = operation[s]("4")
132 # Generate the incorrect matching
134 replace['shortdesc'] = 'MPI_Probe is called before MPI_Recv.'
135 replace['longdesc'] = 'MPI_Probe is a blocking call that returns only after a matching message has been found. By calling MPI_Probe before MPI_Recv, a deadlock is created.'
136 replace['outcome'] = 'ERROR: CallMatching'
137 replace['errormsg'] = 'P2P mistmatch. @{p}@ at @{filename}@:@{line:MBIERROR1}@ and @{filename}@:@{line:MBIERROR2}@ are called before @{r}@.'
138 make_file(template, f'CallOrdering_{p}_{r}_{s}_nok.c', replace)
140 # Generate a correct matching
142 replace['shortdesc'] = 'Correct use of MPI_Probe.'
143 replace['longdesc'] = 'Correct use of MPI_Probe.'
144 replace['outcome'] = 'OK'
145 replace['errormsg'] = 'OK'
146 replace['operation1a'] = operation[s]("1")
147 replace['operation1b'] = operation[p]("1")
148 make_file(template, f'CallOrdering_{p}_{r}_{s}_ok.c', replace)