5 import generator_utils as gen
7 template = """// @{generatedby}@
8 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
12 Description: @{shortdesc}@
16 P2P!basic: @{p2pfeature}@
17 P2P!nonblocking: @{ip2pfeature}@
18 P2P!persistent: Lacking
20 COLL!nonblocking: Lacking
21 COLL!persistent: Lacking
27 $ mpirun -np 4 $zero_buffer ${EXE}
30 $ mpirun -np 4 $infty_buffer ${EXE}
34 ////////////////////// End of MBI headers /////////////////// */
41 int main(int argc, char **argv) {
45 int stag = 0, rtag = 0;
48 MPI_Init(&argc, &argv);
49 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
50 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
51 printf("Hello from rank %d \\n", rank);
54 printf("MBI ERROR: This test needs at least 4 processes to produce a bug!\\n");
56 MPI_Comm newcom = MPI_COMM_WORLD;
57 MPI_Datatype type = MPI_INT;
62 src=@{src1}@,dest=@{dest1}@;
63 @{operation1a}@ /* MBIERROR1 */
67 }else if (rank == 1) {
68 src=@{src2}@,dest=@{dest2}@;
69 @{operation1b}@ /* MBIERROR2 */
74 src=@{src3}@,dest=@{dest3}@;
84 printf("Rank %d finished normally\\n", rank);
89 for s in gen.send + gen.isend:
90 for r in gen.recv + gen.irecv:
92 patterns = {'s': s, 'r': r}
93 patterns['origin'] = 'MBI'
94 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
95 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
96 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
99 patterns['src1'] = '1'
100 patterns['dest1'] = '1'
101 patterns['src2'] = '0'
102 patterns['dest2'] = '0'
103 patterns['src3'] = '0'
104 patterns['dest3'] = '0'
105 patterns['init1'] = gen.init[s]("1")
106 patterns['init2'] = gen.init[r]("2")
107 patterns['fini1a'] = gen.fini[s]("1")
108 patterns['fini1b'] = gen.fini[s]("1")
109 patterns['fini1c'] = ''
110 patterns['fini2a'] = gen.fini[r]("2")
111 patterns['fini2b'] = gen.fini[r]("2")
112 patterns['fini2c'] = ''
113 patterns['free1'] = gen.free[s]("1")
114 patterns['free2'] = gen.free[r]("2")
115 patterns['operation1a'] = gen.operation[s]("1")
116 patterns['operation2a'] = gen.operation[r]("2")
117 patterns['operation1b'] = gen.operation[s]("1")
118 patterns['operation2b'] = gen.operation[r]("2")
119 patterns['operation1c'] = ''
120 patterns['operation2c'] = ''
122 # Generate the incorrect matching depending on the buffering mode (send + recv)
123 replace = patterns.copy()
124 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ may not be matched'
125 replace['longdesc'] = 'Processes 0 and 1 both call @{s}@ and @{r}@. This results in a deadlock depending on the buffering mode'
126 replace['outcome_zerob'] = 'ERROR: BufferingHazard'
127 replace['errormsg_zerob'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause by two processes call {s} before {r}.'
128 replace['outcome_infty'] = 'OK'
129 replace['errormsg_infty'] = 'OK'
130 gen.make_file(template, f'P2PBuffering_{s}_{r}_{s}_{r}_nok.c', replace)
132 # Generate the incorrect matching with send message to the same process depending on the buffering mode (send + recv)
133 replace = patterns.copy().copy()
134 replace['origin'] = 'RTED'
135 replace['src1'] = '0'
136 replace['dest1'] = '0'
137 replace['src2'] = '1'
138 replace['dest2'] = '1'
139 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ may not be matched'
140 replace['longdesc'] = 'Processes 0 and 1 both call @{s}@ and @{r}@. This results in a deadlock depending on the buffering mode'
141 replace['outcome_zerob'] = 'ERROR: BufferingHazard'
142 replace['errormsg_zerob'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause Send message to the same process.'
143 replace['outcome_infty'] = 'OK'
144 replace['errormsg_infty'] = 'OK'
145 gen.make_file(template, f'P2PBuffering_SameProcess_{s}_{r}_nok.c', replace)
147 # Generate the incorrect matching with circular send message depending on the buffering mode (send + recv)
148 replace = patterns.copy().copy()
149 replace['origin'] = 'RTED'
150 replace['src1'] = '(nprocs - 1)'
151 replace['dest1'] = '1'
152 replace['src2'] = '0'
153 replace['dest2'] = '2'
154 replace['src3'] = '(rank - 1)'
155 replace['dest3'] = '((rank + 1) % nprocs)'
156 replace['fini1c'] = gen.fini[s]("1")
157 replace['fini2c'] = gen.fini[r]("2")
158 replace['operation1c'] = gen.operation[s]("1") + ' /* MBIERROR3 */'
159 replace['operation2c'] = gen.operation[r]("2")
160 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ may not be matched'
161 replace['longdesc'] = 'Processes 0 and 1 both call @{s}@ and @{r}@. This results in a deadlock depending on the buffering mode'
162 replace['outcome_zerob'] = 'ERROR: BufferingHazard'
163 replace['errormsg_zerob'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause circular send message.'
164 replace['outcome_infty'] = 'OK'
165 replace['errormsg_infty'] = 'OK'
166 gen.make_file(template, f'P2PBuffering_Circular_{s}_{r}_nok.c', replace)
168 # Generate the incorrect matching depending on the buffering mode (recv + send)
169 replace = patterns.copy()
170 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ are not matched'
171 replace['longdesc'] = 'Processes 0 and 1 both call @{r}@ and @{s}@. This results in a deadlock'
172 replace['outcome_zerob'] = 'ERROR: CallMatching'
173 replace['errormsg_zerob'] = 'ERROR: CallMatching'
174 replace['outcome_infty'] = 'ERROR: CallMatching'
175 replace['errormsg_infty'] = 'ERROR: CallMatching'
176 replace['operation1a'] = gen.operation[r]("2")
177 replace['fini1a'] = gen.fini[r]("2")
178 replace['operation2a'] = gen.operation[s]("1")
179 replace['fini2a'] = gen.fini[s]("1")
180 replace['operation1b'] = gen.operation[r]("2")
181 replace['fini1b'] = gen.fini[r]("2")
182 replace['operation2b'] = gen.operation[s]("1")
183 replace['fini2b'] = gen.fini[s]("1")
184 gen.make_file(template, f'P2PCallMatching_{r}_{s}_{r}_{s}_nok.c', replace)
186 # Generate the correct matching
187 replace = patterns.copy()
188 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ are correctly matched'
189 replace['longdesc'] = 'Process 0 calls @{s}@ and process 1 calls @{r}@.'
190 replace['outcome_zerob'] = 'OK'
191 replace['errormsg_zerob'] = 'OK'
192 replace['outcome_infty'] = 'OK'
193 replace['errormsg_infty'] = 'OK'
194 patterns['init1'] = gen.init[s]("1")
195 replace['operation1a'] = gen.operation[s]("1")
196 replace['fini1a'] = gen.fini[s]("1")
197 replace['operation2a'] = ''
198 replace['fini2a'] = ''
200 patterns['init2'] = gen.init[r]("2")
201 replace['operation1b'] = gen.operation[r]("2")
202 replace['fini1b'] = gen.fini[r]("2")
203 replace['operation2b'] = ''
204 replace['fini2b'] = ''
205 gen.make_file(template, f'P2PCallMatching_{s}_{r}_{r}_{s}_ok.c', replace)