4 import generator_utils as gen
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
11 Description: @{shortdesc}@
14 Version of MPI: Conforms to MPI 2, requires MPI 3 implementation (for lock_all/unlock_all epochs)
18 P2P!nonblocking: Lacking
19 P2P!persistent: Lacking
21 COLL!nonblocking: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
40 int main(int argc, char **argv) {
44 int winbuf[100] = {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_Datatype type = MPI_INT;
57 MPI_Win_create(&winbuf, 100 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
65 @{operation1}@ /* MBIERROR1 */
66 @{operation2}@ /* MBIERROR2 */
81 for p2 in gen.put + gen.store + gen.load + gen.get + gen.loadstore:
83 patterns = {'e': e, 'p1': p1, 'p2': p2}
84 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
85 patterns['rmafeature'] = 'Yes'
89 patterns['epoch'] = gen.epoch[e]("1")
90 patterns['finEpoch'] = gen.finEpoch[e]("1")
91 patterns['init1'] = gen.init[p1]("1")
92 patterns['operation1'] = gen.operation[p1]("1")
93 patterns['operation2'] = gen.operation[p2]("1")
94 shortdesc_rma = 'Correct code using RMA operations'
96 # Generate a data race (Get + Get/load/store/Put)
97 replace = patterns.copy()
98 replace['shortdesc'] = 'Local Concurrency error.'
99 replace['longdesc'] = 'Local Concurrency error. @{p2}@ conflicts with @{p1}@'
100 replace['outcome'] = 'ERROR: LocalConcurrency'
101 replace['errormsg'] = 'Local Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
102 gen.make_file(template, f'LocalConcurrency_lloutwindow_{e}_{p1}_{p2}_nok.c', replace)
103 # Generate a correct code by switching operation1 and operation2
104 if p2 in gen.store + gen.load + gen.loadstore:
105 replace = patterns.copy()
106 replace['shortdesc'] = shortdesc_rma
107 replace['longdesc'] = shortdesc_rma
108 replace['outcome'] = 'OK'
109 replace['errormsg'] = 'OK'
110 replace['operation1'] = gen.operation[p2]("1")
111 replace['operation2'] = gen.operation[p1]("1")
112 gen.make_file(template, f'LocalConcurrency_lloutwindow_{e}_{p2}_{p1}_ok.c', replace)
113 # Generate a correct code by removing operation2
114 replace = patterns.copy()
115 replace['shortdesc'] = shortdesc_rma
116 replace['longdesc'] = shortdesc_rma
117 replace['outcome'] = 'OK'
118 replace['errormsg'] = 'OK'
119 replace['operation1'] = gen.operation[p1]("1")
120 replace['operation2'] = ''
121 gen.make_file(template, f'LocalConcurrency_{e}_{p1}_ok.c', replace)
128 patterns = {'e': e, 'p1': p1, 'p2': p2}
129 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
130 patterns['rmafeature'] = 'Yes'
134 patterns['epoch'] = gen.epoch[e]("1")
135 patterns['finEpoch'] = gen.finEpoch[e]("1")
136 patterns['init1'] = gen.init[p1]("1")
137 patterns['operation1'] = gen.operation[p1]("1")
138 patterns['operation2'] = gen.operation[p2]("1")
140 # Generate a data race (Put + store)
141 replace = patterns.copy()
142 replace['shortdesc'] = 'Local Concurrency error.'
143 replace['longdesc'] = 'Local Concurrency error. @{p2}@ conflicts with @{p1}@'
144 replace['outcome'] = 'ERROR: LocalConcurrency'
145 replace['errormsg'] = 'Local Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
146 gen.make_file(template, f'LocalConcurrency_lloutwindow_{e}_{p1}_{p2}_nok.c', replace)
147 # Generate a correct code by switching operation1 and operation2
148 replace = patterns.copy()
149 replace['shortdesc'] = shortdesc_rma
150 replace['longdesc'] = shortdesc_rma
151 replace['outcome'] = 'OK'
152 replace['errormsg'] = 'OK'
153 replace['operation1'] = gen.operation[p2]("1")
154 replace['operation2'] = gen.operation[p1]("1")
155 gen.make_file(template, f'LocalConcurrency_lloutwindow_{e}_{p2}_{p1}_ok.c', replace)
157 # Generate a correct code by removing operation2
158 replace = patterns.copy()
159 replace['shortdesc'] = shortdesc_rma
160 replace['longdesc'] = shortdesc_rma
161 replace['outcome'] = 'OK'
162 replace['errormsg'] = 'OK'
163 replace['operation1'] = gen.operation[p1]("1")
164 replace['operation2'] = ''
165 gen.make_file(template, f'LocalConcurrency_{e}_{p1}_ok.c', replace)