Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[Tools] TIT convertor script lower case + version + usage
authorMERCIER Michael <michael.mercier@inria.fr>
Thu, 21 Jun 2018 13:30:51 +0000 (15:30 +0200)
committerMERCIER Michael <michael.mercier@inria.fr>
Thu, 21 Jun 2018 13:31:22 +0000 (15:31 +0200)
tools/simgrid_convert_TI_traces.py [moved from tools/simgrid_convert_TIT_traces.py with 81% similarity]

similarity index 81%
rename from tools/simgrid_convert_TIT_traces.py
rename to tools/simgrid_convert_TI_traces.py
index a40b155..e77e526 100755 (executable)
@@ -11,10 +11,12 @@ This new that includes tags field that links MPI_wait calls to the
 MPI_ISend or MPI_IRecv associated to this wait.
 
 This script reproduce the old behavior of simgrid because informations are
-missing to add the tags properly.
+missing to add the tags properly. It also lower case all the mpi calls.
 
 It takes in input (as argument or in stdin) the trace list file that is only a
 simple text file that contains path of actual TIT files split by rank.
+
+It creates a directory to put the traces on ("converted_traces" by default)
 '''
 
 import os
@@ -27,29 +29,36 @@ def insert_elem(split_line, position, elem):
     return " ".join(split_line)
 
 
-def convert_trace(trace_path, base_path, output_path):
+def convert_trace(trace_path, base_path, output_path, trace_version="1.0"):
     old_file_path = os.path.join(base_path, trace_path)
     with open(old_file_path) as trace_file:
+
         new_file_path = os.path.join(output_path, trace_path)
         pathlib.Path(os.path.dirname(new_file_path)).mkdir(
                 parents=True, exist_ok=True)
+
         with open(new_file_path, "w") as new_trace:
+            # Write header
+            new_trace.write("# version: " + trace_version)
+
             last_async_call_src = None
             last_async_call_dst = None
             for line_num, line in enumerate(trace_file.readlines()):
                 #print(line)
                 new_line = None
-                split_line = line.strip().split(" ")
+                split_line = line.lower().strip().split(" ")
                 mpi_call = split_line[1]
+
                 if mpi_call == "recv" or mpi_call == "send":
                     new_line = insert_elem(split_line, 3, "0")
-                if mpi_call == "Irecv" or mpi_call == "Isend":
+
+                elif mpi_call == "irecv" or mpi_call == "isend":
                     last_async_call_src = split_line[0]
                     last_async_call_dst = split_line[2]
                     new_line = insert_elem(split_line, 3, "0")
                     # print("found async call in line: "+ str(line_num))
-                # print("mpi_call: " + mpi_call)
-                if mpi_call == "wait":
+
+                elif mpi_call == "wait":
                     # print("found wait call in line: "+ str(line_num))
                     if (last_async_call_src is None
                             or last_async_call_dst is None):
@@ -73,13 +82,13 @@ if __name__ == "__main__":
     import sys
 
 
-    parser = argparse.ArgumentParser(description=__doc__)
+    parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
 
     parser.add_argument('trace_list_file', type=argparse.FileType('r'),
-            default=sys.stdin, help="the trace list file")
+            default=sys.stdin, help="The trace list file (e.g. smpi_simgrid.txt)")
 
     parser.add_argument('--output_path', '-o', default="converted_traces",
-            help="the path where converted traces will be put")
+            help="The path where converted traces will be put")
 
     args = parser.parse_args()
 
@@ -104,5 +113,5 @@ if __name__ == "__main__":
     for trace_path in trace_list:
         convert_trace(trace_path, base_path, args.output_path)
 
-    print("Done!")
-    print("Result in:\n" + args.output_path)
+    print("Traces converted!")
+    print("Result directory:\n" + args.output_path)