4 import generator_utils as gen
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
11 Description: @{shortdesc}@
14 Version of MPI: Conforms to MPI 2, does not require MPI 3 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 /////////////////// */
40 int main(int argc, char **argv) {
44 int * winbuf = (int *)malloc(N * sizeof(int)); // Window buffer
47 MPI_Init(&argc, &argv);
48 MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
49 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
50 printf("Hello from rank %d \\n", rank);
53 printf("MBI ERROR: This test needs at least 3 processes to produce a bug!\\n");
55 MPI_Comm newcom = MPI_COMM_WORLD;
56 MPI_Datatype type = MPI_INT;
60 MPI_Win_create(winbuf, N*sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
67 @{comment_fence}@MPI_Win_fence(0, win);
72 @{comment_lock}@MPI_Win_lock(MPI_LOCK_EXCLUSIVE, 1, 0, win);
74 @{operation2}@ /* MBIERROR */
75 @{comment_lock}@MPI_Win_unlock(1, win);
84 @{comment_fence}@MPI_Win_fence(0, win);
90 printf("Rank %d finished normally\\n", rank);
97 for s in gen.send + gen.isend:
98 for r in gen.recv + gen.irecv:
100 patterns = {'p': p, 's': s, 'r': r}
101 patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
102 patterns['origin'] = 'RTED'
103 patterns['shortdesc'] = 'Local Concurrency error.'
104 patterns['longdesc'] = 'Local Concurrency error. Concurrent access of variable localbuf1 by @{p}@ (write) and @{s}@ (read)'
105 patterns['rmafeature'] = 'Yes'
106 patterns['p2pfeature'] = 'Yes' if s in gen.send or r in gen.recv else 'Lacking'
107 patterns['ip2pfeature'] = 'Yes' if s in gen.isend or r in gen.irecv else 'Lacking'
111 patterns['init1'] = gen.init[p]("1")
112 patterns['init2'] = gen.init[s]("2")
113 patterns['init3'] = gen.init[r]("3")
114 patterns['fini2'] = gen.fini[s]("2")
115 patterns['fini3'] = gen.fini[r]("3")
116 patterns['operation1'] = gen.operation[p]("1")
117 patterns['operation2'] = gen.operation[s]("2").replace("buf2", "localbuf1")
118 patterns['operation3'] = gen.operation[r]("3")
119 patterns['comment_lock'] = ''
120 patterns['comment_fence'] = ''
123 replace = patterns.copy()
124 replace['outcome'] = 'ERROR: LocalConcurrency'
125 replace['errormsg'] = 'Local Concurrency error. @{p}@ at @{filename}@:@{line:MBIERROR}@ .'
126 replace['comment_lock'] = '// '
127 gen.make_file(template, f'LocalConcurrency_fence_{p}_{s}_{r}_nok.c', replace)
130 replace = patterns.copy()
131 replace['outcome'] = 'ERROR: LocalConcurrency'
132 replace['errormsg'] = 'Local Concurrency error. @{p}@ at @{filename}@:@{line:MBIERROR}@ .'
133 replace['comment_fence'] = '// '
134 gen.make_file(template, f'LocalConcurrency_lock_{p}_{s}_{r}_nok.c', replace)