Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding -ffp-contract=off flag. #266

Merged
merged 2 commits into from
Jan 11, 2024
Merged

Adding -ffp-contract=off flag. #266

merged 2 commits into from
Jan 11, 2024

Conversation

mithro
Copy link
Member

@mithro mithro commented Jan 10, 2024

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 @
The-OpenROAD-Project/OpenROAD#4518

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 @
The-OpenROAD-Project/OpenROAD#4518

Signed-off-by: Tim 'mithro' Ansell <tansell@google.com>
@mithro mithro requested a review from QuantamHD January 10, 2024 20:37
@QuantamHD
Copy link
Collaborator

Should this go in the bazelrc as a global option as well?

@mithro
Copy link
Member Author

mithro commented Jan 10, 2024

Should this go in the bazelrc as a global option as well?

Potentially, I don't know how that works?

@QuantamHD
Copy link
Collaborator

You can add flags to the bazel command line by default so --copt="-ffp-contract=off".

https://github.com/hdl/bazel_rules_hdl/blob/main/.bazelrc#L17

So something like build --copt="-ffp-contract=off"

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 @
The-OpenROAD-Project/OpenROAD#4518

Signed-off-by: Tim Ansell <tansell@google.com>
@mithro
Copy link
Member Author

mithro commented Jan 10, 2024

You can add flags to the bazel command line by default so --copt="-ffp-contract=off".

https://github.com/hdl/bazel_rules_hdl/blob/main/.bazelrc#L17

So something like build --copt="-ffp-contract=off"

Like this -> https://github.com/hdl/bazel_rules_hdl/pull/266/files#diff-544556920c45b42cbfe40159b082ce8af6bd929e492d076769226265f215832fR16 ?

@QuantamHD
Copy link
Collaborator

Looks good!

@mithro mithro merged commit f760335 into hdl:main Jan 11, 2024
4 checks passed
@mithro mithro deleted the or-fp-contract branch January 11, 2024 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants