Skip to content

next_line_prefetch_idx in read_buffer.py  #111

@xuanway

Description

@xuanway

Hello,
I have a question regarding the calculation the next_line_prefetch_idx in read_buffer.py.
The relevant code block from lines 309-312 (def prefetch_active_buffer(self, start_cycle)) of read_buffer.py is as following:

    if requested_data_size > self.active_buf_size: # Set the line to be prefetched next
        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[0]

To enhance the correctness of the logic, I suggest the following modification:

    if requested_data_size > self.active_buf_size: # Set the line to be prefetched next
        self.next_line_prefetch_idx = (num_lines - 1) % self.fetch_matrix.shape[0]
    else:
        self.next_line_prefetch_idx = num_lines % self.fetch_matrix.shape[0]

The reason for this modification is as follows: The row indices for fetch_matrix start from 0. When requested_data_size > self.active_buf_size, it indicates that the last line of the current prefetch requests(prefetch_requests[num_lines-1]) cannot be entirely accommodated within active_buf. Therefore, self.next_line_prefetch_idx is set to (num_lines-1) % self.fetch_matrix.shape[0], which starts from prefetch_requests[num_lines-1].
Similarly, when requested_data_size <= self.active_buf_size, it suggests that the last line of the current prefetch requests(prefetch_requests[num_lines-1]) can fit entirely within active_buf. Hence, self.next_line_prefetch_idx is set to num_lines % self.fetch_matrix.shape[0], which starts from prefetch_requests[num_lines].

Looking forward to your feedback and suggestions.
Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions