Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
New option to detect dangerous code mixing collectives and P2P in a deadlocking way
[simgrid.git] / teshsuite / smpi / MBI / CollMatchingGenerator.py
index f6575db..5d72ca3 100755 (executable)
@@ -105,39 +105,53 @@ for c1 in gen.coll + gen.icoll + gen.ibarrier:
         patterns['operation2a'] = gen.operation[c2]("2")
         patterns['operation2b'] = gen.operation[c2]("2")
         patterns['change_cond'] = 'rank % 2'
+        shortdesc = ' collective ordering'
 
         if c1 == c2:
             # Generate the correct code using the same collective twice
-            replace = patterns
-            replace['shortdesc'] = 'Correct collective ordering'
+            replace = patterns.copy()
+            replace['shortdesc'] = 'Correct' + shortdesc
             replace['longdesc'] = f'All ranks call {c1} twice'
             replace['outcome'] = 'OK'
             replace['errormsg'] = ''
+            replace['change_cond'] = 'rank < nprocs'
+            replace['operation1b'] = ''
+            replace['operation2b'] = ''
+            replace['fini1b'] = ''
+            replace['fini2b'] = ''
             gen.make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
             # Generate the correct code using the collective once
-            replace = patterns
-            replace['shortdesc'] = 'Correct collective ordering'
+            replace = patterns.copy()
+            replace['shortdesc'] = 'Correct' + shortdesc
             replace['longdesc'] = f'All ranks call {c1} once'
             replace['outcome'] = 'OK'
             replace['errormsg'] = ''
             replace['init2'] = ''
+            replace['change_cond'] = 'rank < nprocs'
             replace['operation2a'] = ''
+            replace['operation1b'] = ''
             replace['operation2b'] = ''
             replace['fini2a'] = ''
+            replace['fini1b'] = ''
             replace['fini2b'] = ''
             replace['free2'] = ''
             gen.make_file(template, f'CallOrdering_{c1}_ok.c', replace)
         else:
             # Generate the correct ordering with two different collectives
-            replace = patterns
-            replace['shortdesc'] = 'Correct collective ordering'
+            replace = patterns.copy()
+            replace['shortdesc'] = 'Correct' + shortdesc
             replace['longdesc'] = f'All ranks call {c1} and then {c2}'
             replace['outcome'] = 'OK'
             replace['errormsg'] = ''
+            replace['change_cond'] = 'rank < nprocs'
+            replace['operation1b'] = ''
+            replace['operation2b'] = ''
+            replace['fini1b'] = ''
+            replace['fini2b'] = ''
             gen.make_file(template, f'CallOrdering_{c1}_{c2}_ok.c', replace)
             # Generate the incorrect ordering with two different collectives
-            replace = patterns
-            replace['shortdesc'] = 'Incorrect collective ordering'
+            replace = patterns.copy()
+            replace['shortdesc'] = 'Incorrect' + shortdesc
             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}@.'
@@ -153,27 +167,35 @@ for c1 in gen.coll + gen.icoll + gen.ibarrier:
             gen.make_file(template, f'CallOrdering_{c1}_{c2}_nok.c', replace)
 
     # Generate the incorrect ordering with one collective
-    replace = patterns
-    replace['shortdesc'] = 'Incorrect collective ordering'
+    replace = patterns.copy()
+    replace['shortdesc'] = 'Incorrect' + shortdesc
     replace['longdesc'] = f'Odd ranks call {c1} while even ranks do not call any collective'
     replace['outcome'] = 'ERROR: CallMatching'
     replace['errormsg'] = 'Collective mistmatch. @{c1}@ at @{filename}@:@{line:MBIERROR1}@ is not matched.'
     replace['operation1b'] = ''  # Remove functions
     replace['operation2b'] = ''
     replace['operation2a'] = ''
+    replace['init2'] = ''
     replace['fini1b'] = ''
     replace['fini2a'] = ''
     replace['fini2b'] = ''
+    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['shortdesc'] = 'Correct collective ordering'
-    replace['longdesc'] = f'All ranks call {c1} and then {c2} or inversely'
+    replace = patterns.copy()
+    replace['shortdesc'] = 'Correct' + shortdesc
+    replace['longdesc'] = f'All ranks call {c1}'
     replace['outcome'] = 'OK'
     replace['errormsg'] = ''
-    replace['change_cond'] = 'nprocs<256'
-    replace['operation2b'] = '' # Remove functions
+    replace['change_cond'] = 'rank < nprocs'
+    replace['operation1b'] = '' # Remove functions
+    replace['operation2b'] = ''
     replace['operation2a'] = ''
+    replace['init2'] = ''
+    replace['fini1b'] = ''
+    replace['fini2a'] = ''
     replace['fini2b'] = ''
-    replace['free2a'] = ''
+    replace['free1'] = gen.free[c1]("1")
+    replace['free2'] = ''
     gen.make_file(template, f'CallOrdering_{c1}_none_ok.c', replace)