Skip to content

Commit 7204709

Browse files
committed
Sch: Allow occupancy key to be Any
1 parent af692b5 commit 7204709

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/sch/util.jl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,12 +362,19 @@ function has_capacity(state, p, gp, time_util, alloc_util, occupancy, sig)
362362
else
363363
get(state.signature_alloc_cost, sig, UInt64(0))
364364
end::UInt64
365-
est_occupancy = if occupancy !== nothing && haskey(occupancy, T)
366-
# Clamp to 0-1, and scale between 0 and `typemax(UInt32)`
367-
Base.unsafe_trunc(UInt32, clamp(occupancy[T], 0, 1) * typemax(UInt32))
368-
else
369-
typemax(UInt32)
370-
end::UInt32
365+
est_occupancy::UInt32 = typemax(UInt32)
366+
if occupancy !== nothing
367+
occ = nothing
368+
if haskey(occupancy, T)
369+
occ = occupancy[T]
370+
elseif haskey(occupancy, Any)
371+
occ = occupancy[Any]
372+
end
373+
if occ !== nothing
374+
# Clamp to 0-1, and scale between 0 and `typemax(UInt32)`
375+
est_occupancy = Base.unsafe_trunc(UInt32, clamp(occ, 0, 1) * typemax(UInt32))
376+
end
377+
end
371378
#= FIXME: Estimate if cached data can be swapped to storage
372379
storage = storage_resource(p)
373380
real_alloc_util = state.worker_storage_pressure[gp][storage]

0 commit comments

Comments
 (0)