FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.72k stars 661 forks source link

Use Windows' `_aligned_malloc` paired with `_aligned_free` for MinGW #310

Open albinahlback opened 1 year ago

albinahlback commented 1 year ago

Currently cross-compiling with MinGW (in my case from Linux to Windows) generates an error due to line 131 in kernel/kalloc.c. I am no expert in MinGW, but I suppose one would actually utilize the same case as for MSVC at line 106.

This works for my setup at least. Perhaps there are cases where this won't work?

stevengj commented 1 year ago

On MinGW you should configure with the flag --with-our-malloc (which is effectively equivalent to _aligned_malloc), similar to https://github.com/FFTW/fftw3/blob/master/support/BUILD-MINGW64.sh

stevengj commented 1 year ago

But I guess we could try to automatically use _aligned_malloc on MinGW now that they provide this function. (They didn't used to IIRC.)

albinahlback commented 1 year ago

But I guess we could try to automatically use _aligned_malloc on MinGW now that they provide this function. (They didn't used to IIRC.)

Looking at an answer on StackOverflow, it seems like MinGW has provided _aligned_malloc since at least 2016. Perhaps the best way is to check whether _aligned_alloc is available during the configuration for Windows-type machines?

stevengj commented 1 year ago

Or we could check for _mm_malloc and _mm_free, since it sounds like those are supported even more widely.