-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
fftwf_plan_dft is not threadsafe #18
Comments
Sorry to hear that, but in the actual design eDSP is a single thread library, it does not have any support for multithreaded application mostly because it aims to be a base implementation for DSP/low latency applications and I did not want to introduce the penalty of having You can always build a wrapper on top of it or keep the lock in your implementation. In this scenario, I do normally have an FFT instance per thread. |
Oh well okay didn't knew the single threaded approach. Then it actually is not really a bug. On the other hand i use it exactly like you describe it. On two threads i call the xcorr function independently on independent vectors/datasets. Since the xcorr creates a FFT instance itself i have a independet FFT instance per thread and it still does crash. The FFTW doc i mentioned on thread-safety states "The FFTW planner is intended to be called from a single thread. If you really must call it from multiple threads, you are expected to grab whatever lock makes sense for your application..." and since exactly that is happening it kinda is a bug. |
Good point! I completely forget about that. I need to update the official documentation to make that point clear. I see what you mean. So in my case, I'm using a factory provider. Just a simple: I wanted to do something similar to what the standard does with the I'm gonna try to come with a better approach and provide a helper in the utils section in future releases. |
Hey it's me again.
I found out during testing the xcorr that the fftw implementation is not threadsafe.
More Specific it is the calls to the
fftwf_plan_dft
functions.The only functions that are threadsafe itself are the
fftwf_execute
calls.Found the info here and here.
I fixed it by passing a mutex to the xcorr call and passing it all the way down to the fftw impl as a member reference and wrapping a lock around the
fftwf_plan_dft
calls.It's a bit hacky but does the job for my project.
Example:
The text was updated successfully, but these errors were encountered: