Skip to content

Commit 902c584

Browse files
committed
Sch: Check iscompatible_* in can_use_proc
1 parent a4d6a67 commit 902c584

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/sch/Sch.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ function schedule!(ctx, state, procs=procs_to_use(ctx))
774774

775775
for proc in local_procs
776776
gproc = get_parent(proc)
777-
can_use, scope = can_use_proc(task, gproc, proc, opts, scope)
777+
can_use, scope = can_use_proc(state, task, gproc, proc, opts, scope)
778778
if can_use
779779
has_cap, est_time_util, est_alloc_util, est_occupancy =
780780
has_capacity(state, proc, gproc.pid, opts.time_util, opts.alloc_util, opts.occupancy, sig)
@@ -806,7 +806,7 @@ function schedule!(ctx, state, procs=procs_to_use(ctx))
806806
cap, extra_util = nothing, nothing
807807
procs_found = false
808808
# N.B. if we only have one processor, we need to select it now
809-
can_use, scope = can_use_proc(task, entry.gproc, entry.proc, opts, scope)
809+
can_use, scope = can_use_proc(state, task, entry.gproc, entry.proc, opts, scope)
810810
if can_use
811811
has_cap, est_time_util, est_alloc_util, est_occupancy =
812812
has_capacity(state, entry.proc, entry.gproc.pid, opts.time_util, opts.alloc_util, opts.occupancy, sig)
@@ -832,7 +832,7 @@ function schedule!(ctx, state, procs=procs_to_use(ctx))
832832
@goto pop_task
833833
end
834834

835-
can_use, scope = can_use_proc(task, entry.gproc, entry.proc, opts, scope)
835+
can_use, scope = can_use_proc(state, task, entry.gproc, entry.proc, opts, scope)
836836
if can_use
837837
has_cap, est_time_util, est_alloc_util, est_occupancy =
838838
has_capacity(state, entry.proc, entry.gproc.pid, opts.time_util, opts.alloc_util, opts.occupancy, sig)

src/sch/util.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ function signature(f, args)
322322
return sig
323323
end
324324

325-
function can_use_proc(task, gproc, proc, opts, scope)
325+
function can_use_proc(state, task, gproc, proc, opts, scope)
326326
# Check against proclist
327327
if opts.proclist !== nothing
328328
@warn "The `proclist` option is deprecated, please use scopes instead\nSee https://juliaparallel.org/Dagger.jl/stable/scopes/ for details" maxlog=1
@@ -369,6 +369,24 @@ function can_use_proc(task, gproc, proc, opts, scope)
369369
return false, scope
370370
end
371371

372+
# Check against f/args
373+
Tf = chunktype(task.f)
374+
if !Dagger.iscompatible_func(proc, opts, Tf)
375+
@dagdebug task :scope "Rejected $proc: Not compatible with function type ($Tf)"
376+
return false, scope
377+
end
378+
for (_, arg) in task.inputs
379+
arg = unwrap_weak_checked(arg)
380+
if arg isa Thunk
381+
arg = state.cache[arg]
382+
end
383+
Targ = chunktype(arg)
384+
if !Dagger.iscompatible_arg(proc, opts, Targ)
385+
@dagdebug task :scope "Rejected $proc: Not compatible with argument type ($Targ)"
386+
return false, scope
387+
end
388+
end
389+
372390
@label accept
373391

374392
@dagdebug task :scope "Accepted $proc"

0 commit comments

Comments
 (0)