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 at least 2 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;
65 @{operation3}@ /* MBIERROR1 */
71 @{operation2}@ /* MBIERROR2 */
82 printf("Rank %d finished normally\\n", rank);
88 for s in gen.send + gen.isend:
89 for r in gen.recv + gen.irecv:
92 patterns = {'s': s, 'r': r, 'c': c}
93 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
94 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
95 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
96 patterns['collfeature'] = 'Yes' if c in gen.coll else 'Lacking'
100 patterns['init1'] = gen.init[s]("1")
101 patterns['init2'] = gen.init[r]("2")
102 patterns['init3'] = gen.init[c]("3")
103 patterns['fini1'] = gen.fini[s]("1")
104 patterns['fini2'] = gen.fini[r]("2")
105 patterns['fini3'] = gen.fini[c]("3")
106 patterns['free1'] = gen.free[s]("1")
107 patterns['free2'] = gen.free[r]("2")
108 patterns['free3'] = gen.free[c]("3")
109 patterns['operation1'] = gen.operation[s]("1")
110 patterns['operation2'] = gen.operation[r]("2")
111 patterns['operation3'] = gen.operation[c]("3")
113 # Generate the incorrect matching because of the conditional
114 replace = patterns.copy()
115 replace['shortdesc'] = 'Point to point & collective mismatch'
116 replace['longdesc'] = 'The @{s}@ corresponding to the @{r}@ is after @{c}@, while @{r}@ is before @{c}@. This is a deadlock.'
117 replace['outcome'] = 'ERROR: CallMatching'
118 replace['errormsg'] = 'P2P & Collective mistmatch. @{r}@ at @{filename}@:@{line:MBIERROR2}@ is matched with @{c}@ at @{filename}@:@{line:MBIERROR1}@ wich causes a deadlock.'
119 gen.make_file(template, f'CallOrdering_{r}_{s}_{c}_nok.c', replace)
121 # Generate the incorrect code depending on buffering
122 # replace = patterns.copy()
123 # replace['shortdesc'] = 'Point to point & collective mismatch'
124 # replace['longdesc'] = 'Point to point @{s}@ is matched with @{c}@ which causes a deadlock depending on the buffering mode.'
125 # replace['outcome'] = 'ERROR: BufferingHazard'
126 # replace['errormsg'] = 'P2P & Collective mistmatch. @{s}@ at @{filename}@:@{line:MBIERROR2}@ is matched with @{c}@ at @{filename}@:@{line:MBIERROR1}@ wich causes a deadlock.'
127 # replace['init1'] = gen.init[s]("1")
128 # replace['init2'] = gen.init[r]("2")
129 # replace['operation1'] = gen.operation[r]("2")
130 # replace['operation2'] = gen.operation[s]("1")
131 # replace['fini1'] = gen.fini[r]("2")
132 # replace['fini2'] = gen.fini[s]("1")
133 # gen.make_file(template, f'CollP2PBuffering_{r}_{s}_{c}_nok.c', replace)