Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

nmosier
Copy link
Contributor

@nmosier nmosier commented Apr 21, 2024

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

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
@ivanaamit ivanaamit added the cpu-o3 gem5's Out-Of-Order CPU label Apr 22, 2024
@ivanaamit
Copy link
Contributor

@andysan, we would appreciate it if you could review this PR. Thank you.

@andysan
Copy link
Contributor

andysan commented Apr 29, 2024

I don't think I'm the right person for O3 SMT issues. Maybe @giactra or @rjc-arch can help?

@giactra giactra self-requested a review May 2, 2024 10:30
auto has_tid = [tid] (const DynInstPtr &inst) -> bool {
return inst->threadNumber == tid;
};
DynInstPtr *last = std::remove_if(insts, insts + size, has_tid);
Copy link
Contributor

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

Copy link
Contributor Author

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.

@ivanaamit
Copy link
Contributor

@nmosier, could you address Giacomo's questions? Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpu-o3 gem5's Out-Of-Order CPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cpu-o3: executing MFENCE in two parallel SMT threads causes hang
4 participants