New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu-o3: Clear thread state in time buffers on thread exit #1052
base: develop
Are you sure you want to change the base?
Conversation
Fix gem5#1049. Clear only thread-specific state from the O3 CPU time buffers, rather than clearing *all* state for *all* threads. Specifically, this patch adds a `clearStates()` method for all O3 time buffer structs in src/cpu/o3/comm.hh. Upon thread exit, `CPU::removeThread()` now invokes this method for all structs in each time buffer, rather than flushing out the time buffers (which nukes the states for all threads, not just the exiting one). Change-Id: I48cd50e39b3cd5e0068ddfc19a03d9bbd3f31bd5
@andysan, we would appreciate it if you could review this PR. Thank you. |
auto has_tid = [tid] (const DynInstPtr &inst) -> bool { | ||
return inst->threadNumber == tid; | ||
}; | ||
DynInstPtr *last = std::remove_if(insts, insts + size, has_tid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this working? insts is actually pointing to a C-style array of DynInstPtr. What will remove_if actually do? I though it was supposed to be used with mutable types like std::vector. I have the gut feeling this might be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the slow response. Correct me if I'm wrong, but I think you might be thinking of std::erase_if, which operates on C++ containers like std::vector and std::map? My understanding is that std::remove_if works on arbitrary ranges, including C-style arrays. How std::remove_if works is for each element to be removed, it moves (specifically using a move assignment) an element from the end of the array to the index of the remove element.
@nmosier, could you address Giacomo's questions? Thank you. |
Fix #1049. Clear only thread-specific state from the O3 CPU time buffers, rather than clearing all state for all threads.
Specifically, this patch adds a
clearStates()
method for all O3 time buffer structs in src/cpu/o3/comm.hh. Upon thread exit,CPU::removeThread()
now invokes this method for all structs in each time buffer, rather than flushing out the time buffers (which nukes the states for all threads, not just the exiting one).Change-Id: I48cd50e39b3cd5e0068ddfc19a03d9bbd3f31bd5