Skip to content

Commit 59ea363

Browse files
committed
Set -ffp-contract=off to aid cross-platform bit-reproducability
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. Change-Id: Id6f6eb08e6e3ed269281ed9c9e017159b760cae0
1 parent 25ceee7 commit 59ea363

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ 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 ( VVENC_FPP_CONTRACT_OFF )
28+
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
29+
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
30+
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffp-contract=off" )
31+
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffp-contract=off" )
32+
endif()
33+
endif()
34+
2635
detect_target_architecture( VVENC_TARGET_ARCH )
2736
if( VVENC_TARGET_ARCH MATCHES "ARM\|AARCH64" )
2837
set( VVENC_ARM_SIMD_DEFAULT TRUE )

0 commit comments

Comments
 (0)