Generates a Chrome Trace event to show Launch execution. Args: nodestats: The 'NodeExecStats' proto recording op execution. pid: The pid assigned for the device where this op ran.
(self, nodestats, pid, activity_cache)
| 533 | self._chrome_trace.emit_region(start, duration, pid, tid, 'Op', op, args) |
| 534 | |
| 535 | def _emit_launch(self, nodestats, pid, activity_cache): |
| 536 | """Generates a Chrome Trace event to show Launch execution. |
| 537 | |
| 538 | Args: |
| 539 | nodestats: The 'NodeExecStats' proto recording op execution. |
| 540 | pid: The pid assigned for the device where this op ran. |
| 541 | """ |
| 542 | kernel_name = None |
| 543 | node_name = nodestats.node_name |
| 544 | start = nodestats.op_start_rel_micros |
| 545 | duration = nodestats.op_end_rel_micros |
| 546 | latency = nodestats.all_start_micros - nodestats.op_start_rel_micros |
| 547 | tid = nodestats.thread_id |
| 548 | # Node names should always have the form 'name:op@@kernel_name##target_device_name' |
| 549 | fields = node_name.split('##') |
| 550 | node_name, target_device = fields[:2] |
| 551 | # Node names should always have the form 'name:op@@kernel_name' |
| 552 | fields = node_name.split('@@') + ["unknown"] |
| 553 | node_name, kernel_name = fields[:2] |
| 554 | # Node names should always have the form 'name:op'. |
| 555 | fields = node_name.split(':') + [kernel_name] |
| 556 | node_name, op = fields[:2] |
| 557 | # extract calling contexts via backtracing the parents |
| 558 | cct = "" |
| 559 | parent_id = nodestats.parent_id |
| 560 | while parent_id != 0: |
| 561 | if parent_id not in activity_cache.keys(): |
| 562 | cct += "<unknown>" |
| 563 | break |
| 564 | node, _ = activity_cache[parent_id] |
| 565 | cct += node.node_name + "\n" |
| 566 | parent_id = node.parent_id |
| 567 | if parent_id == 0: |
| 568 | cct += "<root>" |
| 569 | # pack additional infos |
| 570 | args = {'name': node_name, |
| 571 | 'op': op, |
| 572 | 'kernel':kernel_name, |
| 573 | 'latency':latency, |
| 574 | 'target_device':target_device, |
| 575 | 'calling context':cct } |
| 576 | self._chrome_trace.emit_region(start, duration, pid, tid, 'Launch', kernel_name, args) |
| 577 | # now search for the launched kernel event on the target device trace |
| 578 | target_corr_id = nodestats.correlation_id |
| 579 | target_ts = None |
| 580 | target_pid = None |
| 581 | target_tid = None |
| 582 | for dev_stats in self._step_stats.dev_stats: |
| 583 | device_name = dev_stats.device |
| 584 | if device_name != target_device: |
| 585 | continue |
| 586 | target_pid = self._device_pids[device_name] |
| 587 | for node_stats in dev_stats.node_stats: |
| 588 | if node_stats.correlation_id != target_corr_id: |
| 589 | continue |
| 590 | target_tid = node_stats.thread_id |
| 591 | target_ts = node_stats.all_start_micros |
| 592 | break |
no test coverage detected