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
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]
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")
import argparse
import sys
-
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",
- help="The path where converted traces will be put")
+ help="The path where converted traces will be put")
args = parser.parse_args()
# creates results dir
pathlib.Path(args.output_path).mkdir(
- parents=True, exist_ok=True)
-
- assert trace_list_file_path != args.output_path, (
- "Inplace replacement of the trace is not supported: select "
- "another output path")
+ parents=True, exist_ok=True)
# copy trace list file
try:
shutil.copy(trace_list_file_path, args.output_path)
except shutil.SameFileError:
print("ERROR: Inplace replacement of the trace is not supported: "
- "Please, select another output path")
+ "Please, select another output path")
sys.exit(-1)
-
with open(trace_list_file_path) as tracelist_file:
trace_list = tracelist_file.readlines()
# process trace files
for trace_path in trace_list:
- assert not os.path.isabs(trace_path), (
- "Absolute path in the trace list file is not supported")
+ if os.path.isabs(trace_path):
+ 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!")