4 import generator_utils as gen
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
20 COLL!basic: @{collfeature}@
21 COLL!nonblocking: @{icollfeature}@
22 COLL!persistent: Lacking
28 $ mpirun -np 2 ${EXE} 1
31 $ mpirun -np 2 ${EXE} 2
35 ////////////////////// End of MBI headers /////////////////// */
43 int main(int argc, char **argv) {
53 MPI_Init(&argc, &argv);
54 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
55 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
56 printf("Hello from rank %d \\n", rank);
59 printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
62 printf("MBI ERROR: This test needs at least 1 argument to produce a bug!\\n");
64 int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
65 MPI_Comm newcom = MPI_COMM_WORLD;
66 MPI_Datatype type = MPI_INT;
69 int n = atoi(argv[1]);
76 if ((n % 2) == 0) { @{errorcond}@
93 printf("Rank %d finished normally\\n", rank);
99 for s in gen.send + gen.isend:
100 for r in gen.recv + gen.irecv:
102 patterns = {'s': s, 'r': r}
103 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
104 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
105 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
106 patterns['collfeature'] = 'Lacking'
107 patterns['icollfeature'] = 'Lacking'
111 patterns['init1'] = gen.init[s]("1")
112 patterns['operation1a'] = gen.operation[s]("1").replace("buf1", "buffer").replace("dest", "1")
113 patterns['operation1b'] = gen.operation[s]("1").replace("buf1", "buffer").replace("dest", "1")
114 patterns['fini1a'] = gen.fini[s]("1")
115 patterns['fini1b'] = gen.fini[s]("1")
116 patterns['free1'] = gen.free[s]("1")
118 patterns['init2'] = gen.init[r]("2")
119 patterns['operation2'] = gen.operation[r]("2").replace("buf2", "buffer").replace("src", "0")
120 patterns['fini2'] = gen.fini[r]("2")
121 patterns['free2'] = gen.free[r]("2")
123 patterns['errorcond'] = ''
124 patterns['addcond'] = 'if (rank == 1)'
126 # Generate a correct matching
127 replace = patterns.copy()
128 replace['shortdesc'] = 'Correct call ordering.'
129 replace['longdesc'] = 'Correct call ordering.'
130 replace['outcome1'] = 'OK'
131 replace['errormsg1'] = 'OK'
132 replace['outcome2'] = 'OK'
133 replace['errormsg2'] = 'OK'
134 gen.make_file(template, f'InputHazardCallOrdering_{r}_{s}_ok.c', replace)
136 # Generate the incorrect matching
137 replace = patterns.copy()
138 replace['shortdesc'] = 'Missing Send function.'
139 replace['longdesc'] = 'Missing Send function call for a path depending to input, a deadlock is created.'
140 replace['outcome1'] = 'OK'
141 replace['errormsg1'] = 'OK'
142 replace['outcome2'] = 'ERROR: IHCallMatching'
143 replace['errormsg2'] = 'P2P mistmatch. Missing @{r}@ at @{filename}@:@{line:MBIERROR}@.'
144 replace['errorcond'] = '/* MBIERROR */'
145 replace['operation1b'] = ''
146 replace['fini1b'] = ''
147 gen.make_file(template, f'InputHazardCallOrdering_{r}_{s}_nok.c', replace)
153 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
154 patterns['p2pfeature'] = 'Lacking'
155 patterns['ip2pfeature'] = 'Lacking'
156 patterns['collfeature'] = 'Yes' if c in gen.coll else 'Lacking'
157 patterns['icollfeature'] = 'Yes' if c in gen.icoll else 'Lacking'
160 patterns['init1'] = gen.init[c]("1")
161 patterns['operation1a'] = gen.operation[c]("1")
162 patterns['operation1b'] = gen.operation[c]("1")
163 patterns['fini1a'] = gen.fini[c]("1")
164 patterns['fini1b'] = gen.fini[c]("1")
165 patterns['free1'] = gen.free[c]("1")
167 patterns['init2'] = gen.init[c]("2")
168 patterns['operation2'] = gen.operation[c]("2")
169 patterns['fini2'] = gen.fini[c]("2")
170 patterns['free2'] = gen.free[c]("2")
172 patterns['errorcond'] = ''
173 patterns['addcond'] = ''
175 # Generate a correct matching
176 replace = patterns.copy()
177 replace['shortdesc'] = 'Correct call ordering.'
178 replace['longdesc'] = 'Correct call ordering.'
179 replace['outcome1'] = 'OK'
180 replace['errormsg1'] = 'OK'
181 replace['outcome2'] = 'OK'
182 replace['errormsg2'] = 'OK'
183 gen.make_file(template, f'InputHazardCallOrdering_{c}_ok.c', replace)
185 # Generate the incorrect matching
186 replace = patterns.copy()
187 replace['shortdesc'] = 'Missing collective function call.'
188 replace['longdesc'] = 'Missing collective function call for a path depending to input, a deadlock is created.'
189 replace['outcome1'] = 'OK'
190 replace['errormsg1'] = 'OK'
191 replace['outcome2'] = 'ERROR: IHCallMatching'
192 replace['errormsg2'] = 'P2P mistmatch. Missing @{c}@ at @{filename}@:@{line:MBIERROR}@.'
193 replace['errorcond'] = '/* MBIERROR */'
194 replace['operation1b'] = ''
195 replace['fini1b'] = ''
196 gen.make_file(template, f'InputHazardCallOrdering_{c}_nok.c', replace)