From d78b47704bf244a728768e028f178024eebc8c20 Mon Sep 17 00:00:00 2001 From: ritikraj7 Date: Mon, 30 Sep 2024 17:59:00 -0400 Subject: [PATCH] bug fixes for ifmap and ofmap stalls --- scalesim/memory/double_buffered_scratchpad_mem.py | 2 +- scalesim/memory/read_buffer.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scalesim/memory/double_buffered_scratchpad_mem.py b/scalesim/memory/double_buffered_scratchpad_mem.py index 1b08ecaab..4cb1935d4 100644 --- a/scalesim/memory/double_buffered_scratchpad_mem.py +++ b/scalesim/memory/double_buffered_scratchpad_mem.py @@ -185,7 +185,7 @@ def service_memory_requests(self, ifmap_demand_mat, filter_demand_mat, ofmap_dem ofmap_cycle_out = self.ofmap_buf.service_writes(incoming_requests_arr_np=ofmap_demand_line, incoming_cycles_arr_np=cycle_arr) ofmap_serviced_cycles += [ofmap_cycle_out[0]] - ofmap_stalls = ofmap_cycle_out[0] - cycle_arr[0] - 1 + ofmap_stalls = ofmap_cycle_out[0] - cycle_arr[0] self.stall_cycles += int(max(ifmap_stalls[0], filter_stalls[0], ofmap_stalls[0])) diff --git a/scalesim/memory/read_buffer.py b/scalesim/memory/read_buffer.py index 9f35a3aef..fe2a70770 100644 --- a/scalesim/memory/read_buffer.py +++ b/scalesim/memory/read_buffer.py @@ -239,6 +239,9 @@ def service_reads(self, incoming_requests_arr_np, # 2D array with the requests self.new_prefetch() potential_stall_cycles = self.last_prefect_cycle - (cycle + offset) offset += potential_stall_cycles # Offset increments if there were potential stalls + if potential_stall_cycles > 0: + offset += potential_stall_cycles + out_cycles = cycle + offset out_cycles_arr.append(out_cycles) @@ -382,7 +385,7 @@ def new_prefetch(self): if requested_data_size > self.active_buf_size: self.next_line_prefetch_idx = num_lines % self.fetch_matrix.shape[0] else: - self.next_line_prefetch_idx = (num_lines + 1) % self.fetch_matrix.shape[1] + self.next_line_prefetch_idx = (num_lines + 1) % self.fetch_matrix.shape[0] # This does not need to return anything