Does the arithmetic negate count as a floating point operation?
I'm currently measuring the performance of some code in FLOPS. This code presents some arithmetic negate instructions like this one:
d = -a
where d
and a
are floating point variables. The architecture I'm currently using does have specific n开发者_开发百科egate instructions. Should I have to take into account this kind of operations to measure FLOPS? What kind of operations account for FLOPS? Is there a convention or anything?
As @Andrey said, to be sure you should check the disassembled code.
But in general, yes, the instruction would likely execute on a FPU. It simply flips a bit, so it could be done on an integer unit as well, but since you're operating on floating point values, these are most likely already loaded into FP registers, and so there'd be a fair amount of overhead to moving them to general purpose registers, flipping the bit and moving them back.
I don't know if there is a complete universal guide to "what should be counted as a FLOP", but this is most likely an instruction which executes on a FPU, and so it is competing with other FP instructions for resources on the CPU, so yes, I would include it in a FLOPS count.
try to disassemble the code and check how this operation is performed.
if it uses instruction FCHS
(Change sign) then you can consider it floating point operation.
MSVC (Visual Studio 2008)
double c = -b;
00971397 fld qword ptr [b]
0097139A fchs
0097139C fstp qword ptr [c]
fchs - see that?
There is a kind of convention to calculate the FLOPS using LINPACK as a kind of standard benchmark.
精彩评论