From 0f596948fcc0d3c184b20929bcf661558b64cc84 Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Wed, 10 Jan 2024 12:34:50 -0800 Subject: [PATCH 1/2] Adding `-ffp-contract=off` flag. This is needed for floating point stability. The global placement depends on the output of the FFT library. Without `-ffp-contract=off` the current FFT library produces different results dependent on if the compiler is targeting an x86 architecture which has the "FMA instruction". The FMA instruction omits the rounding done in the multiplication instruction, making the calculations produce different results for some input values See https://kristerw.github.io/2021/11/09/fp-contract/ See also OpenROAD change @ https://github.com/The-OpenROAD-Project/OpenROAD/pull/4518 Signed-off-by: Tim 'mithro' Ansell --- dependency_support/org_theopenroadproject/build_helper.bzl | 1 + 1 file changed, 1 insertion(+) diff --git a/dependency_support/org_theopenroadproject/build_helper.bzl b/dependency_support/org_theopenroadproject/build_helper.bzl index 6756f802..a3b04e8f 100644 --- a/dependency_support/org_theopenroadproject/build_helper.bzl +++ b/dependency_support/org_theopenroadproject/build_helper.bzl @@ -92,6 +92,7 @@ OPENROAD_BINARY_SRCS = OPENROAD_BINARY_SRCS_WITHOUT_MAIN + [ OPENROAD_COPTS = [ "-fexceptions", + "-ffp-contract=off", # Needed for floating point stability. "-Wno-error", "-Wall", "-Wextra", From b8dfdac3d83ee2843e59f2becb6b1edc13a61167 Mon Sep 17 00:00:00 2001 From: Tim Ansell Date: Wed, 10 Jan 2024 13:24:44 -0800 Subject: [PATCH 2/2] Add `-ffp-contract=off` to `.bazelrc`. This is needed for floating point stability. The global placement depends on the output of the FFT library. Without `-ffp-contract=off` the current FFT library produces different results dependent on if the compiler is targeting an x86 architecture which has the "FMA instruction". The FMA instruction omits the rounding done in the multiplication instruction, making the calculations produce different results for some input values See https://kristerw.github.io/2021/11/09/fp-contract/ See also OpenROAD change @ https://github.com/The-OpenROAD-Project/OpenROAD/pull/4518 Signed-off-by: Tim Ansell --- .bazelrc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bazelrc b/.bazelrc index c8db7472..08fdc124 100644 --- a/.bazelrc +++ b/.bazelrc @@ -13,7 +13,9 @@ # limitations under the License. build --cxxopt "-std=c++17" +build --cxxopt "-ffp-contract=off" build --host_cxxopt "-std=c++17" +build --host_cxxopt "-ffp-contract=off" build --crosstool_top=@llvm_toolchain//:toolchain build:ciremotebuild --crosstool_top=@llvm_toolchain//:toolchain