-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Description
Hi!
I wanted to disable threading such that I can calculate the NFFT along the first two dimensions, and loop myself along the third dim.
The for loop should be threaded since that should be more beneficial than threading the NFFT itself.
However, I can still see some threading happening.
Even worse, if I wrap a manual Threads.@threads in a loop, the results contain NaNs. Interestingly, using nfft directly, and not the plan, no NaNs.
Code:
# ╔═╡ fe43bf1c-d923-11ed-0a5a-49c652d9550e
using NFFT, FFTW
# ╔═╡ 1d50c640-1a26-4e0c-bfc2-9238f0f65f4f
FFTW.set_num_threads(1)
# ╔═╡ 5c0a30ab-dd03-4693-8411-1503e0f8d438
NFFT._use_threads[] = false
# ╔═╡ 5ee3ea66-123a-4875-8139-00f0571c86d9
arr = randn(ComplexF64, (1024, 1024, 10));
# ╔═╡ 5124e68a-2233-4653-831e-0020c7b490e2
coords = rand(-0.4:0.001:0.4, (2, 1024 * 1024))
# ╔═╡ d566e0b9-5e48-41d9-b59d-955aed49b036
function f(x, coords)
p = NFFT.plan_nfft(coords, (size(x,1), size(x,2)))
out = similar(x)
# removing the @threads is ok but slow
Threads.@threads for i in axes(x, 3)
out[:, :, i] = reshape(p * x[:, :, i], size(x, 1), size(x,2))
end
return out
end
# ╔═╡ 878c4fc3-fafc-4266-b391-bc367dd70b08
abs.(f(arr, coords))
Metadata
Metadata
Assignees
Labels
No labels