Re: flop counter




Pietro schreef:

Richard Maine ha scritto:

Pietro <nvidiaus@xxxxxxxxx> wrote:

is there any free routine that counts flop in a fortran program run?

I don't off-hand know. Might be, but I'm posting to give one caveat...

I haven't seen much about flops "recently" (in the last decade or so). I
believe that most of the reason is that flops just aren't very relevant
to today's machines. It used to be that flops were at least a half
reasonable unit of computational cost; they were never a great one, but
were at least half reasonable. Flops per second was a widely cited unit
of speed, and minimizing flops was a goal for algorithm efficiency.

However, flops just are so poor a measure today that they aren't much
used any more... or at least if they are used, they manage to escape
much attention. Floatting point operations just aren't usually the
performance determiner. Things like memory bandwidth tend to be a much
bigger issue, even for number-crunching codes.

So if that's why you want to count flops, be aware that they probably
aren't very good for the purpose today.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain

well, if your point is "a flop now takes so few time compared to moving
data between cpu and ram so it's not so interesting to measure
performance by counting flop" then i agree.
but my aim is at comparing theoretical flop number of certain
algorithms with the real one used in MY implementatoin of those
algorithms just to know if i'm doing extra-non-ncessary work.

If that is your aim, then you might do something like the following:

module flop_counting
integer, save :: count_multiplications = 0
integer, save :: count_divisions = 0
...

type flop
real :: value
end type

interface operator(*)
module procedure mult
end interface
...
contains
function mult( x, y ) result(r)
type(flop), intent(in) :: x, y
type(flop) :: r

r%value = x%value * y%value
count_multiplications = count_multiplications + 1

end function mult

...
end module

program test
type(flop) :: x, y
integer :: i

x%value = 1.0; y = x
do i = 1,10
x = x * y
enddo

wrtite(*,*) 'Counted multiplications:', count_multiplications

end program

It will take some repetitive code (all arithmetic operations for
scalars,
for one-dimensional arrays, for two-dimensional ones etc (*)) depending
on what your algorithms are exactly, but it will be completely portable

(*) I have not checked, but I do not think you can use elemental
functions here - because of the update of a "global" variable.

Regards,

Arjen

.



Relevant Pages

  • Need to compare optimization algorithms
    ... and i want to compare it to matlabs fminsearch which is ... But how can i count FLOPS? ... So how in the world do i count flops to compare my algorithms then?? ...
    (comp.soft-sys.matlab)
  • Re: flop counter
    ... I haven't seen much about flops "recently". ... believe that most of the reason is that flops just aren't very relevant ... but my aim is at comparing theoretical flop number of certain ... algorithms just to know if i'm doing extra-non-ncessary work. ...
    (comp.lang.fortran)
  • what way to use instead of the obsolete flops function.
    ... I hear that MATLAB's flops is not available any more in some recent ... In case I want to compare the speed of two algorithms ... written in MATLAB, what benchmark is acceptable for this task now? ...
    (comp.soft-sys.matlab)
  • Re: AK discussion hand - part 1
    ... TAG, I'm reluctant to fold. ... Flatting here is setting myself up to give up on many flops, ... some reason I felt he wasn't folding pre-flop here. ...
    (rec.gambling.poker)
  • Re: continuation bets
    ... good a reason to enter a pot with garbage. ... a lot of flops, but when it flops big here it will win big. ... playing it for it's high card value (though there is a little bit, ...
    (rec.gambling.poker)