You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is great that @threads now supports (and uses by default) :dynamic scheduling. As a mirror to that, it would make quite a bit of sense if @distributed could handle dynamic scheduling. As I currently understand it, the best way to currently achieve this would be:
using Distributed
addprocs(whatever)
@everywherefunctiondynamicforeach(f, channel)
whileisopen(channel)
try
task =take!(channel)
ifisnothing(task)
close(channel)
elsef(task)
endcatch e
e isa InvalidStateException && e.state ===:closed&&breakrethrow()
endendend
tasks =1:20
channel =RemoteChannel(() ->Channel{Union{eltype(tasks), Nothing}}(length(tasks)+1))
foreach(t ->put!(channel, t), tasks)
put!(channel, nothing) # Sentinel, end-task@everywheredynamicforeach(task ->println("did $task"), $channel)
It would be both much nicer, and I think rather appropriate if @distributed accepted a :static/:dynamic scheduling argument like @threads does, and allowed for the following instead of the above:
@distributed:dynamicfor task in1:20println("did $task")
end
Going further, I think that :dynamic could actually be a sensible default for distributed scheduling.
In effect? Upon inspection, not much, since pmap already does dynamic scheduling*. However, I think this is could worth doing for the sake of discovery and API consistency. See the first X-ref.
*Maybe this is worth adding to the docs? I wasn't actually aware of this until I tried it.
It is great that
@threads
now supports (and uses by default):dynamic
scheduling. As a mirror to that, it would make quite a bit of sense if@distributed
could handle dynamic scheduling. As I currently understand it, the best way to currently achieve this would be:It would be both much nicer, and I think rather appropriate if
@distributed
accepted a:static
/:dynamic
scheduling argument like@threads
does, and allowed for the following instead of the above:Going further, I think that
:dynamic
could actually be a sensible default for distributed scheduling.Xref: JuliaLang/julia#17887 for having a consistent distributed/threaded API
Xref: JuliaLang/julia#41966 for tedious channel taking
Xref: JuliaLang/julia#48515 for iterating a
RemoteChannel
Xref: JuliaLang/julia#33892 for maybe using a
CachingPool
too?The text was updated successfully, but these errors were encountered: