Comments (4)
Good spot, Ben. Yes this was a bug introduced in ecd5ab3.
I noticed that waiters are inserted at the front of the list which seems like it may also be intentional to try to keep wait/notify pairs on the same thread (or at least provide some ordering); is that right?
There was no strong reason, and perhaps it should be reversed. You could argue that FILO is good for icache, but certainly isn't fair, and does contradict the FIFO nature of scheduler. It is the way it is because it was simpler to implement (marl:: containers::list
doesn't actually keep a pointer to the end item), and there's no order guarantees in the documented interface. It might be worth implementing FIFO for ConditionVariable
and doing some benchmarking.
I need to customize ConditionVariable a bit for my use case, so I was trying to understand the load-bearing parts of the implementation
Are you able to share what sort of customizations you need to make?
from marl.
There was no strong reason, and perhaps it should be reversed. You could argue that FILO is good for icache, but certainly isn't fair, and does contradict the FIFO nature of scheduler. It is the way it is because it was simpler to implement (
marl:: containers::list
doesn't actually keep a pointer to the end item), and there's no order guarantees in the documented interface. It might be worth implementing FIFO forConditionVariable
and doing some benchmarking.
Good points! FIFO may work better for what I'm doing, but that would require a doubly-linked list probably.
Are you able to share what sort of customizations you need to make?
The synchronization primitive I'm working with is basically Vulkan's timeline semaphore/D3D12's fence - so a single monotonically increasing payload value that is signaled and waiters wait for a specific payload value to be reached or exceeded. It could be implemented as a uint64_t + marl::ConditionVariable, but by specializing it I can keep track of waiters with the value they expect and only notify those whose who need to be when signaling (and avoid an extra mutex).
It may be a useful primitive to have in marl itself - if there's interest I'd be happy to upstream!
from marl.
FIFO may work better for what I'm doing, but that would require a doubly-linked list probably.
Yes, probably. Happy to make changes here if we feel there's wins to be had.
The synchronization primitive I'm working with is basically Vulkan's timeline semaphore/D3D12's fence - so a single monotonically increasing payload value that is signaled and waiters wait for a specific payload value to be reached or exceeded. It could be implemented as a uint64_t + marl::ConditionVariable, but by specializing it I can keep track of waiters with the value they expect and only notify those whose who need to be when signaling (and avoid an extra mutex).
Similar to (but clearly not the same as) marl::Ticket::Queue
. In fact, the original implementation of marl::Ticket::Queue
was based around internals very similar to this. I'm not happy about the performance of tickets, so if you come up with something awesome, perhaps I'll take a look at whether its possible to re-implement tickets to use it.
It may be a useful primitive to have in marl itself - if there's interest I'd be happy to upstream!
Certainly sounds like it. Very happy to accept new primitives!
from marl.
Interesting! I was about to take a deeper look at Ticket::Queue to see if I could use it for modeling vkQueueSubmit ordering behavior (the ordering described here: https://www.khronos.org/registry/vulkan/specs/1.2/html/vkspec.html#synchronization-implicit), but now that you mention it this may be better served by a simple FIFO chain as all I'd be doing with Ticket::Queue is taking a new ticket and waiting on the previous one such that things behaved like a FIFO. That definitely calls for a doubly linked list so that may be worth adding (marl::containers::deque?).
from marl.
Related Issues (20)
- Tests aren't run, only built
- CHANGES.md says that the version is 1.0.0-dev but there is no such tag HOT 1
- [question] enabling support for new architecture -- riscv64 HOT 5
- Can't capture unique_ptr in marl::schedule lambda HOT 1
- [Question] Fiber yield behavior HOT 4
- [Question] implemention of function alignedFree() HOT 1
- [Question] Mutex for fiber HOT 3
- Difference between option_if_not_defined and option HOT 1
- [Question] Scheduler suspend/resume and stop HOT 2
- Multiple tasks queued to the same worker while other workers are idle HOT 8
- what's the difference between task and fiber? HOT 12
- Webassembly compatibility HOT 6
- [Question] effect ParallelFor HOT 3
- JNI from Fibers HOT 3
- Pool API missing important feature for object construction!!! HOT 2
- [Question] Waiting for multiple events to be signaled to protect a critical section HOT 2
- crashed when Scheduler::Worker::tryLock HOT 2
- how to schedule function to the marl same thread?
- Does marl support switching context while unwinding stack? i.e. is it exception safe? HOT 1
- Should DAGNodeBuilder::then move the `work` away or just forward? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marl.