-
Notifications
You must be signed in to change notification settings - Fork 8
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
Thread-safe, Channel-like, iteration of chunks #49
Comments
Some timings:
which gives
|
I wander if it makes sense to make the access to chunks and chunk indices always thread safe? I guess that wouldn't affect the current applications. Do you have any thoughts on this @carstenbauer ? |
I think the iterator would need to be stateful then (like my code above and like Channel). |
Do you want to propose a PR before we release 3.0? Probably it is a good time to introduce something new in the API. |
I think we should add this as an option (not the default). Since this is a new feature, and thus non breaking, it doesn't have to go into 3.0 but can be added in any minor version. The remaining question here is how we want to expose this feature. Should users wrap their |
It can easily be generalized to any indexable thing, so perhaps it shouldn't live in this package at all. The main issue with exposing this by default is that you can not iterate over it twice:
so I think you really want to wrap the thing in this in a more local fashion where you know you are about to iterate over it twice, just like in #121. Perhaps this can just be an internal thing in OhMyThreads for now? |
Yeah, let's add this to OhMyThreads for now. (JuliaFolds2/OhMyThreads.jl#121) |
I find the following pattern to be useful:
However, the job producer task, and the task switching between producer and
consumers is unnecessary because the jobs are already "produced" and the
Channel
is only needed here as a way to iterate through the chunks in athread-safe manner.
To get around this, something like
AtomicChunk
(name suggestion?) can beused (Inspired by @KnutAM's similar construct in https://github.com/KnutAM/FerriteAssembly.jl/blob/18fb1a541af37d6ea095cb111e39c3ac1fea8929/src/Multithreading/TaskChunks.jl#L1-L37):
With this we can write the first code block as just a loop over the chunks:
Does such an iterator wrapper exist somewhere? Would something like this be useful to add to this package?
The text was updated successfully, but these errors were encountered: