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
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) {
41 int nprocs = -1 , rank = -1;
43 MPI_Init(&argc, &argv);
44 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
45 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
48 printf("MBI ERROR: This test needs at least 3 processes to produce a bug!\\n");
50 MPI_Comm newcom = MPI_COMM_WORLD;
51 MPI_Datatype type = MPI_INT;
53 int src = 0; int dest = 0;
54 int stag = 1; int rtag = 1;
66 } else if (rank == 1) {
72 } else if (rank == 2) {
84 printf("Rank %d finished normally\\n", rank);
91 for sr in gen.sendrecv:
93 patterns = {'s': s, 'r': r, 'sr': sr}
94 patterns['origin'] = "RTED"
95 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
97 patterns['init1'] = gen.init[r]("1").replace("buf1=-1", "buf1[N]={-1}")
98 patterns['start1'] = gen.start[r]("1")
99 patterns['operation1'] = gen.operation[r]("1")
100 patterns['fini1'] = gen.fini[r]("1")
101 patterns['free1'] = gen.free[r]("1")
103 patterns['init2'] = gen.init[sr]("2")
104 patterns['start2'] = gen.start[sr]("2")
105 patterns['operation2'] = gen.operation[sr]("2")
106 patterns['fini2'] = gen.fini[sr]("2")
107 patterns['free2'] = gen.free[sr]("2")
109 patterns['init3'] = gen.init[s]("3").replace("buf3=rank", "buf3[N]={rank}")
110 patterns['start3'] = gen.start[s]("3")
111 patterns['operation3'] = gen.operation[s]("3")
112 patterns['fini3'] = gen.fini[s]("3")
113 patterns['free3'] = gen.free[s]("3")
115 patterns['change_arg'] = ''
117 # Generate a code with distinct buffer
118 replace = patterns.copy()
119 replace['origin'] = 'MBI'
120 replace['shortdesc'] = 'Correct usage of Sendrecv function.'
121 replace['longdesc'] = 'Correct usage of Sendrecv function.'
122 replace['outcome'] = 'OK'
123 replace['errormsg'] = 'OK'
124 gen.make_file(template, f'InvalidParam_Buffer_{s}_{sr}_{r}_ok.c', replace)
126 # Generate a code with non distinct buffer
127 replace = patterns.copy()
128 replace['shortdesc'] = 'Invalid buffer on Sendrecv function.'
129 replace['longdesc'] = 'Invalid buffer on Sendrecv, the two buffers must be distinct.'
130 replace['outcome'] = 'ERROR: InvalidBuffer'
131 replace['errormsg'] = '@{sr}@ at @{filename}@:@{line:MBIERROR}@ send buffer and recv buffer must be distinct.'
132 replace['change_arg'] = gen.write[sr]("2")
133 replace['operation2'] = gen.operation[sr]("2") + " /* MBIERROR */"
134 gen.make_file(template, f'InvalidParam_Buffer_{s}_{sr}_{r}_nok.c', replace)