-
Notifications
You must be signed in to change notification settings - Fork 12
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
runqueue: allocate threads to >= 1 cores #248
Conversation
Support multiple cores in the runqueue. The current allocation for each core is stored in a new array. Thus, any call to `get_next_for_core` is minimal effort. The allocation is updated after each change in the runqueue.
The "unsupported generic default" hax error is being tackled here: hacspec/hax#597 |
Export `CoreId`.
This got fixed quickly upstream, nice. :) Here's how to work around the u8 matching hax error: hacspec/hax#598 (comment) |
Clean code & improve readability.
Optimize case where `N_CORES` == 1.
Make hax (hopefully) happy.
Thanks! I fixed the previous errors by using early return and rust iterator. Now a new error happens. I opened hacspec/hax#603. |
In the multicore scenario, a yielding thread isn't necessarily the head of the runqueue. This commit adds a method `advance_from` to yield from any thread in the queue. The thread is then moved to the tail of the runqueue.
Remove unused method `advance_head` (duplication of `Runqueue::advance`).
025dbd6
to
dcf08c1
Compare
Handle case N_CORES == 1 separately.
So I did some benchmarks to test performance for single core with this PR. I used
I am not really happy with the current solution, but need to somehow differentiate between single and multicore because for multicore much more cases have to be taken into account/ handled. |
Additional note regarding performance: |
…to runqueue/multiple-cores
Add new `GlobalRunqueue` trait to differentiate and optimize for different number of cores on the type level. It uses the `min_specialization` rust feature to have a generic implementation for _n_ number of cores and fine-grained specialization of methods for concrete _n_.
I now found a solution for this using the rust |
(Converted back to draft because of an idea for an alternative implementation that just came to my mind). |
Closing because I decided to for an alternative implementation of the multicore scheduler, where the runqueue itself doesn't need to support multicore. |
See #244.
Add support for multicore to the runqueue.
The current allocation for each core is stored in a new array so that any call to
get_next_for_core
remains minimal effort.The allocation is updated after each change in the runqueue. The reallocation currently has complexity O(n) because we a) need to get n threads for the n cores and b) need to iterate through the lists of new and old allocations to compare what has changed. Given that we have a very low number of cores I'd say this is okay. Wdyt?
I also had to add a new method
del
to theCList
because with multiple running threads we can't assume that the deleted thread is always the head.