Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[MBI] Make a real copy of 'patterns' into 'replace'.
[simgrid.git] / teshsuite / smpi / MBI / CollMatchingGenerator.py
index f3ffc4e..952f85f 100755 (executable)
@@ -5,7 +5,7 @@
 
 import os
 import sys
-from generator_utils import *
+import generator_utils as gen
 
 template = """// @{generatedby}@
 /* ///////////////////////// The MPI Bugs Initiative ////////////////////////
@@ -15,17 +15,17 @@ template = """// @{generatedby}@
   Description: @{shortdesc}@
     @{longdesc}@
 
-        Version of MPI: Conforms to MPI 1.1, does not require MPI 2 implementation
+   Version of MPI: Conforms to MPI 1.1, does not require MPI 2 implementation
 
 BEGIN_MPI_FEATURES
-       P2P!basic: Lacking
-       P2P!nonblocking: Lacking
-       P2P!persistent: Lacking
-       COLL!basic: @{collfeature}@
-       COLL!nonblocking: @{icollfeature}@
-       COLL!persistent: Lacking
-       COLL!tools: Lacking
-       RMA: Lacking
+  P2P!basic: Lacking
+  P2P!nonblocking: Lacking
+  P2P!persistent: Lacking
+  COLL!basic: @{collfeature}@
+  COLL!nonblocking: @{icollfeature}@
+  COLL!persistent: Lacking
+  COLL!tools: Lacking
+  RMA: Lacking
 END_MPI_FEATURES
 
 BEGIN_MBI_TESTS
@@ -44,7 +44,7 @@ END_MBI_TESTS
 int main(int argc, char **argv) {
   int nprocs = -1;
   int rank = -1;
-       int root = 0;
+  int root = 0;
 
   MPI_Init(&argc, &argv);
   MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
@@ -54,8 +54,8 @@ 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_Comm newcom = MPI_COMM_WORLD;
-       MPI_Datatype type = MPI_INT;
+  MPI_Comm newcom = MPI_COMM_WORLD;
+  MPI_Datatype type = MPI_INT;
   MPI_Op op = MPI_SUM;
 
   int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
@@ -64,58 +64,58 @@ int main(int argc, char **argv) {
 
   if (@{change_cond}@) {
     @{operation1a}@ /* MBIERROR1 */
-       @{fini1a}@
+    @{fini1a}@
     @{operation2a}@
-       @{fini2a}@
+    @{fini2a}@
   } else {
     @{operation1b}@ /* MBIERROR2 */
-       @{fini1b}@
+    @{fini1b}@
     @{operation2b}@
-       @{fini2b}@
+    @{fini2b}@
   }
 
   @{free1}@
   @{free2}@
-  
+
   MPI_Finalize();
   printf("Rank %d finished normally\\n", rank);
   return 0;
 }
 """
 
-for c1 in coll + icoll + ibarrier:
-    for c2 in coll + icoll + ibarrier:
+for c1 in gen.coll + gen.icoll + gen.ibarrier:
+    for c2 in gen.coll + gen.icoll + gen.ibarrier:
         patterns = {}
         patterns = {'c1': c1, 'c2': c2}
         patterns['generatedby'] = f'DO NOT EDIT: this file was generated by {os.path.basename(sys.argv[0])}. DO NOT EDIT.'
-        patterns['collfeature'] = 'Yes' if c1 in coll or c2 in coll else 'Lacking'
-        patterns['icollfeature'] = 'Yes' if c1 in icoll + ibarrier or c2 in icoll + ibarrier else 'Lacking'
+        patterns['collfeature'] = 'Yes' if c1 in gen.coll or c2 in gen.coll else 'Lacking'
+        patterns['icollfeature'] = 'Yes' if c1 in gen.icoll + gen.ibarrier or c2 in gen.icoll + gen.ibarrier else 'Lacking'
         patterns['c1'] = c1
         patterns['c2'] = c2
-        patterns['init1'] = init[c1]("1")
-        patterns['init2'] = init[c2]("2")
-        patterns['fini1a'] = fini[c1]("1")
-        patterns['fini2a'] = fini[c2]("2")
-        patterns['fini1b'] = fini[c1]("1")
-        patterns['fini2b'] = fini[c2]("2")
-        patterns['free1'] = free[c1]("1")
-        patterns['free2'] = free[c2]("2")
-        patterns['operation1a'] = operation[c1]("1")
-        patterns['operation1b'] = operation[c1]("1")
-        patterns['operation2a'] = operation[c2]("2")
-        patterns['operation2b'] = operation[c2]("2")
+        patterns['init1'] = gen.init[c1]("1")
+        patterns['init2'] = gen.init[c2]("2")
+        patterns['fini1a'] = gen.fini[c1]("1")
+        patterns['fini2a'] = gen.fini[c2]("2")
+        patterns['fini1b'] = gen.fini[c1]("1")
+        patterns['fini2b'] = gen.fini[c2]("2")
+        patterns['free1'] = gen.free[c1]("1")
+        patterns['free2'] = gen.free[c2]("2")
+        patterns['operation1a'] = gen.operation[c1]("1")
+        patterns['operation1b'] = gen.operation[c1]("1")
+        patterns['operation2a'] = gen.operation[c2]("2")
+        patterns['operation2b'] = gen.operation[c2]("2")
         patterns['change_cond'] = 'rank % 2'
 
         if c1 == c2:
             # Generate the correct code using the same collective twice
-            replace = patterns
+            replace = patterns.copy()
             replace['shortdesc'] = 'Correct collective ordering'
             replace['longdesc'] = f'All ranks call {c1} twice'
             replace['outcome'] = 'OK'
             replace['errormsg'] = ''
-            make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
+            gen.make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
             # Generate the correct code using the collective once
-            replace = patterns
+            replace = patterns.copy()
             replace['shortdesc'] = 'Correct collective ordering'
             replace['longdesc'] = f'All ranks call {c1} once'
             replace['outcome'] = 'OK'
@@ -126,34 +126,34 @@ for c1 in coll + icoll + ibarrier:
             replace['fini2a'] = ''
             replace['fini2b'] = ''
             replace['free2'] = ''
-            make_file(template, f'CallOrdering_{c1}_ok.c', replace)
+            gen.make_file(template, f'CallOrdering_{c1}_ok.c', replace)
         else:
             # Generate the correct ordering with two different collectives
-            replace = patterns
+            replace = patterns.copy()
             replace['shortdesc'] = 'Correct collective ordering'
             replace['longdesc'] = f'All ranks call {c1} and then {c2}'
             replace['outcome'] = 'OK'
             replace['errormsg'] = ''
-            make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
+            gen.make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
             # Generate the incorrect ordering with two different collectives
-            replace = patterns
+            replace = patterns.copy()
             replace['shortdesc'] = 'Incorrect collective ordering'
             replace['longdesc'] = f'Odd ranks call {c1} and then {c2} while even ranks call these collectives in the other order'
             replace['outcome'] = 'ERROR: CallMatching'
             replace['errormsg'] = 'Collective mistmatch. @{c1}@ at @{filename}@:@{line:MBIERROR1}@ is matched with @{c2}@ line @{filename}@:@{line:MBIERROR2}@.'
-            replace['operation1b'] = operation[c2]("2")  # Inversion
-            replace['operation2b'] = operation[c1]("1")
-            replace['fini1a'] = fini[c1]("1") # Inversion
-            replace['fini2a'] = fini[c2]("2")
-            replace['fini1b'] = fini[c2]("2") # Inversion
-            replace['fini2b'] = fini[c1]("1")
-            replace['free1'] = free[c2]("2") 
-            replace['free2'] = free[c1]("1")
+            replace['operation1b'] = gen.operation[c2]("2")  # Inversion
+            replace['operation2b'] = gen.operation[c1]("1")
+            replace['fini1a'] = gen.fini[c1]("1") # Inversion
+            replace['fini2a'] = gen.fini[c2]("2")
+            replace['fini1b'] = gen.fini[c2]("2") # Inversion
+            replace['fini2b'] = gen.fini[c1]("1")
+            replace['free1'] = gen.free[c2]("2")
+            replace['free2'] = gen.free[c1]("1")
 
-            make_file(template, f'CallOrdering_{c1}_{c2}_nok.c', replace)
+            gen.make_file(template, f'CallOrdering_{c1}_{c2}_nok.c', replace)
 
     # Generate the incorrect ordering with one collective
-    replace = patterns
+    replace = patterns.copy()
     replace['shortdesc'] = 'Incorrect collective ordering'
     replace['longdesc'] = f'Odd ranks call {c1} while even ranks do not call any collective'
     replace['outcome'] = 'ERROR: CallMatching'
@@ -161,19 +161,27 @@ for c1 in coll + icoll + ibarrier:
     replace['operation1b'] = ''  # Remove functions
     replace['operation2b'] = ''
     replace['operation2a'] = ''
+    replace['init2'] = ''
     replace['fini1b'] = ''
     replace['fini2a'] = ''
     replace['fini2b'] = ''
-    make_file(template, f'CallOrdering_{c1}_none_nok.c', replace)
+    replace['free1'] = gen.free[c1]("1")
+    replace['free2'] = ''
+    gen.make_file(template, f'CallOrdering_{c1}_none_nok.c', replace)
     # Generate a correct ordering with a conditional not depending on ranks
-    replace = patterns
+    replace = patterns.copy()
     replace['shortdesc'] = 'Correct collective ordering'
-    replace['longdesc'] = f'All ranks call {c1} and then {c2} or inversely'
+    replace['longdesc'] = f'All ranks call {c1}'
     replace['outcome'] = 'OK'
     replace['errormsg'] = ''
     replace['change_cond'] = 'nprocs<256'
-    replace['operation2b'] = '' # Remove functions
+    replace['operation1b'] = '' # Remove functions
+    replace['operation2b'] = ''
     replace['operation2a'] = ''
+    replace['init2'] = ''
+    replace['fini1b'] = ''
+    replace['fini2a'] = ''
     replace['fini2b'] = ''
-    replace['free2a'] = ''
-    make_file(template, f'CallOrdering_{c1}_none_ok.c', replace)
+    replace['free1'] = gen.free[c1]("1")
+    replace['free2'] = ''
+    gen.make_file(template, f'CallOrdering_{c1}_none_ok.c', replace)