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