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

call to NativeMethods.fftwf_sprint_plan(handle); crashes #3

Closed
siddjain opened this issue Mar 22, 2022 · 10 comments
Closed

call to NativeMethods.fftwf_sprint_plan(handle); crashes #3

siddjain opened this issue Mar 22, 2022 · 10 comments

Comments

@siddjain
Copy link

Thanks a lot for this library. The call to NativeMethods.fftwf_sprint_plan(handle); crashes however. Any chance you could fix this?

@wo80
Copy link
Owner

wo80 commented Mar 22, 2022

Adding [return: MarshalAs(UnmanagedType.LPStr)] should do the trick, like

[return: MarshalAs(UnmanagedType.LPStr)]
public static extern string fftw_sprint_plan(IntPtr plan);

I'll update the code later today.

@wo80 wo80 closed this as completed in f41ecbd Mar 22, 2022
@siddjain
Copy link
Author

Great! Thank you for fixing it so quickly.

@siddjain
Copy link
Author

unfortunately it still crashes with this change! try it!

@wo80
Copy link
Owner

wo80 commented Mar 22, 2022

I tested it before committing the fix. It works for me. Which platform are you on, which FFTW dll are you using?

Could you - just for testing purpose - change the method to return an IntPtr to see if the call works?

[DllImport(Library, EntryPoint = "fftw_sprint_plan", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr fftw_sprint_plan(IntPtr plan);

@siddjain
Copy link
Author

I am on Windows x64. Using the precompiled dlls available on FFTW website. returning an IntPtr followed by Marshal.PtrToStringAnsi worked for me.

@siddjain
Copy link
Author

@wo80
Copy link
Owner

wo80 commented Mar 22, 2022

Alright, I'm using the recent FFTW 3.3.10 compiled with Visual Studio 2022. Marshal.PtrToStringAnsi works for me too, so I'll update the code to use that version.

@siddjain
Copy link
Author

could you share the link to the binary? i can only find fftw-3.3.5-dll64 on official website.

@wo80
Copy link
Owner

wo80 commented Mar 22, 2022

There's a link in the readme, pointing to version 3.3.9 with only SSE2 enabled: http://wo80.bplaced.net/math/packages-fftw.html

I compiled my local version with AVX2 only, if I remember correctly. I'll upload it, if you are interested.

The CMake build script has it's pitfalls (SSE/AVX wasn't detected automatically for me), but it's not too hard to get it working, so you could also try to compile the code for yourself.

@siddjain
Copy link
Author

thanks for the link and for making fftw accessible to C# developers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants