-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Hexagon] Add HexagonThreadManager #11653
Conversation
- Updated HexagonThreadManager interface to use TVMStreams - Added second `Dispatch` interfce in thread manager to use PackedFuncs - Updated thread manager to use vector for dynamic semaphore allocation - Added "#if defined(__hexagon__)" in several places to prevent compilation errors
- Fixed GetStreams not returning the streams properly - Added missing semaphore cleanup to prevent qurt kernel resource leakage - new interface functions: - Start() : now all worker threads are blocked on initialization until ThreadManager->Start() is called - WaitOnThreads() : blocking call which waits until all worker thread queues are empty - added extra debug logging - Two new basic thread tests working
… capacity adjustment invaliding in-use addresses).
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.
Could you move the buffer manager changes to a separate PR? They seem independent from the thread manager.
On another note---all the thread manager files spell "threadmanager" without the underscore, while "buffer manager" has one. Could you add the underscore for consistency? |
I am basically moving this functionality from within the Hexagon Device API where it lived previously to a separate header file. Both the Hexagon Device API and the Hexagon Thread Manager need a Hexagon Buffer Manager. The alternative would be two duplicate code in two places. |
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.
My general feedback would be mostly about coding style. This patch doesn't conform to the style used in TVM (for example, private class member names should end with _, etc.). Besides that:
- Almost any pointer can be implicitly converted to
void*
, so most (if not all) of thereinterpret_cast<void*>(...)
are unnecessary. - Please use
nullptr
instead ofreinterpret_cast<...>(0)
. - Please avoid C-style casts, i.e.
(type)value
. In particular, please replace(TVMStreamHandle)i
withstatic_cast<TVMStreamHandle>(i)
. - In several cases, there is code that constructs a message for
DBG
/DLOG
that will execute unconditionally, even ifDLOG
is disabled. Even though the constructed string is not used, the code creating it will most likely not be removed (because it can contain library calls, etc).
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.
The (TVMStreamHandle)i
is still there. It's not that much of a big deal, but it would be nice to replace it with static_cast
eventually.
Thanks Adam! |
Missed this. Will fix. [Edit] We need reinterpret_cast to cast between |
Just realized that I named my commit Just thinking out loud here ... the other thing we can do RE |
I wouldn't worry about renaming a commit in the PR. The code looks fine. For some reason I thought that the stream handle was actually an integer... |
Just a reminder that CI is failing because it requires this PR #11635 |
This PR was made in collaboration with @JosephTheOctonaut.
Add HexagonThreadManager class and unit testing. HexagonThreadManager can be used to spawn a given number of QURT threads on which the user can
Dispatch
work including basicSignal
andWait
functionality to create synchronization points between threads. This PR adds the low-level HexagonThreadManager class only. Related Hexagon Device API support and codegen to come in future PRs.This PR is dependent on #11635 to pass CI.
cc @mehrdadh