Skip to content

Commit aa1127d

Browse files
committed
Set -ffp-contract=off to aid cross-platform bit-reproducibility
Currently when running VVenC on Arm machines, the md5sum of the output video differs from x86 even when specifying `--SIMD=SCALAR`. This is due to the default `-ffp-contract` setting on GCC and LLVM enabling fused multiply-add instructions for floating-point arithmetic, which causes small bit differences due to the lack of intermediate rounding in these instructions. Setting `-ffp-contract=off` disables this behaviour, ensuring the md5sum output for the tested video now matches for `--SIMD=SCALAR`. There are some remaining differences when other SIMD settings are used on Arm which will be resolved in a separate PR.
1 parent 5c2b2cb commit aa1127d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ message( STATUS "CMAKE_MODULE_PATH: updating module path to: ${CMAKE_MODULE_PATH
2323

2424
include( vvencCompilerSupport )
2525

26+
# Avoid non-portable fp contractions leading to cross-platform bit-differences.
27+
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
28+
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
29+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off" )
30+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off" )
31+
endif()
32+
2633
detect_target_architecture( VVENC_TARGET_ARCH )
2734
if( VVENC_TARGET_ARCH MATCHES "ARM\|AARCH64" )
2835
set( VVENC_ARM_SIMD_DEFAULT TRUE )

0 commit comments

Comments
 (0)