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]);
77 if ((n % 2) == 0) { @{errorcond}@
95 printf("Rank %d finished normally\\n", rank);
101 for s in gen.send + gen.isend:
102 for r in gen.recv + gen.irecv:
104 patterns = {'s': s, 'r': r}
105 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
106 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
107 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
108 patterns['collfeature'] = 'Lacking'
109 patterns['icollfeature'] = 'Lacking'
113 patterns['init1'] = gen.init[s]("1")
114 patterns['operation1a'] = gen.operation[s]("1").replace("buf1", "buffer")
115 patterns['operation1b'] = gen.operation[s]("1").replace("buf1", "buffer")
116 patterns['fini1a'] = gen.fini[s]("1")
117 patterns['fini1b'] = gen.fini[s]("1")
118 patterns['free1'] = gen.free[s]("1")
120 patterns['init2'] = gen.init[r]("2")
121 patterns['operation2'] = gen.operation[r]("2").replace("buf2", "buffer")
122 patterns['fini2'] = gen.fini[r]("2")
123 patterns['free2'] = gen.free[r]("2")
125 patterns['errorcond'] = ''
126 patterns['addcond'] = 'if (rank == 1)'
128 # Generate a correct matching
129 replace = patterns.copy()
130 replace['shortdesc'] = 'Correct call ordering.'
131 replace['longdesc'] = 'Correct call ordering.'
132 replace['outcome'] = 'OK'
133 replace['errormsg'] = '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['outcome'] = 'ERROR: IHCallMatching'
141 replace['errormsg'] = 'P2P mistmatch. Missing @{r}@ at @{filename}@:@{line:MBIERROR}@.'
142 replace['errorcond'] = '/* MBIERROR */'
143 replace['operation1b'] = ''
144 replace['fini1b'] = ''
145 gen.make_file(template, f'InputHazardCallOrdering_{r}_{s}_nok.c', replace)
151 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
152 patterns['p2pfeature'] = 'Lacking'
153 patterns['ip2pfeature'] = 'Lacking'
154 patterns['collfeature'] = 'Yes' if c in gen.coll else 'Lacking'
155 patterns['icollfeature'] = 'Yes' if c in gen.icoll else 'Lacking'
158 patterns['init1'] = gen.init[c]("1")
159 patterns['operation1a'] = gen.operation[c]("1")
160 patterns['operation1b'] = gen.operation[c]("1")
161 patterns['fini1a'] = gen.fini[c]("1")
162 patterns['fini1b'] = gen.fini[c]("1")
163 patterns['free1'] = gen.free[c]("1")
165 patterns['init2'] = gen.init[c]("2")
166 patterns['operation2'] = gen.operation[c]("2")
167 patterns['fini2'] = gen.fini[c]("2")
168 patterns['free2'] = gen.free[c]("2")
170 patterns['errorcond'] = ''
171 patterns['addcond'] = ''
173 # Generate a correct matching
174 replace = patterns.copy()
175 replace['shortdesc'] = 'Correct call ordering.'
176 replace['longdesc'] = 'Correct call ordering.'
177 replace['outcome'] = 'OK'
178 replace['errormsg'] = 'OK'
179 gen.make_file(template, f'InputHazardCallOrdering_{c}_ok.c', replace)
181 # Generate the incorrect matching
182 replace = patterns.copy()
183 replace['shortdesc'] = 'Missing collective function call.'
184 replace['longdesc'] = 'Missing collective function call for a path depending to input, a deadlock is created.'
185 replace['outcome'] = 'ERROR: IHCallMatching'
186 replace['errormsg'] = 'P2P mistmatch. Missing @{c}@ at @{filename}@:@{line:MBIERROR}@.'
187 replace['errorcond'] = '/* MBIERROR */'
188 replace['operation1b'] = ''
189 replace['fini1b'] = ''
190 gen.make_file(template, f'InputHazardCallOrdering_{c}_nok.c', replace)