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['outcome1'] = 'ERROR: BufferingHazard'
127 replace['errormsg1'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause by two processes call {s} before {r}.'
128 gen.make_file(template, f'P2PBuffering_{s}_{r}_{s}_{r}_nok.c', replace)
130 # Generate the incorrect matching with send message to the same process depending on the buffering mode (send + recv)
131 replace = patterns.copy().copy()
132 replace['origin'] = 'RTED'
133 replace['src1'] = '0'
134 replace['dest1'] = '0'
135 replace['src2'] = '1'
136 replace['dest2'] = '1'
137 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ may not be matched'
138 replace['longdesc'] = 'Processes 0 and 1 both call @{s}@ and @{r}@. This results in a deadlock depending on the buffering mode'
139 replace['outcome1'] = 'ERROR: BufferingHazard'
140 replace['errormsg1'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause Send message to the same process.'
141 gen.make_file(template, f'P2PBuffering_SameProcess_{s}_{r}_nok.c', replace)
143 # Generate the incorrect matching with circular send message depending on the buffering mode (send + recv)
144 replace = patterns.copy().copy()
145 replace['origin'] = 'RTED'
146 replace['src1'] = '(nprocs - 1)'
147 replace['dest1'] = '1'
148 replace['src2'] = '0'
149 replace['dest2'] = '2'
150 replace['src3'] = '(rank - 1)'
151 replace['dest3'] = '((rank + 1) % nprocs)'
152 replace['fini1c'] = gen.fini[s]("1")
153 replace['fini2c'] = gen.fini[r]("2")
154 replace['operation1c'] = gen.operation[s]("1") + ' /* MBIERROR3 */'
155 replace['operation2c'] = gen.operation[r]("2")
156 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ may not be matched'
157 replace['longdesc'] = 'Processes 0 and 1 both call @{s}@ and @{r}@. This results in a deadlock depending on the buffering mode'
158 replace['outcome1'] = 'ERROR: BufferingHazard'
159 replace['errormsg1'] = f'Buffering Hazard. Possible deadlock depending the buffer size of MPI implementation and system environment cause circular send message.'
160 gen.make_file(template, f'P2PBuffering_Circular_{s}_{r}_nok.c', replace)
162 # Generate the incorrect matching depending on the buffering mode (recv + send)
163 replace = patterns.copy()
164 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ are not matched'
165 replace['longdesc'] = 'Processes 0 and 1 both call @{r}@ and @{s}@. This results in a deadlock'
166 replace['outcome1'] = 'ERROR: CallMatching'
167 replace['errormsg1'] = 'ERROR: CallMatching'
168 replace['operation1a'] = gen.operation[r]("2")
169 replace['fini1a'] = gen.fini[r]("2")
170 replace['operation2a'] = gen.operation[s]("1")
171 replace['fini2a'] = gen.fini[s]("1")
172 replace['operation1b'] = gen.operation[r]("2")
173 replace['fini1b'] = gen.fini[r]("2")
174 replace['operation2b'] = gen.operation[s]("1")
175 replace['fini2b'] = gen.fini[s]("1")
176 gen.make_file(template, f'P2PCallMatching_{r}_{s}_{r}_{s}_nok.c', replace)
178 # Generate the correct matching
179 replace = patterns.copy()
180 replace['shortdesc'] = 'Point to point @{s}@ and @{r}@ are correctly matched'
181 replace['longdesc'] = 'Process 0 calls @{s}@ and process 1 calls @{r}@.'
182 replace['outcome1'] = 'OK'
183 replace['errormsg1'] = 'OK'
184 replace['fini1a'] = gen.fini[s]("1")
185 replace['fini2a'] = gen.fini[r]("2")
186 replace['operation1a'] = gen.operation[s]("1")
187 replace['operation2a'] = gen.operation[r]("2")
188 gen.make_file(template, f'P2PCallMatching_{s}_{r}_{r}_{s}_ok.c', replace)