Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill trailing spaces and tabs in MBI files
[simgrid.git] / teshsuite / smpi / MBI / RMARemoteLocalConcurrencyGenerator.py
1 #! /usr/bin/python3
2 import os
3 import sys
4 from generator_utils import *
5
6 template = """// @{generatedby}@
7 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
8
9   Origin: MBI
10
11   Description: @{shortdesc}@
12     @{longdesc}@
13
14   Version of MPI: Conforms to MPI 2, requires MPI 3 implementation (for lock_all/unlock_all epochs)
15
16 BEGIN_MPI_FEATURES
17   P2P!basic: Lacking
18   P2P!nonblocking: Lacking
19   P2P!persistent: Lacking
20   COLL!basic: Lacking
21   COLL!nonblocking: Lacking
22   COLL!persistent: Lacking
23   COLL!tools: Lacking
24   RMA: @{rmafeature}@
25 END_MPI_FEATURES
26
27 BEGIN_MBI_TESTS
28   $ mpirun -np 2 ${EXE}
29   | @{outcome}@
30   | @{errormsg}@
31 END_MBI_TESTS
32 //////////////////////       End of MBI headers        /////////////////// */
33
34 #include <mpi.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 #define N 1
39
40 int main(int argc, char **argv) {
41   int nprocs = -1;
42   int rank = -1;
43   MPI_Win win;
44   int winbuf[100] = {0};
45
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);
50
51   if (nprocs < 2)
52     printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
53
54   MPI_Datatype type = MPI_INT;
55   int target = 1;
56
57   MPI_Win_create(&winbuf, 100 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
58
59   @{init1}@
60
61   @{epoch}@
62
63   if (rank == 0) {
64     @{operation1}@ /* MBIERROR1 */
65   }
66   if(rank == 1){
67     target = 0;
68     @{operation2}@ /* MBIERROR2 */
69   }
70
71   @{finEpoch}@
72
73   MPI_Win_free(&win);
74
75   MPI_Finalize();
76   return 0;
77 }
78 """
79
80
81 for e in epoch:
82     for p1 in get:
83         for p2 in put + rstore + rload + get :
84             patterns = {}
85             patterns = {'e': e, 'p1': p1, 'p2': p2}
86             patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
87             patterns['rmafeature'] = 'Yes'
88             patterns['p1'] = p1
89             patterns['p2'] = p2
90             patterns['e'] = e
91             patterns['epoch'] = epoch[e]("1")
92             patterns['finEpoch'] = finEpoch[e]("1")
93             patterns['init1'] = init[p1]("1")
94             patterns['operation1'] = operation[p1]("1")
95             patterns['operation2'] = operation[p2]("1")
96
97             # Generate a data race (Get + Get/load/store/Put)
98             replace = patterns
99             replace['shortdesc'] = 'Global Concurrency error.'
100             replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@'
101             replace['outcome'] = 'ERROR: GlobalConcurrency'
102             replace['errormsg'] = 'Global Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
103
104             # Replace Put and Get first argument
105             if p2 in put:
106                 replace['operation2'] = 'MPI_Put(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
107             if p2 in get:
108                 replace['operation2'] = 'MPI_Get(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
109
110             make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)
111
112
113 for e in epoch:
114     for p1 in put:
115         for p2 in rstore + rload + put:
116             patterns = {}
117             patterns = {'e': e, 'p1': p1, 'p2': p2}
118             patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
119             patterns['rmafeature'] = 'Yes'
120             patterns['p1'] = p1
121             patterns['p2'] = p2
122             patterns['e'] = e
123             patterns['epoch'] = epoch[e]("1")
124             patterns['finEpoch'] = finEpoch[e]("1")
125             patterns['init1'] = init[p1]("1")
126             patterns['operation1'] = operation[p1]("1")
127             patterns['operation2'] = operation[p2]("1")
128
129             # Generate a data race (Put + store)
130             replace = patterns
131             replace['shortdesc'] = 'Global Concurrency error.'
132             replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@'
133             replace['outcome'] = 'ERROR: LocalConcurrency'
134             replace['errormsg'] = 'Global Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
135
136             # Replace Put first argument
137             if p2 in put:
138               replace['operation2'] = 'MPI_Put(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
139
140             make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)