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
21 COLL!nonblocking: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
40 int main(int argc, char **argv) {
46 int stag = 0, rtag = 0;
49 MPI_Init(&argc, &argv);
50 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
51 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
52 printf("Hello from rank %d \\n", rank);
55 printf("MBI ERROR: This test needs at least 3 processes to produce a bug!\\n");
57 int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
58 MPI_Comm newcom = MPI_COMM_WORLD;
59 MPI_Datatype type = MPI_INT;
71 } else if (rank == 1) {
77 @{operation1b}@ @{tagerror}@
79 } else if (rank == 2) {
91 printf("Rank %d finished normally\\n", rank);
96 # To be correct, this benchmark must be use wildcard on second recv
97 # tag, or no wildcard on first recv tag and second recv tag must be
100 # |-----+-----+----+----|
101 # | x\y | ANY | 1 | 2 |
102 # |-----+-----+----+----|
103 # | ANY | OK | - | - |
104 # | 1 | OK | - | OK |
105 # | 2 | OK | OK | - |
106 # |-----+-----+----+----|
110 for x, y in [('MPI_ANY_TAG', 'MPI_ANY_TAG'), # OK
111 ('MPI_ANY_TAG', '1'), # NOK
112 ('1', 'MPI_ANY_TAG'), # OK
116 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
117 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
118 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
125 patterns['init0'] = gen.init[s]("0")
126 patterns['operation0'] = gen.operation[s]("0")
127 patterns['fini0'] = gen.fini[s]("0")
128 patterns['free0'] = gen.free[s]("0")
130 patterns['init1a'] = gen.init[r]("1a")
131 patterns['init1b'] = gen.init[r]("1b")
132 patterns['operation1a'] = gen.operation[r]("1a")
133 patterns['operation1b'] = gen.operation[r]("1b")
134 patterns['fini1a'] = gen.fini[r]("1a")
135 patterns['fini1b'] = gen.fini[r]("1b")
136 patterns['free1a'] = gen.free[r]("1a")
137 patterns['free1b'] = gen.free[r]("1b")
139 patterns['init2'] = gen.init[s]("2")
140 patterns['operation2'] = gen.operation[s]("2")
141 patterns['fini2'] = gen.fini[s]("2")
142 patterns['free2'] = gen.free[s]("2")
143 patterns['tagerror'] = '/* MBIERROR */'
145 if y == 'MPI_ANY_TAG' or (x != 'MPI_ANY_TAG' and x != y):
146 # Generate the correct matching because of the conditional
147 replace = patterns.copy()
148 replace['shortdesc'] = 'Message race'
149 replace['longdesc'] = 'Correct code without message race.'
150 replace['outcome'] = 'OK'
151 replace['errormsg'] = 'OK'
152 replace['tagerror'] = ''
153 gen.make_file(template, f'MessageRace_tag_{x}_{y}_{s}_{r}_ok.c', replace)
155 # Generate the incorrect matching because of the conditional
156 replace = patterns.copy()
157 replace['shortdesc'] = 'Message race'
158 replace['longdesc'] = 'Message race in @{r}@ with @{s}@.'
159 replace['outcome'] = 'ERROR: MessageRace'
160 replace['errormsg'] = 'Message race. The use of wildcard receive calls @{r}@ at @{filename}@:@{line:MBIERROR}@ and incorrect tag matching.'
161 gen.make_file(template, f'MessageRace_tag_{x}_{y}_{s}_{r}_nok.c', replace)