05-12-09-Write Buffer

From Msim

Jump to: navigation, search

This page discusses the write buffer patch related to an infinite loop trying to remove elements from the write buffer.

The Problem

The loop that controlled emptying the write buffer (when detected as full) compared the first element against sim_cycle to see if it were less than sim_cycle and can be removed. However, if the write buffer became empty through this, it would continue to try to delete these elements.

The offending code

From commit:

if((MD_OP_FLAGS(contexts[context_id].LSQ[contexts[context_id].LSQ_head].op) & (F_MEM|F_STORE)) == (F_MEM|F_STORE))
{
 if(cores[core_num].write_buf.size() == cores[core_num].write_buf_size)
 {
  while(*(cores[core_num].write_buf.begin()) < sim_cycle))
  {
   cores[core_num].write_buf.erase(cores[core_num].write_buf.begin());
  }
 }

Corrected Code

The while needs to check that the buffer is not empty first.

if((MD_OP_FLAGS(contexts[context_id].LSQ[contexts[context_id].LSQ_head].op) & (F_MEM|F_STORE)) == (F_MEM|F_STORE))
{
 if(cores[core_num].write_buf.size() == cores[core_num].write_buf_size)
 {
  while(!cores[core_num].write_buf.empty() && (*(cores[core_num].write_buf.begin()) < sim_cycle))
  {
   cores[core_num].write_buf.erase(cores[core_num].write_buf.begin());
  }
 }
Personal tools