4 import generator_utils as gen
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
11 Description: @{shortdesc}@
17 P2P!nonblocking: Lacking
18 P2P!persistent: Lacking
20 COLL!nonblocking: Lacking
21 COLL!persistent: Lacking
31 ////////////////////// End of MBI headers /////////////////// */
40 int main(int argc, char **argv) {
43 MPI_Init(&argc, &argv);
44 MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
45 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
47 int *winbuf = (int *)malloc(N * sizeof(int));
50 MPI_Win_create(&winbuf, N * sizeof(int), 1, MPI_INFO_NULL, MPI_COMM_WORLD, &win);
52 MPI_Datatype type = MPI_INT;
53 int target = (rank + 1) % numProcs;
59 @{operation}@ /* MBIERROR2 */
81 patterns = {'e': e, 'p': p}
82 patterns['origin'] = "MBI"
83 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
84 patterns['rmafeature'] = 'Yes'
87 patterns['epoch'] = gen.epoch[e]("1")
88 patterns['finEpoch'] = gen.finEpoch[e]("1")
89 patterns['init'] = gen.init[p]("1")
90 patterns['operation'] = gen.operation[p]("1")
91 patterns['change_arg'] = ""
93 # Generate a code with a null type
94 replace = patterns.copy()
95 replace['shortdesc'] = 'Invalid argument in one-sided operation.'
96 replace['longdesc'] = 'A one-sided operation has MPI_DATATYPE_NULL as a type.'
97 replace['outcome'] = 'ERROR: InvalidDatatype'
98 replace['change_arg'] = 'type = MPI_DATATYPE_NULL;'
99 replace['errormsg'] = '@{p}@ at @{filename}@:@{line:MBIERROR}@ has MPI_DATATYPE_NULL as a type'
100 gen.make_file(template, f'InvalidParam_BufferNullCond_{e}_{p}_nok.c', replace)
102 # Generate a code with an invalid type
103 replace = patterns.copy()
104 replace['shortdesc'] = 'Invalid argument in one-sided operation.'
105 replace['longdesc'] = 'Use of an invalid datatype in one-sided operation.'
106 replace['outcome'] = 'ERROR: InvalidDatatype'
107 replace['change_arg'] = 'MPI_Type_contiguous (2, MPI_INT, &type); MPI_Type_commit(&type);MPI_Type_free(&type); /* MBIERROR2 */'
108 replace['errormsg'] = 'Invalid Datatype in @{p}@ at @{filename}@:@{line:MBIERROR}@'
109 gen.make_file(template, f'InvalidParam_DatatypeCond_{e}_{p}_nok.c', replace)