Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
added platform for ns3 wifi example
[simgrid.git] / tools / simgrid_convert_TI_traces.py
index 27e2481a8005ae915ac80e793f531c4a53639d87..d3425f8f904f019f4c027c8a2d581a60d26c4056 100755 (executable)
@@ -10,7 +10,7 @@ IRecv call arbitrarily.
 This new that includes tags field that links MPI_wait calls to the
 MPI_ISend or MPI_IRecv associated to this wait.
 
 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
+This script reproduce the old behavior of simgrid because information are
 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
 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
@@ -35,7 +35,7 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"):
 
         new_file_path = os.path.join(output_path, trace_path)
         pathlib.Path(os.path.dirname(new_file_path)).mkdir(
 
         new_file_path = os.path.join(output_path, trace_path)
         pathlib.Path(os.path.dirname(new_file_path)).mkdir(
-                parents=True, exist_ok=True)
+            parents=True, exist_ok=True)
 
         with open(new_file_path, "w") as new_trace:
             # Write header
 
         with open(new_file_path, "w") as new_trace:
             # Write header
@@ -44,7 +44,7 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"):
             last_async_call_src = None
             last_async_call_dst = None
             for line_num, line in enumerate(trace_file.readlines()):
             last_async_call_src = None
             last_async_call_dst = None
             for line_num, line in enumerate(trace_file.readlines()):
-                #print(line)
+                # print(line)
                 new_line = None
                 split_line = line.lower().strip().split(" ")
                 mpi_call = split_line[1]
                 new_line = None
                 split_line = line.lower().strip().split(" ")
                 mpi_call = split_line[1]
@@ -63,8 +63,8 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"):
                     if (last_async_call_src is None
                             or last_async_call_dst is None):
                         raise Exception("Invalid traces: No Isend or Irecv "
                     if (last_async_call_src is None
                             or last_async_call_dst is None):
                         raise Exception("Invalid traces: No Isend or Irecv "
-                                "found before the wait in line " +
-                                str(line_num) + " in file " + old_file_path )
+                                        "found before the wait in line " +
+                                        str(line_num) + " in file " + old_file_path)
                     new_line = insert_elem(split_line, 2, last_async_call_src)
                     new_line = insert_elem(split_line, 3, last_async_call_dst)
                     new_line = insert_elem(split_line, 4, "0")
                     new_line = insert_elem(split_line, 2, last_async_call_src)
                     new_line = insert_elem(split_line, 3, last_async_call_dst)
                     new_line = insert_elem(split_line, 4, "0")
@@ -81,14 +81,13 @@ if __name__ == "__main__":
     import argparse
     import sys
 
     import argparse
     import sys
 
-
     parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__)
 
     parser.add_argument('trace_list_file', type=argparse.FileType('r'),
     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 (e.g. smpi_simgrid.txt)")
+                        default=sys.stdin, help="The trace list file (e.g. smpi_simgrid.txt)")
 
     parser.add_argument('--output_path', '-o', default="converted_traces",
 
     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()
 
 
     args = parser.parse_args()
 
@@ -96,7 +95,7 @@ if __name__ == "__main__":
 
     # creates results dir
     pathlib.Path(args.output_path).mkdir(
 
     # creates results dir
     pathlib.Path(args.output_path).mkdir(
-            parents=True, exist_ok=True)
+        parents=True, exist_ok=True)
 
     # copy trace list file
     try:
 
     # copy trace list file
     try:
@@ -106,7 +105,6 @@ if __name__ == "__main__":
               "Please, select another output path")
         sys.exit(-1)
 
               "Please, select another output path")
         sys.exit(-1)
 
-
     with open(trace_list_file_path) as tracelist_file:
         trace_list = tracelist_file.readlines()
 
     with open(trace_list_file_path) as tracelist_file:
         trace_list = tracelist_file.readlines()
 
@@ -118,9 +116,7 @@ if __name__ == "__main__":
     # process trace files
     for trace_path in trace_list:
         if os.path.isabs(trace_path):
     # process trace files
     for trace_path in trace_list:
         if os.path.isabs(trace_path):
-            print("ERROR: Absolute path in the trace list file is not "
-                  "supported")
-            sys.exit(-1)
+            sys.exit("ERROR: Absolute path in the trace list file is not supported")
         convert_trace(trace_path, base_path, args.output_path)
 
     print("Traces converted!")
         convert_trace(trace_path, base_path, args.output_path)
 
     print("Traces converted!")