nest-simulator icon indicating copy to clipboard operation
nest-simulator copied to clipboard

Described and actual behavior of -Dwith-optimize don't match

Open jarsi opened this issue 2 years ago • 2 comments

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.

jarsi avatar Mar 11 '22 10:03 jarsi

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.

heplesser avatar Mar 11 '22 11:03 heplesser

Issue automatically marked stale!

github-actions[bot] avatar May 22 '22 08:05 github-actions[bot]

Issue automatically marked stale!

github-actions[bot] avatar Sep 13 '22 08:09 github-actions[bot]

Solved with #2432.

steffengraber avatar Sep 13 '22 09:09 steffengraber