-
Notifications
You must be signed in to change notification settings - Fork 9
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
Shorthand for setting number of tasks #76
Comments
Would you want a shortcut for setting the number of tasks or the number of chunks? Note that for Assuming you want a shortcut for the number of tasks, let me first say that I've also had this thought before. Given that we now call the loop macro What's your reason for requesting it? Are you trying to set As for your other idea, at least for now I don't plan to add a "global config" feature. A workaround is to just to instantiate a "global" |
Right, I had But yeah, as you point out, there might not be a single |
Assuming that we make the following work tmapreduce(sin, +, 1:10; ntasks=2) # meaning DynamicScheduler(; nchunks=2) what should happen if both What would we expect to happen in the following cases? tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler()) Should this amount to tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler(; nchunks=5)) Should this amount to tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler(; nchunks=2)) Should this amount to (The macro API should behave in the same way of course.) |
My first naive thought was to respect the kind of scheduling (static, dynamic, ...) when julia> tmapreduce(sin, +, 1:10; ntasks=2) # meaning DynamicScheduler(; nchunks=2)
_scheduler = DynamicScheduler{OhMyThreads.Schedulers.FixedCount}(:default, 2, -1, :batch)
1.4111883712180107
julia> tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler())
_scheduler = StaticScheduler{OhMyThreads.Schedulers.FixedCount}(2, -1, :batch)
1.4111883712180107
julia> tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler(; nchunks=5))
_scheduler = StaticScheduler{OhMyThreads.Schedulers.FixedCount}(2, -1, :batch)
1.4111883712180107
julia> tmapreduce(sin, +, 1:10; ntasks=2, scheduler=StaticScheduler(; nchunks=2))
_scheduler = StaticScheduler{OhMyThreads.Schedulers.FixedCount}(2, -1, :batch)
1.4111883712180107 The reasoning was to allow switching between dynamic and, say, static scheduling and avoid adding |
I think I like this option, but it's hard to say. I could also imagine making it go the other way such that
I think this one is maybe best, that way there's no guessing about which one takes priority. |
FYI: I made a (rather big) PR (#81) where I implement the no guessing strategy from above. In the PR, I don't special case |
PR looks great, will definitely make it work for my use case, and I agree that no-guessing strategy won't make anyone upset but will prevent mistakes. |
Hi,
I really like the macro addition and was wondering if it would make sense for You to include a shorthand for number of spawned tasks?
So having e.g.
@set chunks=8
instead of@set scheduler = DynamicScheduler(; nchunks=8)
?It feels like an option that users would frequently want to change and this would make the code more clear and readable.
On a separate note, not sure how useful it would be in general, but I found myself frequently testing longer pipelines with many functions that have multithreading and having a global setting that changes them all at once makes the work much easier.
I have implemented an "config" struct in my packages that gets queried about parameters to run the code with, but maybe it would be useful to have something similar already here?
The text was updated successfully, but these errors were encountered: