Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[MBI] Import generator_utils as gen.
[simgrid.git] / teshsuite / smpi / MBI / RMARemoteLocalConcurrencyGenerator.py
index 4a8e83c..9a28409 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/python3
 import os
 import sys
-from generator_utils import *
+import generator_utils as gen
 
 template = """// @{generatedby}@
 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
@@ -11,17 +11,17 @@ template = """// @{generatedby}@
   Description: @{shortdesc}@
     @{longdesc}@
 
-       Version of MPI: Conforms to MPI 2, requires MPI 3 implementation (for lock_all/unlock_all epochs)
+  Version of MPI: Conforms to MPI 2, requires MPI 3 implementation (for lock_all/unlock_all epochs)
 
 BEGIN_MPI_FEATURES
-       P2P!basic: Lacking 
-       P2P!nonblocking: Lacking
-       P2P!persistent: Lacking
-       COLL!basic: Lacking
-       COLL!nonblocking: Lacking
-       COLL!persistent: Lacking
-       COLL!tools: Lacking
-       RMA: @{rmafeature}@
+  P2P!basic: Lacking
+  P2P!nonblocking: Lacking
+  P2P!persistent: Lacking
+  COLL!basic: Lacking
+  COLL!nonblocking: Lacking
+  COLL!persistent: Lacking
+  COLL!tools: Lacking
+  RMA: @{rmafeature}@
 END_MPI_FEATURES
 
 BEGIN_MBI_TESTS
@@ -40,7 +40,7 @@ END_MBI_TESTS
 int main(int argc, char **argv) {
   int nprocs = -1;
   int rank = -1;
-       MPI_Win win;
+  MPI_Win win;
   int winbuf[100] = {0};
 
   MPI_Init(&argc, &argv);
@@ -51,22 +51,22 @@ int main(int argc, char **argv) {
   if (nprocs < 2)
     printf("MBI ERROR: This test needs at least 2 processes to produce a bug!\\n");
 
-       MPI_Datatype type = MPI_INT;
-       int target = 1;
+  MPI_Datatype type = MPI_INT;
+  int target = 1;
 
   MPI_Win_create(&winbuf, 100 * sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
 
-       @{init1}@ 
+  @{init1}@
 
   @{epoch}@
 
-       if (rank == 0) {
-       @{operation1}@ /* MBIERROR1 */
-       }
-       if(rank == 1){
-               target = 0;
-       @{operation2}@ /* MBIERROR2 */
-       }
+  if (rank == 0) {
+    @{operation1}@ /* MBIERROR1 */
+  }
+  if(rank == 1){
+    target = 0;
+    @{operation2}@ /* MBIERROR2 */
+  }
 
   @{finEpoch}@
 
@@ -78,51 +78,63 @@ int main(int argc, char **argv) {
 """
 
 
-for e in epoch:
-    for p1 in get: 
-        for p2 in rput + rstore + rload + rget :
+for e in gen.epoch:
+    for p1 in gen.get:
+        for p2 in gen.put + gen.rstore + gen.rload + gen.get:
             patterns = {}
             patterns = {'e': e, 'p1': p1, 'p2': p2}
-            patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'  
+            patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
             patterns['rmafeature'] = 'Yes'
-            patterns['p1'] = p1 
-            patterns['p2'] = p2 
-            patterns['e'] = e 
-            patterns['epoch'] = epoch[e]("1") 
-            patterns['finEpoch'] = finEpoch[e]("1") 
-            patterns['init1'] = init[p1]("1") 
-            patterns['operation1'] = operation[p1]("1") 
-            patterns['operation2'] = operation[p2]("1") 
-
-                   # Generate a data race (Get + Get/load/store/Put)
-            replace = patterns 
-            replace['shortdesc'] = 'Global Concurrency error.' 
-            replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@' 
-            replace['outcome'] = 'ERROR: GlobalConcurrency' 
+            patterns['p1'] = p1
+            patterns['p2'] = p2
+            patterns['e'] = e
+            patterns['epoch'] = gen.epoch[e]("1")
+            patterns['finEpoch'] = gen.finEpoch[e]("1")
+            patterns['init1'] = gen.init[p1]("1")
+            patterns['operation1'] = gen.operation[p1]("1")
+            patterns['operation2'] = gen.operation[p2]("1")
+
+            # Generate a data race (Get + Get/load/store/Put)
+            replace = patterns
+            replace['shortdesc'] = 'Global Concurrency error.'
+            replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@'
+            replace['outcome'] = 'ERROR: GlobalConcurrency'
             replace['errormsg'] = 'Global Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
-            make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)
 
+            # Replace Put and Get first argument
+            if p2 in gen.put:
+                replace['operation2'] = 'MPI_Put(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
+            if p2 in gen.get:
+                replace['operation2'] = 'MPI_Get(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
 
-for e in epoch:
-    for p1 in put: 
-        for p2 in rstore + rload + rput:
+            gen.make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)
+
+
+for e in gen.epoch:
+    for p1 in gen.put:
+        for p2 in gen.rstore + gen.rload + gen.put:
             patterns = {}
             patterns = {'e': e, 'p1': p1, 'p2': p2}
-            patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'  
+            patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
             patterns['rmafeature'] = 'Yes'
-            patterns['p1'] = p1 
-            patterns['p2'] = p2 
-            patterns['e'] = e 
-            patterns['epoch'] = epoch[e]("1") 
-            patterns['finEpoch'] = finEpoch[e]("1") 
-            patterns['init1'] = init[p1]("1") 
-            patterns['operation1'] = operation[p1]("1") 
-            patterns['operation2'] = operation[p2]("1") 
-
-                   # Generate a data race (Put + store)
-            replace = patterns 
-            replace['shortdesc'] = 'Global Concurrency error.' 
-            replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@' 
-            replace['outcome'] = 'ERROR: LocalConcurrency' 
+            patterns['p1'] = p1
+            patterns['p2'] = p2
+            patterns['e'] = e
+            patterns['epoch'] = gen.epoch[e]("1")
+            patterns['finEpoch'] = gen.finEpoch[e]("1")
+            patterns['init1'] = gen.init[p1]("1")
+            patterns['operation1'] = gen.operation[p1]("1")
+            patterns['operation2'] = gen.operation[p2]("1")
+
+            # Generate a data race (Put + store)
+            replace = patterns
+            replace['shortdesc'] = 'Global Concurrency error.'
+            replace['longdesc'] = 'Global Concurrency error. @{p2}@ conflicts with @{p1}@'
+            replace['outcome'] = 'ERROR: GlobalConcurrency'
             replace['errormsg'] = 'Global Concurrency error. @{p2}@ at @{filename}@:@{line:MBIERROR2}@ conflicts with @{p1}@ line @{line:MBIERROR1}@'
-            make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)
+
+            # Replace Put first argument
+            if p2 in gen.put:
+                replace['operation2'] = 'MPI_Put(&winbuf[20], N, MPI_INT, target, 0, N, type, win);'
+
+            gen.make_file(template, f'GlobalConcurrency_rl_{e}_{p1}_{p2}_nok.c', replace)