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: @{persfeature}@
21 COLL!nonblocking: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
39 int main(int argc, char **argv) {
43 int stag = 0, rtag = 0;
46 MPI_Init(&argc, &argv);
47 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
48 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
49 printf("Hello from rank %d \\n", rank);
52 printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
54 MPI_Comm newcom = MPI_COMM_WORLD;
55 MPI_Datatype type = MPI_INT;
63 @{write1}@ /* MBIERROR1 */
70 @{write2}@ /* MBIERROR2 */
76 printf("Rank %d finished normally\\n", rank);
82 for s in gen.send + gen.isend + gen.psend:
83 for r in gen.irecv + gen.precv + gen.recv:
85 patterns = {'s': s, 'r': r}
86 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
87 patterns['p2pfeature'] = 'Yes' if s in gen.send else 'Lacking'
88 patterns['ip2pfeature'] = 'Yes' if r in gen.irecv else 'Lacking'
89 patterns['persfeature'] = 'Yes' if r in gen.precv else 'Lacking'
92 patterns['init1'] = gen.init[s]("1")
93 patterns['init2'] = gen.init[r]("2")
94 patterns['fini1'] = gen.fini[s]("1")
95 patterns['fini2'] = gen.fini[r]("2")
96 patterns['start1'] = gen.start[s]("1")
97 patterns['start2'] = gen.start[r]("2")
98 patterns['operation1'] = gen.operation[s]("1")
99 patterns['operation2'] = gen.operation[r]("2")
100 patterns['write1'] = gen.write[s]("1")
101 patterns['write2'] = gen.write[r]("2")
102 patterns['free1'] = gen.free[s]("1")
103 patterns['free2'] = gen.free[r]("2")
104 shortdesc = ' Local Concurrency with a P2P'
106 # Gtenerate a message race
107 if s in gen.send and r in gen.irecv + gen.precv:
108 replace = patterns.copy()
109 replace['shortdesc'] = shortdesc
110 replace['longdesc'] = f'The message buffer in {r} is modified before the call has been completed.'
111 replace['outcome'] = 'ERROR: LocalConcurrency'
112 replace['errormsg'] = 'Local Concurrency with a P2P. The receive buffer in @{r}@ is modified at @{filename}@:@{line:MBIERROR2}@ whereas there is no guarantee the message has been received.'
113 gen.make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)
114 if s in gen.isend + gen.psend and r in gen.recv:
115 replace = patterns.copy()
116 replace['shortdesc'] = shortdesc
117 replace['longdesc'] = f'The message buffer in {s} is modified before the call has been completed.'
118 replace['outcome'] = 'ERROR: LocalConcurrency'
119 replace['errormsg'] = 'Local Concurrency with a P2P. The send buffer in @{s}@ is modified at @{filename}@:@{line:MBIERROR1}@ whereas there is no guarantee the message has been sent.'
120 gen.make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)
121 if s in gen.isend + gen.psend and r in gen.irecv + gen.precv:
122 replace = patterns.copy()
123 replace['shortdesc'] = shortdesc
124 replace['longdesc'] = f'The message buffer in {s} and {r} are modified before the calls have completed.'
125 replace['outcome'] = 'ERROR: LocalConcurrency'
126 replace['errormsg'] = 'Local Concurrency with a P2P. The message buffers in @{s}@ and @{r}@ are modified at @{filename}@:@{line:MBIERROR1}@ and @{filename}@:@{line:MBIERROR2}@ whereas there is no guarantee the calls have been completed.'
127 gen.make_file(template, f'LocalConcurrency_{r}_{s}_nok.c', replace)