4 from generator_utils import *
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 /////////////////// */
39 int main(int argc, char **argv) {
42 int src=MPI_ANY_SOURCE, dest=0;
43 int stag = 42, rtag = MPI_ANY_TAG;
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");
57 MPI_Datatype type = MPI_INT;
58 MPI_Comm newcom = MPI_COMM_WORLD;
64 for (int i = 0; i < nprocs - 1; i++) {
65 @{operation1}@ /* MBIERROR */
69 printf("MBI_MSG_RACE: The last received message is not 3 but %d!\\n", recv_buffer);
80 printf("Rank %d finished normally\\n", rank);
86 for s in send + isend:
87 for r in recv + irecv:
89 patterns = {'s': s, 'r': r}
90 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
91 patterns['p2pfeature'] = 'Yes' if s in send or r in recv else 'Lacking'
92 patterns['ip2pfeature'] = 'Yes' if s in isend or r in irecv else 'Lacking'
95 patterns['cond'] = 'buf1'
96 patterns['init2'] = init[s]("2")
97 patterns['init1'] = init[r]("1")
98 patterns['fini2'] = fini[s]("2")
99 patterns['fini1'] = fini[r]("1")
100 patterns['operation2'] = operation[s]("2")
101 patterns['operation1'] = operation[r]("1")
103 # Generate the incorrect matching
105 replace['shortdesc'] = 'The message ordering is non-deterministic.'
106 replace['longdesc'] = f'The code assumes a fixed order in the reception of messages while the message ordering is non-deterministic.'
107 replace['outcome'] = 'ERROR: MessageRace'
108 replace['errormsg'] = 'P2P message race which can cause a deadlock. @{r}@ at @{filename}@:@{line:MBIERROR}@ is called with ANY_SRC.'
109 make_file(template, f'MessageRace_{r}_{s}_nok.c', replace)