Skip to content

Commit d38bf36

Browse files
committed
Change default to JIT without fma (AcademySoftwareFoundation#2076)
The ShadingSystem option "llvm_jit_fma" seems to advertise that it switches between no fused multiply-add (the default, 0), versus allowing fma to be generated in the JIT. The underlying LLVM option is actually a 3-way switch about how to utilized fused ops: Strict (no fused ops), Standard (allow fma but not other fused ops), or Fast (allow other fused ops when it will speed things up). Aside: "standard" is really confusing, as one might think it means original standard IEEE 754 definitions that lacked fma. These are not the same! We were using llvm_jit_fma to switch between Standard and Fast, but upon closer examination, we now believe that it should control a switch between Strict and Standard, and Strict should be the default. This seems to directly change the pesky render-microfacet test, which has always seemed to have an unusual sensitivity to the specific processor. Hopefully, users will find that across the board, it leads to their renderers having fewer minor pixel differences from one platform to another. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 367867f commit d38bf36

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/liboslexec/llvm_util.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,9 +1529,15 @@ LLVM_Util::make_jit_execengine(std::string* err, TargetISA requestedISA,
15291529

15301530
llvm::TargetOptions options;
15311531
// Enables FMA's in IR generation.
1532-
// However cpu feature set may or may not support FMA's independently
1533-
options.AllowFPOpFusion = jit_fma() ? llvm::FPOpFusion::Fast
1534-
: llvm::FPOpFusion::Standard;
1532+
// However cpu feature set may or may not support FMA's independently.
1533+
// Note: This is confusingly named, LLVM's FPOpFution choices are Strict
1534+
// (no fma used), Standard (fma used for actual fma circumstances), and
1535+
// Fast (fused ops beyond just fma's, any time it thinks it will be
1536+
// faster). Since we call the option "jit_fma", we interpret that as
1537+
// switching between Strict and Standard. We will need some other control
1538+
// if we ever want full "Fast" mode.
1539+
options.AllowFPOpFusion = jit_fma() ? llvm::FPOpFusion::Standard
1540+
: llvm::FPOpFusion::Strict;
15351541
// Unfortunately enabling UnsafeFPMath allows reciprocals, which we don't want for divides
15361542
// To match results for existing unit tests we might need to disable UnsafeFPMath
15371543
// TODO: investigate if reciprocals can be disabled by other means.
316 KB
Binary file not shown.

0 commit comments

Comments
 (0)