mathnet / mathnet-numerics

Math.NET Numerics
http://numerics.mathdotnet.com
MIT License
3.47k stars 893 forks source link

multidim fourier transforms error #603

Open tpolakovic opened 5 years ago

tpolakovic commented 5 years ago

When trying to use Fourier transforms (forward or inverse) like for example

let varr = Array.create 60 (Complex (1.0,0.0))
Fourier.ForwardMultiDim(varr, [|3; 4; 5|], o)

I get an error:

System.NotSupportedException: "Specified method is not supported."
  at MathNet.Numerics.Providers.FourierTransform.Managed.ManagedFourierTransformProvider.ForwardMultidim(Complex[] samples, Int32[] dimensions, FourierTransformScaling scaling)

This is on OS X Mojave 10.14 using Visual Studio 2017.

cdrnet commented 5 years ago

Yes, unfortunately multidim is supported only with the MKL native provider at this point - despite of our design principle that all functionality must work also with the built-in managed provider. I'll keep this issue open until this is fixed. Thanks for the reminder.

tpolakovic commented 5 years ago

I see. On a related note, I tried using the MKL native provider (built following the steps on the MathNet website) and now I'm getting this error:

Unhandled Exception: System.NotSupportedException: MKL Native Provider not found. ---> System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies.

Any idea why that may be happening?

cdrnet commented 5 years ago

This used to work. Maybe we need to use libdl.dylib instead of libdl.so to dynamically load the provider on newer OSX versions? I don't have a mac, so I cannot test myself.

bronco382 commented 5 years ago

Any updates or workarounds for the original issue?

nrkramer commented 3 years ago

This issue is now 3 years old. It blocks more usage than just MultiDim API, because 2D Fourier transforms rely on a multidimensional transform. It makes it hard to do any kind of multidimensional Fourier analysis on macOS. It should be higher priority.

@cdrnet I'd say that your hunch about using the .dylib extension is spot on, seeing as darwin does not natively load elf binaries, but mach ones. If you want a guinea pig, I'm happy to test out the changes for you.

nrkramer commented 3 years ago

Additionally, newer Macs now run an AMD architecture that requires the use of AVX2 hardware vectorized instructions in order to optimize for MKL. AVX2 support can be enabled by setting the environment variable MKL_DEBUG_CPU_TYPE=5 while compiling on an AMD system. I highly recommend this be enabled for AMD architectures if it isn't already.

IS4Code commented 1 year ago

Any progress on this? It's not really the best thing to have to download 150 MB of MKL just for one Fourier transform.