3

I'd like to calculate the computational intensity of my code, but it works with integers, not floats. I thought about counting the number of operations with PAPI, but the hardware doesn't provide counters for integer operations. How can I do this?

AstroCB
  • 12,337
  • 20
  • 57
  • 73
a3mlord
  • 1,060
  • 6
  • 16
  • How about just counting all instructions? E.g. callgrind can do this. – John Zwinck Sep 08 '14 at 03:17
  • Unfortunately, that counts many more instructions that we need. We want to calculate actual arithmetic operations, while that will count other types of instructions as well. – a3mlord Sep 08 '14 at 08:56

1 Answers1

-1

Valgrind's Lackey tool will give you ALU operation counts if you specify --detailed-counts=yes: http://valgrind.org/docs/manual/lk-manual.html

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • I think that operations such as pre-fetching (which I do NOT want to count) are also counted, no? – a3mlord Sep 08 '14 at 19:31
  • How can I know if it works, looking at the output?! The only thing I can do is try it on a very small code whose no. of operations I know. – a3mlord Sep 09 '14 at 12:24
  • Perfect, then do that! – John Zwinck Sep 09 '14 at 12:26
  • It doesn't work... SIZE = 500.000 for(i = 0; i < SIZE; i++) { x[i] = i * 2; } data type of x: int; result: AluOps = 3,225,684 – a3mlord Sep 09 '14 at 20:40
  • You know `x[i]` means `*(x + i)` right? There are various hidden ALU operations, you will never get a simple "How many times did I add two numbers using the + operator?" – John Zwinck Sep 09 '14 at 23:43
  • Right. However, and in short, I can't distinguish between "my" operations and "control" operations. That means that I can't estimate the computational intensity of the code, at least following this approach... – a3mlord Sep 10 '14 at 10:14