473,883 Members | 2,069 Online

# Calculating MFLOPS

Hi,

Can someone tell me how to calculate MFLOPS for the following C# code
(on a Pentium 4 2.0 Ghz)?

for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
for (k=0; k<n; k++)
{
C[i,j] = C[i,j] + A[i,k] * B[k,j];
}
}
}

Thanks!

Miller

Nov 15 '05 #1
3 5350
What's the point of calculating MFLOPS? What does it show us when
normally we can't get the maximum amount of floating point operations,
as we should. What can we normally tell with such a measure? I'm sure
two different compilers (doing different things) would give separate
results... so can we then predict how good or bad one is from the other?

Thanks

James

Anders Forsgren wrote:
If the process takes a fair amount of time, you can use the tick count or
current time to measure the time for completion. i.e. The number of
operations is
2*n^3 then divide by one million times the number of seconds to get the
approximate MFLOP count. Your processor model and clock really only matters
if you assume the thread is the only thread executing, which is not that
likely.

System.DateTime start = System.DateTime .Now;

for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
for (k=0; k<n; k++)
{
C[i,j] = C[i,j] + A[i,k] * B[k,j];
}
}
}

System.DateTime end = System.DateTime .Now;

double dt = now.Subtract(st art).TotalSecon ds;

double mflops = (2*n*n*n) / (1e6 *dt);

System.Diagnost ics.Debug.Write Line("Time : "+dt+" seconds, MFLOPS:
"+mflops);

Note however that this needs the time dt to be fairly long (i.e. n needs to
be fairly large).

/A

Nov 15 '05 #2

"James" <sn****@jamison .snort> wrote in message
news:3f******** @clarion.carno. net.au...
What's the point of calculating MFLOPS? What does it show us when
normally we can't get the maximum amount of floating point operations,
as we should. What can we normally tell with such a measure? I'm sure
two different compilers (doing different things) would give separate
results... so can we then predict how good or bad one is from the other?

The MegaFLOP (million floating point operations per second) is an old
measure of supercomputer performance, dating from the days when
supercomputers ran at 50 MHz.

Many operating systems let you measure the CPU time of an individual thread.
That's how it was normally done, although I occasionally saw MFLOP ratings
based on "wall clock time" instead. In that case you'd do your best to keep
other threads from running during the test.
Nov 15 '05 #3

"Michael A. Covington" <Mi*****@Coving tonInnovations. com> wrote in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..

"James" <sn****@jamison .snort> wrote in message
news:3f******** @clarion.carno. net.au...
What's the point of calculating MFLOPS? What does it show us when
normally we can't get the maximum amount of floating point operations, as we should. What can we normally tell with such a measure? I'm sure two different compilers (doing different things) would give separate
results... so can we then predict how good or bad one is from the
other?
The MegaFLOP (million floating point operations per second) is an old
measure of supercomputer performance, dating from the days when
supercomputers ran at 50 MHz.

Or you're desperately trying to sell Apple computers, in which
case you might as well claim it goes "1,000,000 MPH"

:)

-c
Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.