Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP workstealing scheduler + refactor for easier experimentation #55542

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
8 changes: 7 additions & 1 deletion base/schedulers/CDLL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,15 @@
return node !== nothing && !is_special(node)
end

const _PADDING_TUPLE = ntuple(zero, 15)
mutable struct ConcurrentDoublyLinkedList{T}
@atomic header::Union{Node{T}, Nothing}
@atomic header::Union{Node{T}, Nothing} # 8 bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 byte on 32 bit, right?

padding::NTuple{15,UInt64} # 120 bytes
@atomic trailer::Union{Node{T}, Nothing}
padding2::NTuple{15,UInt64}
function ConcurrentDoublyLinkedList{T}(header::Union{Node{T}, Nothing}, trailer::Union{Node{T}, Nothing}) where {T}
new{T}(header, _PADDING_TUPLE, trailer, _PADDING_TUPLE)
end
end

function ConcurrentDoublyLinkedList{T}() where {T}
Expand Down Expand Up @@ -257,3 +263,3 @@

const Queue = CDLL

Expand Down
11 changes: 11 additions & 0 deletions base/schedulers/workstealing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ function attempt_steal!()
end
end
end
for i in 1:(nt) # Try to steal from other threads round robin
t = QueueModule.steal!(queue_for(Int(i))) #TODO: Change types of things to avoid the convert
if t !== nothing
if ccall(:jl_set_task_tid, Cint, (Any, Cint), t, tid-1) == 0
push!(queue_for(tid), t)
ccall(:jl_wakeup_thread, Cvoid, (Int16,), (Threads.threadid(t) - 1) % Int16)
else
return t
end
end
end
return nothing
end

Expand Down
Loading