| 102 | |
| 103 | # Add log entry |
| 104 | def append(self, raw_name, record_name, latency, msg_size): |
| 105 | algbw, busbw = calc_bw_log(raw_name, msg_size, latency) |
| 106 | if record_name in self.comms_dict.keys(): |
| 107 | # If this comm_op has already been logged with this message size, just add to existing record |
| 108 | if msg_size in self.comms_dict[record_name].keys(): |
| 109 | self.comms_dict[record_name][msg_size][0] += 1 |
| 110 | self.comms_dict[record_name][msg_size][1].append(latency) |
| 111 | self.comms_dict[record_name][msg_size][2].append(algbw) |
| 112 | self.comms_dict[record_name][msg_size][3].append(busbw) |
| 113 | # If this is a new message size for this comm_op, add new record under existing comm_op |
| 114 | else: |
| 115 | self.comms_dict[record_name][msg_size] = [1, [latency], [algbw], [busbw]] |
| 116 | else: |
| 117 | # Create entirely new record |
| 118 | self.comms_dict[record_name] = {msg_size: [1, [latency], [algbw], [busbw]]} |
| 119 | # If verbose, print every comm op |
| 120 | # TODO: Add to tensorboard |
| 121 | if self.verbose: |
| 122 | log_str = f"comm op: {record_name} | time (ms): {latency:.2f} | msg size: {convert_size(msg_size)} | algbw (Gbps): {algbw:.2f} | busbw (Gbps): {busbw:.2f}" |
| 123 | log_dist(log_str, [0]) |
| 124 | |
| 125 | def get_raw_data(self): |
| 126 | """ |