views:

38

answers:

3

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 negate 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?

+2  A: 

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?

Andrey
true, but note that he doesn't say he's running on x86
jalf
Yes, I know for sure there is a negate assembly instruction in the architecture the I'm using, I've already done that, thank you.
Auron
+1  A: 

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.

jalf
+1  A: 

There is a kind of convention to calculate the FLOPS using LINPACK as a kind of standard benchmark.

Peter Tillemans