Skip to content

Commit 9c63657

Browse files
authored
Merge pull request #251 from JuliaParallel/jps/windows-fixes
Windows cputhreadtime fix and 32-bit fixes
2 parents b378f11 + 83b07b0 commit 9c63657

File tree

4 files changed

+23
-26
lines changed

4 files changed

+23
-26
lines changed

Diff for: Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Dagger"
22
uuid = "d58978e5-989f-55fb-8d15-ea34adc7bf54"
3-
version = "0.12.1"
3+
version = "0.12.2"
44

55
[deps]
66
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"

Diff for: src/sch/Sch.jl

+18-18
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ Fields:
4747
- `running_on::Dict{Thunk,OSProc}` - Map from `Thunk` to the OS process executing it
4848
- `thunk_dict::Dict{Int, Any}` - Maps from thunk IDs to a `Thunk`
4949
- `node_order::Any` - Function that returns the order of a thunk
50-
- `worker_pressure::Dict{Int,Dict{Type,UInt}}` - Cache of worker pressure
51-
- `worker_capacity::Dict{Int,Dict{Type,UInt}}` - Maps from worker ID to capacity
50+
- `worker_pressure::Dict{Int,Dict{Type,UInt64}}` - Cache of worker pressure
51+
- `worker_capacity::Dict{Int,Dict{Type,UInt64}}` - Maps from worker ID to capacity
5252
- `worker_loadavg::Dict{Int,NTuple{3,Float64}}` - Worker load average
5353
- `worker_chans::Dict{Int, Tuple{RemoteChannel,RemoteChannel}}` - Communication channels between the scheduler and each worker
5454
- `procs_cache_list::Base.RefValue{Union{ProcessorCacheEntry,Nothing}}` - Cached linked list of processors ready to be used
55-
- `function_cost_cache::Dict{Type{<:Tuple},UInt}` - Cache of estimated CPU time required to compute the given signature
55+
- `function_cost_cache::Dict{Type{<:Tuple},UInt64}` - Cache of estimated CPU time required to compute the given signature
5656
- `halt::Base.Event` - Event indicating that the scheduler is halting
5757
- `lock::ReentrantLock` - Lock around operations which modify the state
5858
- `futures::Dict{Thunk, Vector{ThunkFuture}}` - Futures registered for waiting on the result of a thunk.
@@ -69,12 +69,12 @@ struct ComputeState
6969
running_on::Dict{Thunk,OSProc}
7070
thunk_dict::Dict{Int, Any}
7171
node_order::Any
72-
worker_pressure::Dict{Int,Dict{Type,UInt}}
73-
worker_capacity::Dict{Int,Dict{Type,UInt}}
72+
worker_pressure::Dict{Int,Dict{Type,UInt64}}
73+
worker_capacity::Dict{Int,Dict{Type,UInt64}}
7474
worker_loadavg::Dict{Int,NTuple{3,Float64}}
7575
worker_chans::Dict{Int, Tuple{RemoteChannel,RemoteChannel}}
7676
procs_cache_list::Base.RefValue{Union{ProcessorCacheEntry,Nothing}}
77-
function_cost_cache::Dict{Type{<:Tuple},UInt}
77+
function_cost_cache::Dict{Type{<:Tuple},UInt64}
7878
halt::Base.Event
7979
lock::ReentrantLock
8080
futures::Dict{Thunk, Vector{ThunkFuture}}
@@ -92,12 +92,12 @@ function start_state(deps::Dict, node_order, chan)
9292
Dict{Thunk,OSProc}(),
9393
Dict{Int, Thunk}(),
9494
node_order,
95-
Dict{Int,Dict{Type,UInt}}(),
96-
Dict{Int,Dict{Type,UInt}}(),
95+
Dict{Int,Dict{Type,UInt64}}(),
96+
Dict{Int,Dict{Type,UInt64}}(),
9797
Dict{Int,NTuple{3,Float64}}(),
9898
Dict{Int, Tuple{RemoteChannel,RemoteChannel}}(),
9999
Ref{Union{ProcessorCacheEntry,Nothing}}(nothing),
100-
Dict{Type{<:Tuple},UInt}(),
100+
Dict{Type{<:Tuple},UInt64}(),
101101
Base.Event(),
102102
ReentrantLock(),
103103
Dict{Thunk, Vector{ThunkFuture}}(),
@@ -228,19 +228,19 @@ function init_proc(state, p)
228228
# Initialize pressure and capacity
229229
proc = OSProc(p.pid)
230230
lock(state.lock) do
231-
state.worker_pressure[p.pid] = Dict{Type,UInt}()
232-
state.worker_capacity[p.pid] = Dict{Type,UInt}()
231+
state.worker_pressure[p.pid] = Dict{Type,UInt64}()
232+
state.worker_capacity[p.pid] = Dict{Type,UInt64}()
233233
state.worker_loadavg[p.pid] = (0.0, 0.0, 0.0)
234234
for T in unique(typeof.(get_processors(proc)))
235235
state.worker_pressure[p.pid][T] = 0
236-
state.worker_capacity[p.pid][T] = capacity(proc, T) * UInt(1e9)
236+
state.worker_capacity[p.pid][T] = capacity(proc, T) * UInt64(1e9)
237237
end
238238
state.worker_pressure[p.pid][OSProc] = 0
239239
state.worker_capacity[p.pid][OSProc] = 0
240240
end
241241
cap = remotecall(capacity, p.pid)
242242
@async begin
243-
cap = fetch(cap) * UInt(1e9)
243+
cap = fetch(cap) * UInt64(1e9)
244244
lock(state.lock) do
245245
state.worker_capacity[p.pid] = cap
246246
end
@@ -295,7 +295,7 @@ end
295295
const TASK_SYNC = Threads.Condition()
296296

297297
"Process-local dictionary tracking per-processor total utilization."
298-
const PROC_UTILIZATION = Dict{UInt64,Dict{Type,Ref{UInt}}}()
298+
const PROC_UTILIZATION = Dict{UInt64,Dict{Type,Ref{UInt64}}}()
299299

300300
"""
301301
MaxUtilization
@@ -540,7 +540,7 @@ function schedule!(ctx, state, procs=procs_to_use(ctx))
540540
function has_capacity(p, gp, procutil, sig)
541541
T = typeof(p)
542542
# FIXME: MaxUtilization
543-
extra_util = round(UInt, get(procutil, T, 1) * 1e9)
543+
extra_util = round(UInt64, get(procutil, T, 1) * 1e9)
544544
real_util = state.worker_pressure[gp][T]
545545
if (T === Dagger.ThreadProc) && haskey(state.function_cost_cache, sig)
546546
# Assume that the extra pressure is between estimated and measured
@@ -930,10 +930,10 @@ function do_task(to_proc, extra_util, thunk_id, f, data, send_result, persist, c
930930

931931
# Check if we'll go over capacity from running this thunk
932932
real_util = lock(TASK_SYNC) do
933-
AT = get!(()->Dict{Type,Ref{UInt}}(), PROC_UTILIZATION, uid)
934-
get!(()->Ref{UInt}(UInt(0)), AT, typeof(to_proc))
933+
AT = get!(()->Dict{Type,Ref{UInt64}}(), PROC_UTILIZATION, uid)
934+
get!(()->Ref{UInt64}(UInt64(0)), AT, typeof(to_proc))
935935
end
936-
cap = UInt(capacity(OSProc(), typeof(to_proc))) * UInt(1e9)
936+
cap = UInt64(capacity(OSProc(), typeof(to_proc))) * UInt64(1e9)
937937
while true
938938
lock(TASK_SYNC)
939939
if ((extra_util isa MaxUtilization) && (real_util[] > 0)) ||

Diff for: src/sch/eager.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const EAGER_INIT = Ref{Bool}(false)
22
const EAGER_THUNK_CHAN = Channel(typemax(Int))
3-
const EAGER_ID_MAP = Dict{UInt,Int}()
3+
const EAGER_ID_MAP = Dict{UInt64,Int}()
44
const EAGER_CONTEXT = Ref{Context}()
55
const EAGER_STATE = Ref{ComputeState}()
66

Diff for: src/utils/clock.jl

+3-6
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ elseif Sys.isfreebsd() # atleast on FreeBSD 11.1
2727
elseif Sys.isapple() # Version 10.12 required
2828
const CLOCK_MONOTONIC = Cint(6)
2929
const CLOCK_PROCESS_CPUTIME_ID = Cint(12)
30-
else
31-
@inline cputhreadtime() = time_ns()
32-
return
3330
end
3431

32+
@static if Sys.isunix()
3533
@inline function clock_gettime(cid)
3634
ts = Ref{TimeSpec}()
3735
ccall(:clock_gettime, Cint, (Cint, Ref{TimeSpec}), cid, ts)
@@ -46,10 +44,9 @@ end
4644
maketime(clock_gettime(CLOCK_PROCESS_CPUTIME_ID))
4745
end
4846

49-
@static if Sys.islinux()
5047
@inline function cputhreadtime()
5148
maketime(clock_gettime(CLOCK_THREAD_CPUTIME_ID))
5249
end
53-
else
54-
@inline cputhreadtime() = time_ns()
50+
else # Windows
51+
@inline cputhreadtime() = time_ns() # HACK
5552
end

0 commit comments

Comments
 (0)