-
Notifications
You must be signed in to change notification settings - Fork 28
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
NFFT in parallel #17
Comments
On Julia v0.4.5 the code runs without errors. Let me find an v0.5 and test. |
I can run your code without errors in Julia v0.5.0 on Linux Mint. What does |
Hello, I forgot to tell that I have problem with this code only when Julia is using several workers (julia -p nprocs). Similar code was working perfectly with the Version 4.5 of Julia. julia> versioninfo() Regards |
I get seg faults on both Julia v0.4.5 and v0.5.0, but the fault is happening in A recent change in NFFT is to use a precomputed plan to perform the ordinary FFT part: What used to be I don't have experience with |
Testing with the ordinary FFT confirms my suspicion: Precomputed plans for FFT do not work in parallel. Check e.g. the following:
This seg faults my It's unfortunate that the precomputed FFT plans in NFFT causes problems at this approach allows us to have only one @tknopp : Any thoughts on this? Maybe it's better to ask wiser people for help with the FFT. |
If I remember correctly there is an option in FFTW to make a plan thread safe. This is a little different since it is about multi-process parallelism but it may work. But our plan is certainly not safe to be used in different threads, because of the tmp vector. |
@DeVerMyst : Have you looked into the correctness of your results when using NFFT in parallel? |
@robertdj : I use the NFFT in parallel in PAINTER.jl |
I have next to no experience with parallel computing in Julia, but I don't understand why the different threads are not overwriting the same temporary array... |
@DeVerMyst: Its not surprising that your code works because in you have |
That explains it! |
Hello, Do you have any idea on how to make it work on julia v.5 ? Regards |
@DeVerMyst your code should work on Julia 0.5. The example that you posted on top of this issue is not what you have done here: As long as you have a dedicated plan for each process, it should work. |
In order to present to You my problem I gave a lighter version of the code I use without thinking it can have a problem of temporary variable. I wrote to You because it was not working with Julia 0.5. Other libraries also, but I tried them one by one and I got this pb with NFFT and or FFTW. https://github.com/DeVerMyst/ForJulia5 Best regards |
That code works for me and does not segfault |
on a Mac |
Hello, For me when I launch julia 0.5 without workers and so not in parallel, it s working. Here is my versioninfo() : Julia Version 0.5.0 I tried on a second mac and we obtain a segfault also, here is the versioninfo(): julia> versioninfo() Regards |
ok confirmed. segfaults here as well. But this is an issue with fftw and you should be able reproducing a similar test case that does not involve any nfft. So this would be more suitable as a bug in the JuliaLang/julia repository. Or maybe @stevengj could shim in here and report if the segfault is expected (I have no experience using fifth with multi-process shared-memory Julia). |
Seems like it needs FFTW 3.3.5 and |
Oh, sorry, this issue is not about threading... |
FFTW plans can't be serialized and sent to other processes, I don't think. Seems like Julia should throw an exception if you try to do this. |
Aaaa, I just saw that we switched in this package to the low level fftw interface where we store the plan https://github.com/tknopp/NFFT.jl/blob/master/src/NFFT.jl#L205 I originally used |
So one would have to modify the code in https://github.com/DeVerMyst/ForJulia5/blob/master/painternnfftpar.jl to somehow create the plans on the remote and not all in the master process. But I don't have a clue how to do that... |
I did indeed started to save the plan at some point (also noted earlier in this thread). For now, it's probably easier to revert to using |
I'd forgotten about this issue. Let me make the revert to |
I am not so sure about that. In a single processing environment what you do is actually what we want. And also for the multi-threading case it is possible to cache the FFTW plan as Steve indicated above |
Maybe an optional parameter and an |
I agree with:
Didn't Steven write:
I read that as if it could not be done..? Since the precomputed plans break stuff I'm thinking that we can revert to |
Regarding the optional par, I suppose we can check if |
One has to distinguish multiprocessing and multithreading. In my opinion with Julia 0.5 supporting multithreading, the multiprocessing use case is not so important anymore. |
Right. If e.g. the Painter package is using multiprocessing don't you think it is worth supporting (for now)? P.s.: Sorry if I rushed through this. |
Thats fine. lets just have a parameter |
I just finished writing up a fix before you answered: https://github.com/robertdj/NFFT.jl/blob/master/src/NFFT.jl#L208 What do you think of this? |
yea that also a good approach. Lets stick with that |
Cool. I'll do the tagging later and close this issue. |
nice, I fixed a small issue with the density compensation methods in the mean time. don't know if you use that (the In my research group be are starting doing MRI research and therefore will use this package more and more in the future. |
@tknopp : Have you published the tag v0.1.3 to METADATA? Otherwise I'll do it now along with a new v0.1.4. |
no this was by accident. Please do it and thanks. |
I was /am playing around with PkgDev. Making releases seems pretty easy nowadays |
It is pretty easy :-) Now the releases await approval. |
Hello, trying to update a software for Julia V.5 I got this problem:
nx = 64
nb = 195
nw = 20
serial
using NFFT
println(" serial ")
fr = rand(2,nb) - .5
plan = NFFTPlan( fr , (nx,nx))
x = rand(nx,nx) + 0.*im
F = nfft(plan,x)
parallel 1
println(" p1 ")
Fx = SharedArray( Complex{Float64}, (nb, nw))
@sync @parallel for n in 1:nw
println("worker")
plan = NFFTPlan( fr , (nx,nx))
x = rand(nx,nx) + 0.*im
Fx[:,n] = nfft(plan, x)
end
plan = NFFTPlan( fr , (nx,nx))
@sync @parallel for n in 1:nw
println("worker")
x = rand(nx,nx) + 0.*im
Fx[:,n] = nfft(plan, x)
end
julia> include("testnfft.jl")
serial
p1
From worker 2: worker
signal (11): Segmentation fault: 11
while loading no file, in expression starting on line 0
fftw_execute_dft at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia//libfftw3.dylib (unknown line)
The text was updated successfully, but these errors were encountered: