| 85 | |
| 86 | |
| 87 | def parse(file): |
| 88 | with open(file, "r") as read_file: |
| 89 | data = json.load(read_file) |
| 90 | |
| 91 | #Get marker names and first marker's time |
| 92 | list_names = [] |
| 93 | first_marker = True |
| 94 | first_marker_time = 0 |
| 95 | for i in data: |
| 96 | if (i): |
| 97 | if ("Marker start:" in i['name']) and ( |
| 98 | i['name'] not in list_names): |
| 99 | list_names.append(i['name']) |
| 100 | if first_marker: |
| 101 | first_marker_time = i['ts'] |
| 102 | first_marker = False |
| 103 | |
| 104 | if (args.debug): |
| 105 | print(f"FIRST MARKER TIME DETERMINED: {first_marker_time}") |
| 106 | |
| 107 | if (first_marker_time == 0): |
| 108 | raise ("FIRST MARKER TIME IS ZERO. EXITING...") |
| 109 | |
| 110 | kernel_launch_info = [] #kernel description |
| 111 | kernel_launch_list = [] #kernel launch details |
| 112 | kernel_launch_time = [] #kernel execution time |
| 113 | for i in data: |
| 114 | if (i and i.get('args')): |
| 115 | try: |
| 116 | if (("KernelExecution" in i['args']['desc']) |
| 117 | and (i['ts'] >= first_marker_time)): |
| 118 | kernel_launch_info.append(i['args']['desc']) |
| 119 | kernel_launch_list.append(i) |
| 120 | kernel_launch_time.append(int(i['dur'])) |
| 121 | except: |
| 122 | continue |
| 123 | |
| 124 | max_index = kernel_launch_time.index(max(kernel_launch_time)) |
| 125 | max_kernel_info = kernel_launch_list[max_index] |
| 126 | |
| 127 | if (args.debug): |
| 128 | with open('rocTX_kernel_launch_list.txt', 'w') as f: |
| 129 | for i in kernel_launch_list: |
| 130 | f.write(f'{i}') |
| 131 | |
| 132 | # Get timing information for each marker name |
| 133 | list_times_per_names = [] |
| 134 | for name in list_names: |
| 135 | temp_list = [] |
| 136 | for entry in data: |
| 137 | if (entry) and ( |
| 138 | name == entry['name'] |
| 139 | ): # name can match on gpu or cpu side, for gpu, we need data from gpu markers. |
| 140 | if (("gpu::" in name) |
| 141 | and ("UserMarker frame:" in entry['args']['desc']) |
| 142 | ): #gpu side information |
| 143 | temp_list.append(int(entry.get('dur'))) |
| 144 | elif (("gpu::" not in name) |