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

RFC: Track queued FFTW thread count to aid profiling #235

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/providers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ function set_provider!(provider; export_prefs::Bool = false)
end
end

const num_queued_threads = Threads.Atomic{Int}(0)

# If we're using fftw_jll, load it in
@static if fftw_provider == "fftw"
import FFTW_jll
Expand All @@ -55,7 +57,14 @@ end
# tasks (FFTW/fftw3#175):
function spawnloop(f::Ptr{Cvoid}, fdata::Ptr{Cvoid}, elsize::Csize_t, num::Cint, callback_data::Ptr{Cvoid})
@sync for i = 0:num-1
Threads.@spawn ccall(f, Ptr{Cvoid}, (Ptr{Cvoid},), fdata + elsize*i)
Threads.@spawn begin
Threads.atomic_add!(num_queued_threads, 1)
try
ccall(f, Ptr{Cvoid}, (Ptr{Cvoid},), fdata + elsize*i)
finally
Threads.atomic_sub!(num_queued_threads, 1)
end
end
end
end

Expand Down