Compilation Error when using DFFT_FFTW3 and DFFT_SINGLE

Dear developers,

I was getting Error when compiling LAMMPS with -DFFT_SINGLE -DFFT_FFTW3 flags, with 'Undefined reference to 'fftw_cleanup()' in main.cpp'. I double checked and could not find any errors in my linking, but after some digging I concluded that the function call 'fftw_cleanup()' in main.cpp might be the problem. I am no expert on the FFTW3 library, but I believe that fftwf_cleanup() should be used with single precision, instead of fftw_cleanup(). At least it compiles successfully after adding the 'f' :slight_smile:

I have also tried to add some more logic to main.cpp, to call 'fftwf_cleanup()' when both FFT_FFTW3 and FFT_SINGLE flags are used, and 'fftw_cleanup()' when only FFT_FFTW3. And it also seems to work.

Not sure if it's a bug or not, but want to report it anyway.

(By the way, I am using latest stable (16Mar18) version of LAMMPS, but the 'fftw_cleanup()' command was added just in October, so other versions could be affected as well.)

Best regards,

Juri

Dear developers,

I was getting Error when compiling LAMMPS with -DFFT_SINGLE -DFFT_FFTW3
flags, with 'Undefined reference to 'fftw_cleanup()' in main.cpp'. I double
checked and could not find any errors in my linking, but after some digging
I concluded that the function call 'fftw_cleanup()' in main.cpp might be the
problem. I am no expert on the FFTW3 library, but I believe that
fftwf_cleanup() should be used with single precision, instead of
fftw_cleanup(). At least it compiles successfully after adding the 'f' :slight_smile:

I have also tried to add some more logic to main.cpp, to call
'fftwf_cleanup()' when both FFT_FFTW3 and FFT_SINGLE flags are used, and
'fftw_cleanup()' when only FFT_FFTW3. And it also seems to work.

Not sure if it's a bug or not, but want to report it anyway.

yes, this is a bug and your proposed fix is the correct way to address it:

diff --git a/src/main.cpp b/src/main.cpp
index 82dac5af6..95368385b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -70,6 +70,10 @@ int main(int argc, char **argv)
#ifdef FFT_FFTW3
   // tell fftw3 to delete its global memory pool
   // and thus avoid bogus valgrind memory leak reports
+#ifdef FFT_SINGLE
+ fftwf_cleanup();
+#else
   fftw_cleanup();
#endif
+#endif
}

(By the way, I am using latest stable (16Mar18) version of LAMMPS, but the
'fftw_cleanup()' command was added just in October, so other versions could
be affected as well.)

they all are. the fact, that you are the first person reporting it
since then shows, how few people use single precision FFTs. the
benefit of using them is rather limited on modern machines.

thanks for letting us know,
      axel.