FFTW not working when I compile it myself

  • abczyx123987
    17th Aug 2011 Member 0 Permalink
    As the thread title suggests, I can compile FFTW, and get it to link in when I compile TPT, but if I open TPT, it crashes when I try to turn on Newtonian gravity. I tried rebuilding FFTW (this time with a static library, and without threads), but the same thing happened.

    Even if I use the libraries and dll provided by ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip to compile TPT, it crashes when I put an element in that changes the gravity field (e.g. black hole).

    To build FFTW (the first time I tried), I used

    ./configure LIBS=-lpthread --with-our-malloc16 --enable-shared --disable-static --enable-threads --with-combined-threads --enable-float --enable-sse
    make
    make install

    And the second time:

    ./configure --with-our-malloc16 --enable-float --enable-sse
    make
    make install

    (running Windows XP SP3 (x86), using MinGW and compiling from within an MSYS shell)

    And, as I said, both times TPT crashes with Newtonian gravity turned on if I link with the files created here.
    Using the files from ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip, it doesn't crash right when I turn Newtonian gravity on, but rather when I put some BHOL or something like that in.

    Am I doing something wrong?
  • abczyx123987
    17th Aug 2011 Member 0 Permalink
    (sorry for bump; I haven't gotten an answer yet, so...)

    I also found that if I compile in Visual Studio using the files from ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip, the problem goes away completely....
    ...what's going on here?
  • BlueAmulet
    17th Aug 2011 Member 0 Permalink

    Deleted

    Edited once by BlueAmulet. Last: 12th April
  • abczyx123987
    17th Aug 2011 Member 0 Permalink
    @gamax92 (View Post)
    What do you mean?
    When I compile TPT with MinGW, it crashes at some point with Newtonian Gravity on no matter which dll I use.
    Compiling with the dll from ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip using Visual Studio seems to work fine, although I would prefer to use MinGW instead of Visual Studio (which starts up very slowly, doesn't support C99, is picky about where variables are declared, etc...).

    A little debugging shows that using my dll, TPT segfaults at line 190 (this is with the v57.5 source) in air.c:

    plan_ptgravx = fftwf_plan_dft_r2c_2d(yblock2, xblock2, th_ptgravx, th_ptgravxt, FFTW_MEASURE);


    I tried copy/pasting a section of air.c containing that line of code into a new file and compiling that by itself, and it ran perfectly fine without any trouble.

    ...Nobody else has run into a problem like this? (but then again, the wikis haven't been updated to tell how to compile with FFTW, so....)
  • BlueAmulet
    17th Aug 2011 Member 0 Permalink

    Deleted

    Edited once by BlueAmulet. Last: 12th April
  • abczyx123987
    17th Aug 2011 Member 0 Permalink
    Well, at least now I know I'm not alone. :)

    I wonder how the devs do it...do they compile the windows version with Visual Studio or what...?
    (or maybe cross-compiling for Windows from a Linux computer doesn't have that problem?)
  • jacksonmj
    17th Aug 2011 Developer 0 Permalink
    The official binaries don't have FFTW enabled at the moment, because it makes them enormous. FFTW isn't essential, just a speed improvement for gravity calculations. You can remove -DGRAVFFT and -lfftw3f from the Makefile and TPT will still work fine.


    I've reproduced the problem on Windows, but not yet managed to fix it. If grav_fft_init() is run from the main thread, that function works fine and TPT instead crashes in update_grav. I wondered whether it was a stack overflow, but I tried increasing the stack size with pthread_attr_setstacksize and it still crashed in the same place.

    Cross-compiling from Linux seems to work fine (using mingw32-fftw3 packages from system repositories, I haven't yet experimented with compiling it myself or using files from fftw.org on Linux).