来自Nvidia发行说明:
The nvcc compiler switch, --fmad (short name: -fmad), to control the contraction of
floating-point multiplies and add/subtracts into floating-point multiply-add
operations (FMAD, FFMA, or DFMA) has been added:
--fmad=true and --fmad=false enables and disables the contraction respectively.
This switch is supported only when the --gpu-architecture option is set with
compute_20, sm_20, or higher. For other architecture classes, the contraction is
always enabled.
The --use_fast_math option implies --fmad=true, and enables the contraction.
我有两个内核 - 一个是纯粹的计算绑定,有很多乘法,而另一个是内存绑定。当我执行-fmad=false
时,我注意到我的计算密集型内核的性能持续改善(大约5%)...当我为内存绑定内核关闭它时,性能下降大致相同。
所以,FMA对我的内存绑定内核工作得更好,但我的计算绑定内核可以通过关闭它来挤出一点性能。
可能是什么原因?
我的设备是M2090,我使用的是CUDA 4.2。
完整的编译选项:
-arch,sm_20,-ftz=true,-prec-div=false,-prec-sqrt=false,-use_fast_math,-fmad=false
(或者我只删除了fmad=false
,因为无论如何这都是默认值。
答案 0 :(得分:7)
使用FMA可能会略微增加套准压力,因为三个源操作数必须同时可用。因此,开启/关闭FMA生成可能会导致指令调度和寄存器分配方面的细微差别,从而导致性能差异小。对于具有许多乘法加法惯用语的计算绑定内核,-fmad = true应该会产生显着的性能差异,但正如您所说,您的内核由乘法控制,因此使用FMA几乎不会受益,并且任何增益都可能是由寄存器压力/指令调度方面抵消