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) {
44 int stag = 0, rtag = 0;
47 MPI_Init(&argc, &argv);
48 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
49 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
50 printf("Hello from rank %d \\n", rank);
53 printf("MBI ERROR: This test needs 4 processes to produce a bug!\\n");
55 int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
56 MPI_Comm newcom = MPI_COMM_WORLD;
57 MPI_Datatype type = MPI_INT;
80 @{operation3}@ /* MBIERROR1 */
84 @{operation4}@ /* MBIERROR2 */
98 printf("Rank %d finished normally\\n", rank);
104 for s in gen.send + gen.isend:
108 patterns = {'s': s, 'r': r, 'c': c}
109 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
110 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
111 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
112 patterns['collfeature'] = 'Yes' if c in gen.coll else 'Lacking'
116 patterns['init1'] = gen.init[c]("1")
117 patterns['init2'] = gen.init[s]("2")
118 patterns['init3'] = gen.init[r]("3")
119 patterns['init4'] = gen.init[r]("4")
120 patterns['fini1'] = gen.fini[c]("1")
121 patterns['fini2'] = gen.fini[s]("2")
122 patterns['fini3'] = gen.fini[r]("3")
123 patterns['fini4'] = gen.fini[r]("4")
124 patterns['free1'] = gen.free[c]("1")
125 patterns['free2'] = gen.free[s]("2")
126 patterns['free3'] = gen.free[r]("3")
127 patterns['free4'] = gen.free[r]("4")
128 patterns['operation1'] = gen.operation[c]("1")
129 patterns['operation2'] = gen.operation[s]("2")
130 patterns['operation3'] = gen.operation[r]("3")
131 patterns['operation4'] = gen.operation[r]("4")
133 # Generate the incorrect matching because of the conditional
134 replace = patterns.copy()
135 replace['shortdesc'] = 'Message race'
136 replace['longdesc'] = 'Message race in @{r}@ with @{c}@.'
137 replace['outcome'] = 'ERROR: MessageRace'
138 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.'
139 gen.make_file(template, f'MessageRace_{c}_{s}_{r}_nok.c', replace)