0

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?

Auron
  • 13,626
  • 15
  • 47
  • 54
  • 1
    How is measuring FLOPS on arbitary code useful? – Jonas Elfström Jun 24 '10 at 11:04
  • @Jonas: it tells you how well you're utilizing the FPU units on your CPU. For computationally heavy programs, that can be a very good measurement of how much room there is for further optimization. – jalf Jun 24 '10 at 14:13
  • I'm benchmarking some algorithms, and I'm using FLOPS as a measure of the performance of these algorithms (comparing the performance achieved with the maximum FLOPS possible in the architecture I'm using). – Auron Jun 24 '10 at 14:39
  • The FLOPS number for your architecture was probably measured with LINPACK. I'm not at all sure that you really can compare an arbitary algorithm with LINPACK. – Jonas Elfström Jun 24 '10 at 14:47

3 Answers3

3

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
  • 59,039
  • 12
  • 119
  • 163
  • true, but note that he doesn't say he's running on x86 – jalf Jun 24 '10 at 14:12
  • 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 Jun 24 '10 at 14:40
2

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
  • 243,077
  • 51
  • 345
  • 550
1

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

Peter Tillemans
  • 34,983
  • 11
  • 83
  • 114