Bug #1037
CMake detects SSE4.1 but compilation fails
Description
As reported on gmx-developers, I am trying to compile the latest release-4-6 branch, but it fails with errors related to SSE4.1 optimization. Attached are my CMakeCache.txt, CMakeFiles/CMakeOutput.log, and CMakeFiles/CMakeError.log files. Manually adding -msse4.1 to CMAKE_C_FLAGS circumvents the problem and produces functional executables.
Associated revisions
History
#1 Updated by Szilárd Páll about 8 years ago
Could you please provide the full cmake invocation as well. Based on the CMakeCache you provided everything should be working as expected:
GMX_CPU_ACCELERATION:STRING=SSE4.1 GMX_SUGGESTED_CPU_ACCELERATION:INTERNAL=SSE4.1 GNU_SSE4_CFLAG:INTERNAL=1 GNU_SSE4_CXXFLAG:INTERNAL=1 HAVE_SMMINTRIN_H:INTERNAL=1
#2 Updated by Justin Lemkul about 8 years ago
I built using
ccmake ../release-4-6
The only variable settings I changed were related to FFTW since they were not auto-detected. I can try using cmake instead while manually specifying any necessary variables.
#3 Updated by Justin Lemkul about 8 years ago
- File files2.tar.gz files2.tar.gz added
cmake invoked with:
cmake ../release-4-6/ -DFFTWF_LIBRARY=/usr/local/fftw-3.3.2/lib/libfftw3f.so -DFFTWF_INCLUDE_DIR=/usr/local/fftw-3.3.2/include/ -DCMAKE_INSTALL_PREFIX=/home/jalemkul/gmx-test
Same error occurs during compilation. Files attached.
#4 Updated by Roland Schulz about 8 years ago
What cmake version is this?
#5 Updated by Justin Lemkul about 8 years ago
Version 2.8.2 - do I need an upgrade? I suspect that's somewhat outdated.
#6 Updated by Roland Schulz about 8 years ago
That is old, but anything 2.8.x should in theory work. But the older ones are less tested.
#7 Updated by Roland Schulz about 8 years ago
I can reproduce it with cmake 2.8.2.
#8 Updated by Szilárd Páll about 8 years ago
Roland Schulz wrote:
I can reproduce it with cmake 2.8.2.
That's weird, with cmake 2.8.0 it works for me. So what fails with 2.8.2? Justin's cache file suggests that both -msse4.1 and smmintrin.h checks have succeeded.
#9 Updated by Roland Schulz about 8 years ago
Never mind. I tested incorrectly. Can't reproduce it. Justin, did you delete CMakeCache.txt before you ran cmake? Do you get any warnings?
#10 Updated by Justin Lemkul about 8 years ago
Roland Schulz wrote:
Never mind. I tested incorrectly. Can't reproduce it. Justin, did you delete CMakeCache.txt before you ran cmake? Do you get any warnings?
Almost everything I do fails, with one weird exception.
1. ccmake ../release-4-6 fails with the above
2. Removal of CMakeCache.txt and re-running ccmake ../release-4-6 does the exact same thing
3. The cmake command above (not ccmake) fails with the same thing
4. Running ccmake, removal of CMakeCache.txt, and then re-running cmake as shown above works. Why the heck is that the case?
#11 Updated by Roland Schulz about 8 years ago
Could you add line
message("Set: ${GROMACS_C_FLAGS_SET} Flags: ${GROMACS_C_FLAGS}")
before line 1070 (right after "NO MORE TESTS AFTER THIS LINE!")? And both the result of the message?
#12 Updated by Roland Schulz about 8 years ago
Justin Lemkul wrote:
Roland Schulz wrote:
Never mind. I tested incorrectly. Can't reproduce it. Justin, did you delete CMakeCache.txt before you ran cmake? Do you get any warnings?
Almost everything I do fails, with one weird exception.
1. ccmake ../release-4-6 fails with the above
2. Removal of CMakeCache.txt and re-running ccmake ../release-4-6 does the exact same thing
3. The cmake command above (not ccmake) fails with the same thing
but this was without deleting CMakeCache.txt?
4. Running ccmake, removal of CMakeCache.txt, and then re-running cmake as shown above works. Why the heck is that the case?
We only set the flags the first time around. So if the first run of ccmake/cmake somehow messes up and then it doesn't help anymore to run cmake/ccmake again.
So it seems that cmake works but ccmake doesn't. What exactly did you do in ccmake?
1. Configure
2. change FFTW values
3. Configure
Or anything else?
#13 Updated by Justin Lemkul about 8 years ago
Roland Schulz wrote:
Could you add line
[...]
before line 1070 (right after "NO MORE TESTS AFTER THIS LINE!")? And both the result of the message?
Result is:
Set: Flags: -msse4.1
#14 Updated by Justin Lemkul about 8 years ago
Roland Schulz wrote:
Justin Lemkul wrote:
Roland Schulz wrote:
Never mind. I tested incorrectly. Can't reproduce it. Justin, did you delete CMakeCache.txt before you ran cmake? Do you get any warnings?
Almost everything I do fails, with one weird exception.
1. ccmake ../release-4-6 fails with the above
2. Removal of CMakeCache.txt and re-running ccmake ../release-4-6 does the exact same thing
3. The cmake command above (not ccmake) fails with the same thingbut this was without deleting CMakeCache.txt?
That's with an empty directory, starting over from scratch, just to test the difference between cmake and ccmake.
4. Running ccmake, removal of CMakeCache.txt, and then re-running cmake as shown above works. Why the heck is that the case?
We only set the flags the first time around. So if the first run of ccmake/cmake somehow messes up and then it doesn't help anymore to run cmake/ccmake again.
So it seems that cmake works but ccmake doesn't. What exactly did you do in ccmake?
1. Configure
2. change FFTW values
3. ConfigureOr anything else?
That's it - the only problem is with finding FFTW.
#15 Updated by Roland Schulz about 8 years ago
I think I found the problem. It goes wrong if FFTW fails and thus the GROMACS_C_FLAGS aren't being written. Then the 2nd time around the flags aren't detected again. I'll verify. Just keeping this up to date, in case Szilard is looking at it too.
Fix GMX_TEST_CFLAG bug with acceleration flags
If a cmake error occured (e.g. fftw not found) between a flag being
tested (e.g. -msse4.1) and the flags being set, then those flags
weren't set. Neither on the first run with the error, nor later
because in later runs GROMACS_C_FLAGS_SET would already be set.
Fixes #1037
Change-Id: Ibc555d885bab5bec04a1aa5b10f06351e6aa6f38