Skip to content

Commit

Permalink
report script, some fixes, new reports, and ...
Browse files Browse the repository at this point in the history
  • Loading branch information
salehjg committed Sep 25, 2021
1 parent dbed368 commit 5a41c35
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions scripts/Report.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,10 @@ def report_xiltimes_cpuusages_pertoplayer(self):
dict_report[reported_layer_name]['pertoplayer.total.xiltime'] += total_device

for n in dict_report.keys():
dict_report[n]['pertoplayer.cpuusage.min'] = np.min(dict_report[n]['pertoplayer.cpuusage.list'])
dict_report[n]['pertoplayer.cpuusage.max'] = np.max(dict_report[n]['pertoplayer.cpuusage.list'])
dict_report[n]['pertoplayer.cpuusage.mean'] = np.mean(dict_report[n]['pertoplayer.cpuusage.list'])
if len(dict_report[n]['pertoplayer.cpuusage.list']) != 0:
dict_report[n]['pertoplayer.cpuusage.min'] = np.min(dict_report[n]['pertoplayer.cpuusage.list'])
dict_report[n]['pertoplayer.cpuusage.max'] = np.max(dict_report[n]['pertoplayer.cpuusage.list'])
dict_report[n]['pertoplayer.cpuusage.mean'] = np.mean(dict_report[n]['pertoplayer.cpuusage.list'])
del dict_report[n]['pertoplayer.cpuusage.list']

return dict_report
Expand Down Expand Up @@ -247,7 +248,7 @@ def report_detailed_relu_sqrt_square_perkernel(self):
dict_detailed['relu.xil']['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed['relu.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers_xil_relu))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['relu.xil']['total.time.xil'] += k['duration']
dict_detailed['relu.xil']['throughput.list'].append(
Expand All @@ -269,7 +270,7 @@ def report_detailed_relu_sqrt_square_perkernel(self):
dict_detailed['sqrt.xil']['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed['sqrt.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers_xil_sqrt))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['sqrt.xil']['total.time.xil'] += k['duration']
dict_detailed['sqrt.xil']['throughput.list'].append(
Expand All @@ -291,7 +292,7 @@ def report_detailed_relu_sqrt_square_perkernel(self):
dict_detailed['square.xil']['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed['square.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers_xil_square))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['square.xil']['total.time.xil'] += k['duration']
dict_detailed['square.xil']['throughput.list'].append(
Expand Down Expand Up @@ -348,7 +349,7 @@ def report_detailed_reduce_sum_max_perkernel(self):
dict_detailed['reduce.max.xil']['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed['reduce.max.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers_xil_max))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['reduce.max.xil']['total.time.xil'] += k['duration']
dict_detailed['reduce.max.xil']['throughput.list'].append(
Expand All @@ -373,7 +374,7 @@ def report_detailed_reduce_sum_max_perkernel(self):
dict_detailed['reduce.sum.r3a2.xil']['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed['reduce.sum.r3a2.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers_xil_sum_r3a2))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['reduce.sum.r3a2.xil']['total.time.xil'] += k['duration']
dict_detailed['reduce.sum.r3a2.xil']['throughput.list'].append(
Expand All @@ -397,7 +398,7 @@ def report_detailed_reduce_sum_max_perkernel(self):
dict_detailed['reduce.sum.r4a012.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(
len(layers_xil_sum_r4a012))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['reduce.sum.r4a012.xil']['total.time.xil'] += k['duration']
dict_detailed['reduce.sum.r4a012.xil']['throughput.list'].append(
Expand Down Expand Up @@ -468,7 +469,7 @@ def report_detailed_pad_unpad_perkernel(self):
dict_detailed['padunpad.unpad.xil']['cpu.usage.mean'] += e['cpu.usage'] / float(
len(layers_xil_unpad))
matched_kernels = self.find_kernel(e['id'])
assert len(matched_kernels) == 1
assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed['padunpad.unpad.xil']['total.time.xil'] += k['duration']
shape_out = copy.deepcopy(e['args']['shape'])
Expand Down Expand Up @@ -510,7 +511,7 @@ def report_detailed_transpose_topk_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
dict_detailed[target_name]['throughput.list'].append(
Expand Down Expand Up @@ -546,7 +547,7 @@ def report_detailed_basicops_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
dict_detailed[target_name]['throughput.list'].append(
Expand Down Expand Up @@ -582,7 +583,7 @@ def report_detailed_tile_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
shape_out = copy.deepcopy(e['args']['shape'])
Expand Down Expand Up @@ -621,7 +622,7 @@ def report_detailed_gather_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
shape_out = copy.deepcopy(e['args']['shape'])
Expand Down Expand Up @@ -665,7 +666,7 @@ def report_detailed_concat2_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
shape_out = copy.deepcopy(e['args']['shape1'])
Expand Down Expand Up @@ -704,7 +705,7 @@ def report_detailed_matmul_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']
rank = len(e['args']['shape1'])
Expand Down Expand Up @@ -759,7 +760,7 @@ def report_detailed_sharedmlp_perkernel(self):
dict_detailed[target_name]['total.time.host'] += (e['time.stop'] - e['time.start']) * 1000.0
dict_detailed[target_name]['cpu.usage.mean'] += e['cpu.usage'] / float(len(layers))
matched_kernels = self.find_kernel(e['id'])
# assert len(matched_kernels) == 1
# assert len(matched_kernels) <= 1
for k in matched_kernels:
dict_detailed[target_name]['total.time.xil'] += k['duration']

Expand Down Expand Up @@ -805,6 +806,18 @@ def report_detailed_datamover_perkernel(self):
dict_detailed['DataMover']['throughput.mean'] = np.mean(dict_detailed['DataMover']['throughput.list'])
return dict_detailed

def report_summary_perkernel(self):
dict_detailed = {}
for record in self.src_json['trace']:
if record['type'] != 'kernel' or record['platform'] != 'xil':
continue
if not (record['name'] in dict_detailed.keys()):
dict_detailed[record['name']] = {'num.calls': 0, 'total.xil': 0}
dict_detailed[record['name']]['num.calls'] += 1
dict_detailed[record['name']]['total.xil'] += record['duration']
return dict_detailed


class CReporter:
def __init__(self, path_json):
self.obj = CProfiler(path_json)
Expand Down Expand Up @@ -866,6 +879,9 @@ def __init__(self, path_json):
self.report.append(self.obj.report_detailed_sharedmlp_perkernel())
self.print_report(self.report[-1], self.new_dump_dir + "/16PerKernelDetailedSharedMLP.json")

self.report.append(self.obj.report_summary_perkernel())
self.print_report(self.report[-1], self.new_dump_dir + "/17PerKernelSummary.json")

def print_report(self, report, dump_fname):
print(
json.dumps(report, sort_keys=True, indent=4),
Expand Down

0 comments on commit 5a41c35

Please sign in to comment.