【发布时间】:2012-08-14 06:01:59
【问题描述】:
来自 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,因为这是默认设置。
【问题讨论】:
-
使用 FMA 可能会稍微增加寄存器压力,因为三个源操作数必须同时可用。因此打开/关闭 FMA 生成会导致指令调度和寄存器分配的微小差异,进而导致性能差异很小。对于具有许多乘加习语的计算密集型内核,-fmad=true 应该会产生显着的性能差异,但是正如您所说,您的内核由乘法控制,因此从使用 FMA 中受益甚少,任何收益都可能是寄存器压力/指令调度方面的偏移量。
-
很好,非常感谢您的确认
-
@njuffa,您能发表您的评论作为答案吗?