This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Set default FP_CONTRACT to ON
AbandonedPublic

Authored by dfukalov on Jun 26 2020, 5:51 AM.

Details

Summary

With the FAST default FP_CONTRACT mode' setting for
func(float a, float b, float c) { return a + b * c; } FE generates pair
fmul contract + fadd contract that are fused to an fma operation in BE.

But OpenCL fuses these in FE. This approach seems more effective since avoids a
probabilty that these instructions are not fused in BE. Default setting can be
overridden with #pragma STDC FP_CONTRACT by a programmer.

Diff Detail

Event Timeline

dfukalov created this revision.Jun 26 2020, 5:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2020, 5:51 AM
yaxunl added a reviewer: tra.Jun 26 2020, 6:09 AM

I think the point of -ffp-contract=fast is that it allows emitting fma across statements if there are such opportunities whereas -ffp-contract=on only allows fma in one statement

https://llvm.org/docs/CompileCudaWithLLVM.html#flags-that-control-numerical-code

dfukalov planned changes to this revision.Jun 26 2020, 7:34 AM

I think the point of -ffp-contract=fast is that it allows emitting fma across statements if there are such opportunities whereas -ffp-contract=on only allows fma in one statement

https://llvm.org/docs/CompileCudaWithLLVM.html#flags-that-control-numerical-code

Yes, you're right. I was confused by current FE behavior and a number of different commits, reverts and re-commits.

Currently FE checks allowFPContractWithinStatement() and it returns false for FAST mode. As I understand, FAST mode should be more aggressive and include this case.
I'll re-work the change.

dfukalov abandoned this revision.Jun 28 2020, 3:13 AM

I was completely wrong