c++ - Calculating GFlops -
i'm wondering how calculate gflops program of mine like, let's say, cuda application.
do need measure execution time , number of floating point operations in code? if had operation "logf", count 1 flop?
the number of actual floating point operations depend on how code written (compilers can optimize in both directions - is, merging common operatoions c = (a * 4.0 + b * 4.0);
can becomes c = (a + b) * 4.0
, 1 less wrote. compiler can convert more operations:
c = / b;
may turn into:
temp = 1 / b; c = temp * a;
(this because 1/x "simpler" y/x, , multiplication faster division).
as mentioned in comments, floating point operations (log, sin, cos, etc) take more one, more ten, operations result.
another factor take account "loads" , "stores". these can quite hard predict, highly dependant on compilers code generation, number of registers available compiler @ given point, etc, etc. whether loads , stores count or not depends on how @ things, count towards total execution time. if there lot of data work through, each step simple (e.g. c = + b
a
, b
, c
vectors), time fetch data memory longer execution time of add
. on other hand, c = log(a) + log(b);
"hide" time load , store results, because log
takes lot longer load or store operations.