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: @{persfeature}@
21 COLL!nonblocking: Lacking
22 COLL!persistent: Lacking
32 ////////////////////// End of MBI headers /////////////////// */
39 int main(int argc, char **argv) {
43 int stag = 0, rtag = 0;
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");
54 MPI_Datatype type = MPI_INT;
56 MPI_Comm_split(MPI_COMM_WORLD, 0, nprocs - rank, &newcom);
63 @{operation1}@ /* MBIERROR1 */
66 }else if (rank == 1) {
67 @{operation2}@ /* MBIERROR2 */
74 if(newcom != MPI_COMM_NULL && newcom != MPI_COMM_WORLD)
75 MPI_Comm_free(&newcom);
78 printf("Rank %d finished normally\\n", rank);
84 for p1 in send + isend + psend:
85 for p2 in recv + irecv + precv:
87 patterns = {'p1': p1, 'p2': p2}
88 patterns['origin'] = "MBI"
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 p1 in send or p2 in recv else 'Lacking'
91 patterns['ip2pfeature'] = 'Yes' if p1 in isend or p2 in irecv else 'Lacking'
92 patterns['persfeature'] = 'Yes' if p1 in psend or p2 in precv else 'Lacking'
95 patterns['init1'] = init[p1]("1")
96 patterns['init2'] = init[p2]("2")
97 patterns['start1'] = start[p1]("1")
98 patterns['start2'] = start[p2]("2")
99 patterns['fini1'] = fini[p1]("1")
100 patterns['fini2'] = fini[p2]("2")
101 patterns['operation1'] = operation[p1]("1") #send
102 patterns['operation2'] = operation[p2]("2") #recv
103 patterns['free1'] = free[p1]("1")
104 patterns['free2'] = free[p2]("2")
105 patterns['change_srcdest'] = ""
107 # Generate the incorrect matching
109 replace['shortdesc'] = 'Point to point @{p1}@ and @{p2}@ have a communicator mismatch'
110 replace['longdesc'] = 'Process 1 uses newcom as the communicator while process 0 uses MPI_COMM_WORLD.'
111 replace['outcome'] = 'ERROR: CommunicatorMatching'
112 replace['errormsg'] = 'P2P Communicator mismatch. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ and @{p2}@ at @{filename}@:@{line:MBIERROR2}@ have newcom or MPI_COMM_WORLD as a communicator.'
113 replace['change_com'] = 'if (rank==0)\n newcom = MPI_COMM_WORLD; /* MBIERROR */'
114 make_file(template, f'ParamMatching_Com_{p1}_{p2}_nok.c', replace)
116 # Generate the code with an invalid communicator
118 replace['shortdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator'
119 replace['longdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator.'
120 replace['outcome'] = 'ERROR: InvalidCommunicator'
121 replace['errormsg'] = 'Invalid Communicator. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ and @{p2}@ at @{filename}@:@{line:MBIERROR2}@ use a communicator that is freed line @{line:MBIERROR}@.'
122 replace['change_com'] = 'MPI_Comm_free(&newcom); /* MBIERROR */'
123 make_file(template, f'InvalidParam_Com_{p1}_{p2}_nok.c', replace)
125 # Generate the code with an invalid communicator ==> TO CHECK
127 #replace['shortdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator'
128 # replace['longdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator.'
129 # replace['outcome'] = 'ERROR: InvalidCommunicator'
130 # replace['errormsg'] = 'Invalid Communicator. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ and @{p2}@ at @{filename}@:@{line:MBIERROR2}@ use different communicators'
131 # replace['origin'] = "MPI-Corrbench"
132 # replace['change_com'] = ""
133 # make_file(template, f'InvalidParam_Com_{p1}_{p2}_nok.c', replace)
135 # Generate the code with an invalid dest
137 replace['origin'] = "MBI"
138 replace['shortdesc'] = 'Point to point @{p1}@ has an invalid argument'
139 replace['longdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator.'
140 replace['outcome'] = 'ERROR: InvalidSrcDest'
141 replace['errormsg'] = 'InvalidSrcDest. @{p1}@ at @{filename}@:@{line:MBIERROR1}@ performs a send with a dest not in communicator (dest is changed line @{line:MBIERROR}@).'
142 replace['change_com'] = ""
143 replace['change_srcdest'] = 'dest=4; /* MBIERROR */'
144 make_file(template, f'InvalidParam_Dest_{p1}_{p2}_nok.c', replace)
146 # Generate the code with an invalid src
148 replace['shortdesc'] = 'Point to point @{p2}@ has an invalid argument'
149 replace['longdesc'] = 'Point to point @{p1}@ and @{p2}@ have an invalid communicator.'
150 replace['outcome'] = 'ERROR: InvalidSrcDest'
151 replace['errormsg'] = 'InvalidSrcDest. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ performs a recv with a negative integer as source (src is changed line @{line:MBIERROR}@).'
152 replace['change_srcdest'] = 'src=-1; /* MBIERROR */'
153 make_file(template, f'InvalidParam_Src_{p1}_{p2}_nok.c', replace)