3 # Copyright 2021-2022. The MBI project. All rights reserved.
4 # This program is free software; you can redistribute it and/or modify it under the terms of the license (GNU GPL).
7 from generator_utils import *
9 template = """// @{generatedby}@
10 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
14 Description: @{shortdesc}@
17 Version of MPI: Conforms to MPI 1.1, does not require MPI 2 implementation
21 P2P!nonblocking: Lacking
22 P2P!persistent: Lacking
23 COLL!basic: @{collfeature}@
24 COLL!nonblocking: @{icollfeature}@
25 COLL!persistent: Lacking
35 ////////////////////// End of MBI headers /////////////////// */
43 int main(int argc, char **argv) {
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 at least 2 processes to produce a bug.\\n");
56 MPI_Comm newcom = MPI_COMM_WORLD;
57 MPI_Datatype type = MPI_INT;
60 int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
64 if (@{change_cond}@) {
65 @{operation1a}@ /* MBIERROR1 */
70 @{operation1b}@ /* MBIERROR2 */
80 printf("Rank %d finished normally\\n", rank);
85 for c1 in coll + icoll + ibarrier:
86 for c2 in coll + icoll + ibarrier:
88 patterns = {'c1': c1, 'c2': c2}
89 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {sys.argv[0]}. DO NOT EDIT.'
90 patterns['collfeature'] = 'Yes' if c1 in coll or c2 in coll else 'Lacking'
91 patterns['icollfeature'] = 'Yes' if c1 in icoll + ibarrier or c2 in icoll + ibarrier else 'Lacking'
94 patterns['init1'] = init[c1]("1")
95 patterns['init2'] = init[c2]("2")
96 patterns['fini1a'] = fini[c1]("1")
97 patterns['fini2a'] = fini[c2]("2")
98 patterns['fini1b'] = fini[c1]("1")
99 patterns['fini2b'] = fini[c2]("2")
100 patterns['free1'] = free[c1]("1")
101 patterns['free2'] = free[c2]("2")
102 patterns['operation1a'] = operation[c1]("1")
103 patterns['operation1b'] = operation[c1]("1")
104 patterns['operation2a'] = operation[c2]("2")
105 patterns['operation2b'] = operation[c2]("2")
106 patterns['change_cond'] = 'rank % 2'
109 # Generate the correct code using the same collective twice
111 replace['shortdesc'] = 'Correct collective ordering'
112 replace['longdesc'] = f'All ranks call {c1} twice'
113 replace['outcome'] = 'OK'
114 replace['errormsg'] = ''
115 make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
116 # Generate the correct code using the collective once
118 replace['shortdesc'] = 'Correct collective ordering'
119 replace['longdesc'] = f'All ranks call {c1} once'
120 replace['outcome'] = 'OK'
121 replace['errormsg'] = ''
122 replace['init2'] = ''
123 replace['operation2a'] = ''
124 replace['operation2b'] = ''
125 replace['fini2a'] = ''
126 replace['fini2b'] = ''
127 replace['free2'] = ''
128 make_file(template, f'CallOrdering_{c1}_ok.c', replace)
130 # Generate the correct ordering with two different collectives
132 replace['shortdesc'] = 'Correct collective ordering'
133 replace['longdesc'] = f'All ranks call {c1} and then {c2}'
134 replace['outcome'] = 'OK'
135 replace['errormsg'] = ''
136 make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
137 # Generate the incorrect ordering with two different collectives
139 replace['shortdesc'] = 'Incorrect collective ordering'
140 replace['longdesc'] = f'Odd ranks call {c1} and then {c2} while even ranks call these collectives in the other order'
141 replace['outcome'] = 'ERROR: CallMatching'
142 replace['errormsg'] = 'Collective mistmatch. @{c1}@ at @{filename}@:@{line:MBIERROR1}@ is matched with @{c2}@ line @{filename}@:@{line:MBIERROR2}@.'
143 replace['operation1b'] = operation[c2]("2") # Inversion
144 replace['operation2b'] = operation[c1]("1")
145 replace['fini1a'] = fini[c1]("1") # Inversion
146 replace['fini2a'] = fini[c2]("2")
147 replace['fini1b'] = fini[c2]("2") # Inversion
148 replace['fini2b'] = fini[c1]("1")
149 replace['free1'] = free[c2]("2")
150 replace['free2'] = free[c1]("1")
152 make_file(template, f'CallOrdering_{c1}_{c2}_nok.c', replace)
154 # Generate the incorrect ordering with one collective
156 replace['shortdesc'] = 'Incorrect collective ordering'
157 replace['longdesc'] = f'Odd ranks call {c1} while even ranks do not call any collective'
158 replace['outcome'] = 'ERROR: CallMatching'
159 replace['errormsg'] = 'Collective mistmatch. @{c1}@ at @{filename}@:@{line:MBIERROR1}@ is not matched.'
160 replace['operation1b'] = '' # Remove functions
161 replace['operation2b'] = ''
162 replace['operation2a'] = ''
163 replace['fini1b'] = ''
164 replace['fini2a'] = ''
165 replace['fini2b'] = ''
166 make_file(template, f'CallOrdering_{c1}_none_nok.c', replace)
167 # Generate a correct ordering with a conditional not depending on ranks
169 replace['shortdesc'] = 'Correct collective ordering'
170 replace['longdesc'] = f'All ranks call {c1} and then {c2} or inversely'
171 replace['outcome'] = 'OK'
172 replace['errormsg'] = ''
173 replace['change_cond'] = 'nprocs<256'
174 replace['operation2b'] = '' # Remove functions
175 replace['operation2a'] = ''
176 replace['fini2b'] = ''
177 replace['free2a'] = ''
178 make_file(template, f'CallOrdering_{c1}_none_ok.c', replace)