JuliaParallel / Dagger.jl

A framework for out-of-core and parallel execution
Other
637 stars 67 forks source link

No way to set scheduler options for eager API #308

Open kshyatt opened 2 years ago

kshyatt commented 2 years ago
function init_eager()
    EAGER_INIT[] && return
    EAGER_INIT[] = true
    ctx = eager_context()
    @async try
        sopts = SchedulerOptions(;allow_errors=true)
        topts = ThunkOptions(;single=1)
        Dagger.compute(ctx, Dagger.delayed(eager_thunk;options=topts)(); options=sopts)
    catch err
        iob = IOContext(IOBuffer(), :color=>true)
        println(iob, "Error in eager scheduler:")
        Base.showerror(iob, err)
        Base.show_backtrace(iob, catch_backtrace())
        println(iob)
        seek(iob.io, 0)
        write(stderr, iob)
    finally
        EAGER_INIT[] = false
    end
end

This creates its own set of scheduler and thunk options.

function _spawn(f, args...; kwargs...)
    Dagger.Sch.init_eager()
    uid = eager_next_id()
    future = ThunkFuture()
    finalizer_ref = poolset(EagerThunkFinalizer(uid))
    added_future = Future()
    put!(Dagger.Sch.EAGER_THUNK_CHAN, (added_future, future, uid, finalizer_ref, f, (args...,), (kwargs...,)))
    thunk_ref = fetch(added_future)
    return (uid, future, finalizer_ref, thunk_ref)
end

and spawn seems to not pass any of the kwargs (where proclist would presumably be) to init_eager.

jpsamaroo commented 2 years ago

With more and more features using/relying on the eager API (which has only 1 scheduler), I'm considering making SchedulerOptions an internal API, and ripping out most of its functionality and tests. All of the same options are available in ThunkOptions, and with #328 now merged, it's easy enough to make options act as if they were set globally.

@kshyatt you might want to try out the new Dagger.with_options API and see if that works for you; I imagine you were trying to set procutil globally?