forked from learning-process/parallel_programming_course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_perf_table.py
More file actions
104 lines (93 loc) · 4.03 KB
/
create_perf_table.py
File metadata and controls
104 lines (93 loc) · 4.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import argparse
import os
import re
import xlsxwriter
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', help='Input file path (logs of perf tests, .txt)', required=True)
parser.add_argument('-o', '--output', help='Output file path (path to .xlsx table)', required=True)
args = parser.parse_args()
logs_path = os.path.abspath(args.input)
xlsx_path = os.path.abspath(args.output)
list_of_type_of_tasks = ["all", "mpi", "omp", "seq", "stl", "tbb"]
result_tables = {"pipeline": {}, "task_run": {}}
set_of_task_name = []
logs_file = open(logs_path, "r")
logs_lines = logs_file.readlines()
for line in logs_lines:
pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
result = re.findall(pattern, line)
if len(result):
task_name = result[0][1]
perf_type = result[0][2]
set_of_task_name.append(task_name)
result_tables[perf_type][task_name] = {}
for ttype in list_of_type_of_tasks:
result_tables[perf_type][task_name][ttype] = -1.0
for line in logs_lines:
pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)'
result = re.findall(pattern, line)
if len(result):
task_type = result[0][0]
task_name = result[0][1]
perf_type = result[0][2]
perf_time = float(result[0][3])
if perf_time < 0.1:
msg = f"Performance time = {perf_time} < 0.1 second : for {task_type} - {task_name} - {perf_type} \n"
raise Exception(msg)
result_tables[perf_type][task_name][task_type] = perf_time
for table_name in result_tables:
workbook = xlsxwriter.Workbook(os.path.join(xlsx_path, table_name + '_perf_table.xlsx'))
worksheet = workbook.add_worksheet()
worksheet.set_column('A:Z', 23)
right_bold_border = workbook.add_format({'bold': True, 'right': 2, 'bottom': 2})
bottom_bold_border = workbook.add_format({'bold': True, 'bottom': 2})
cpu_num = os.environ.get("PROC_COUNT")
if cpu_num is None:
raise EnvironmentError("Required environment variable 'PROC_COUNT' is not set.")
cpu_num = int(cpu_num)
worksheet.write(0, 0, "cpu_num = " + str(cpu_num), right_bold_border)
it = 1
for type_of_task in list_of_type_of_tasks:
worksheet.write(0, it, "T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border)
it += 1
worksheet.write(0, it, "S(" + str(cpu_num) + ")" + " = " +
"T_seq(" + str(cpu_num) + ")" + " / " +
"T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border)
it += 1
worksheet.write(0, it, "Eff(" + str(cpu_num) + ")" + " = " +
"S(" + str(cpu_num) + ")" + " / " + str(cpu_num), right_bold_border)
it += 1
it = 1
for task_name in list(set(set_of_task_name)):
worksheet.write(it, 0, task_name, workbook.add_format({'bold': True, 'right': 2}))
it += 1
it_i = 1
it_j = 1
right_border = workbook.add_format({'right': 2})
for task_name in list(set(set_of_task_name)):
for type_of_task in list_of_type_of_tasks:
if task_name not in result_tables[table_name].keys():
print(f"Warning! Task '{task_name}' is not found in results")
worksheet.write(it_j, it_i, "Error!")
it_i += 1
worksheet.write(it_j, it_i, "Error!")
it_i += 1
worksheet.write(it_j, it_i, "Error!")
it_i += 1
continue
par_time = result_tables[table_name][task_name][type_of_task]
seq_time = result_tables[table_name][task_name]["seq"]
if par_time == 0:
speed_up = -1
else:
speed_up = seq_time / par_time
efficiency = speed_up / cpu_num
worksheet.write(it_j, it_i, par_time)
it_i += 1
worksheet.write(it_j, it_i, speed_up)
it_i += 1
worksheet.write(it_j, it_i, efficiency, right_border)
it_i += 1
it_i = 1
it_j += 1
workbook.close()