@@ -190,47 +190,38 @@ def _parse_logs(self, logs):
190190 break
191191
192192 parse_status = False
193- kernel_gpu_time = 0.0
193+ time_unit = TimeUnit ()
194+
194195 if kernel_line_from is not None and kernel_line_to is not None :
195196 for i in range (kernel_line_from , kernel_line_to ):
196197 print (logs [i ])
198+ if i >= kernel_line_from + 4 :
199+ gpu_time , percent , function = self ._parse_line (logs [i ])
200+ time_unit .add_info (gpu_time , function )
197201 print ("" )
198202 parse_status = True
199- kernel_gpu_time = self ._parse_gpu_time (logs [kernel_line_from + 4 ])
200203
201- memcpy_gpu_time = 0.0
202204 if memcpy_line_from is not None and memcpy_line_to is not None :
203205 for i in range (memcpy_line_from , memcpy_line_to ):
204206 print (logs [i ])
207+ if i >= memcpy_line_from + 4 :
208+ gpu_time , percent , function = self ._parse_line (logs [i ])
209+ time_unit .add_info (gpu_time , function )
205210 print ("" )
206211 parse_status = True
207- memcpy_gpu_time = self ._parse_gpu_time (logs [memcpy_line_from + 4 ])
208-
209- total_gpu_time = kernel_gpu_time + memcpy_gpu_time
210- if total_gpu_time != 0.0 :
211- print (
212- "total gpu_time: {:.4f} ms (kernel: {:.4f} ms ({:.2f}%); memcpy: {:.4f} ms ({:.2f}%))" .
213- format (total_gpu_time , kernel_gpu_time , kernel_gpu_time * 100 /
214- total_gpu_time , memcpy_gpu_time , memcpy_gpu_time * 100 /
215- total_gpu_time ))
216- else :
217- print (
218- "total gpu_time: {:.4f} ms (kernel: {:.4f} ms; memcpy: {:.4f} ms)" .
219- format (total_gpu_time , kernel_gpu_time , memcpy_gpu_time ))
220- print ("" )
221- return parse_status , total_gpu_time
222212
223- def _parse_gpu_time (self , line ):
213+ print (time_unit )
214+ return parse_status , time_unit .total ()
215+
216+ def _parse_line (self , line ):
224217 infos = line .strip ().split ()
225218 percent = float (infos [0 ].replace ("%" , "" )) * 0.01
226219 gpu_time = float (infos [1 ].replace ("," , "" )) * 1E-6
227220 calls = int (infos [2 ].replace ("," , "" ))
228221 function = infos [7 ]
229222 for i in range (8 , len (infos )):
230223 function = function + " " + infos [i ]
231- #print("percent: %.2f; gpu_time: %.4f ms; calls: %d; function: %s" %
232- # (percent, gpu_time, calls, function))
233- return gpu_time / percent
224+ return gpu_time , percent , function
234225
235226
236227def launch (benchmark_script ,
0 commit comments