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: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
39 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 4 processes to produce a bug!\\n");
56 int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
57 MPI_Comm newcom = MPI_COMM_WORLD;
58 MPI_Datatype type = MPI_INT;
81 @{operation3}@ /* MBIERROR1 */
85 @{operation4}@ /* MBIERROR2 */
99 printf("Rank %d finished normally\\n", rank);
105 for s in gen.send + gen.isend:
109 patterns = {'s': s, 'r': r, 'c': c}
110 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
111 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
112 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
113 patterns['collfeature'] = 'Yes' if c in gen.coll else 'Lacking'
117 patterns['init1'] = gen.init[c]("1")
118 patterns['init2'] = gen.init[s]("2")
119 patterns['init3'] = gen.init[r]("3")
120 patterns['init4'] = gen.init[r]("4")
121 patterns['fini1'] = gen.fini[c]("1")
122 patterns['fini2'] = gen.fini[s]("2")
123 patterns['fini3'] = gen.fini[r]("3")
124 patterns['fini4'] = gen.fini[r]("4")
125 patterns['free1'] = gen.free[c]("1")
126 patterns['free2'] = gen.free[s]("2")
127 patterns['free3'] = gen.free[r]("3")
128 patterns['free4'] = gen.free[r]("4")
129 patterns['operation1'] = gen.operation[c]("1")
130 patterns['operation2'] = gen.operation[s]("2")
131 patterns['operation3'] = gen.operation[r]("3")
132 patterns['operation4'] = gen.operation[r]("4")
133 patterns['changesrc'] = ''
135 # Generate the correct matching because of the conditional
136 replace = patterns.copy()
137 replace['shortdesc'] = 'Message race'
138 replace['longdesc'] = 'Message race without problem in @{r}@ with @{c}@.'
139 replace['outcome'] = 'OK'
140 replace['errormsg'] = 'OK'
141 replace['changesrc'] = ''
142 gen.make_file(template, f'MessageRace_{c}_{s}_{r}_ok.c', replace)
144 # Generate the incorrect matching because of the conditional
145 replace = patterns.copy()
146 replace['shortdesc'] = 'Message race'
147 replace['longdesc'] = 'Message race in @{r}@ with @{c}@.'
148 replace['outcome'] = 'ERROR: MessageRace'
149 replace['errormsg'] = 'Message race. The use of wildcard receive calls (@{r}@ at @{filename}@:@{line:MBIERROR1}@ and @{r}@ at @{filename}@:@{line:MBIERROR2}@) leads to nondeterministic matching.'
150 replace['changesrc'] = 'src = 0;'
151 gen.make_file(template, f'MessageRace_{c}_{s}_{r}_nok.c', replace)