nest-simulator
nest-simulator copied to clipboard
Described and actual behavior of -Dwith-optimize don't match
Description
While doing some benchmarks together with @ackurth, we discovered that there is a discrepancy between the description and behavior of the flag -Dwith-optimize
. According to the description in the file CMakeLists.txt the default is OFF
yielding -O2
. Changing it to ON
should yield -O3
. Contrary to the description, the default is ON
:
set( with-optimize ON CACHE STRING "Enable user defined optimizations [default=OFF (uses '-O2')]. When ON, '-O3' is used. Separate multiple flags by ';'." )
Looking at cmake/ProcessOptions.cmake shows that ON
actually leads to -O2
and OFF
yields no optimization, which is afaik -O0
.
function( NEST_PROCESS_WITH_OPTIMIZE )
if ( with-optimize )
if ( with-optimize STREQUAL "ON" )
set( with-optimize "-O2" )
endif ()
foreach ( flag ${with-optimize} )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}" PARENT_SCOPE )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" PARENT_SCOPE )
endforeach ()
endif ()
endfunction()
To Reproduce Running cmake shows that the described behavior is inconsistent with the actual behavior.
Expected behavior
Described and actual behavior should match. In my understanding -Dwith-optimize=ON
should be -O3
and -Dwith-optimize=OFF
should be -O2
.
I think with-optimize=OFF
should to that, i.e., turn off all optimization, i.e., -O0
. The question then is if ON
should yield -O2
or -O3
. I am not sure why we did not use -O3
so far—maybe check compile times and resulting performance. Users can always give their own choice explicitly if they want. Documentation must obviously be updated.
Issue automatically marked stale!
Issue automatically marked stale!
Solved with #2432.