()
| 172 | analyzer_tot = ProfileAnalyzer(dump, lambda _, __, ___: True) |
| 173 | |
| 174 | def summary(): |
| 175 | device_end_func = TimeFuncHelper.eval_time_func("device", "end", np.max) |
| 176 | device_kern_func = TimeFuncHelper.eval_time_func("device", "kern", np.max) |
| 177 | host_end_func = TimeFuncHelper.eval_time_func("host", "end", np.max) |
| 178 | |
| 179 | def get_tot_time(func): |
| 180 | rec = analyzer_tot.select(func, aggregate=np.sum) |
| 181 | if not rec: |
| 182 | return "N/A" |
| 183 | rec = rec[0] |
| 184 | return rec.time |
| 185 | |
| 186 | tab = [] |
| 187 | tot_dev_time = get_tot_time(device_end_func) |
| 188 | tot_host_time = get_tot_time(host_end_func) |
| 189 | tab.append(("total device time", tot_dev_time)) |
| 190 | # check device time |
| 191 | if 0 == tot_dev_time: |
| 192 | msg = ( |
| 193 | "please call mgb::CompNode::enable_opencl_profile(true) before profile at c/c++ code" |
| 194 | if is_profile_from_ocl |
| 195 | else "please raise a issue for Engine" |
| 196 | ) |
| 197 | assert 0 != tot_dev_time, "total device time should not be 0, {}".format( |
| 198 | msg |
| 199 | ) |
| 200 | tab.append(("total host time", tot_host_time)) |
| 201 | if args.copy_time: |
| 202 | |
| 203 | def fmt(a, b): |
| 204 | a = a[0] |
| 205 | b = b[0] |
| 206 | return "tot={:.4f} avg={:.4f}".format(a.time, b.time) |
| 207 | |
| 208 | tab.append( |
| 209 | ( |
| 210 | "copy time", |
| 211 | fmt( |
| 212 | analyzer.select( |
| 213 | device_end_func, |
| 214 | lambda opr: opr.opr_info["type"] == "Copy", |
| 215 | aggregate=np.sum, |
| 216 | ), |
| 217 | analyzer.select( |
| 218 | device_end_func, |
| 219 | lambda opr: opr.opr_info["type"] == "Copy", |
| 220 | aggregate=np.mean, |
| 221 | ), |
| 222 | ), |
| 223 | ) |
| 224 | ) |
| 225 | tab.append( |
| 226 | ( |
| 227 | "copy wait time", |
| 228 | fmt( |
| 229 | analyzer.select( |
| 230 | device_kern_func, |
| 231 | lambda opr: opr.opr_info["type"] == "Copy", |
no test coverage detected