Skip to content
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