Skip to content
Permalink
Browse files

No longer use ffast-math (#2960)

Summary:
Regardless of whether we are compiling a model in Release or Debug mode, we should try to generate the same binary. Prior to this PR, for example the GraphOptimizer may have quantized a Constant Tensor payload slightly differently due to `ffast-math` when in Release vs. Debug.
Pull Request resolved: #2960

Test Plan: All tests pass.

Differential Revision: D15473529

Pulled By: jfix71

fbshipit-source-id: a1b21cb50d347de4ee0920f94135aad9b63b051d
  • Loading branch information
jfix71 authored and facebook-github-bot committed Dec 5, 2019
1 parent 007f8ba commit 285071494330734cc28d079769325800d33ff747
Showing with 5 additions and 10 deletions.
  1. +5 −10 cmake/modules/GlowDefaults.cmake
@@ -37,20 +37,15 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wnon-virtual-dtor -fno-exceptions -fno-rtti")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -O0")
set(FAST_MATH_FLAGS "-ffast-math -fno-finite-math-only")
CHECK_CXX_COMPILER_FLAG("-Wno-psabi" HAS_W_NO_PSABI)
if(HAS_W_NO_PSABI)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
endif()
if((CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7)
AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${FAST_MATH_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${FAST_MATH_FLAGS}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${FAST_MATH_FLAGS}")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native ${FAST_MATH_FLAGS}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -march=native ${FAST_MATH_FLAGS}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -march=native ${FAST_MATH_FLAGS}")
if(NOT ((CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR CMAKE_SYSTEM_PROCESSOR STREQUAL armv7)
AND CMAKE_CXX_COMPILER_ID STREQUAL Clang))
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -march=native")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -march=native")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -march=native")
endif()
endif()

0 comments on commit 2850714

Please sign in to comment.
You can’t perform that action at this time.