Re: How to compare two algorithms in MATLAB



yep, I know why flops function is obsolete. However If I really want
to compare two algorithms, can I use the following process?

1. Program them in a Compiled Language like Fortran, C++,....
2. Run the program on same machine
3. Compare the CPU time they take and the memory they need .

Or is there better practical method?

Sam

On 3月31日, 下午6时54分, "John D'Errico" <woodch...@xxxxxxxxxxxxxxxx> wrote:
Konstantinos Konstantinidis wrote:

I think the fellow means if you can do it automatically in Matlab.
I
actually had the same problem since R12 so i had to do everything
by hand.
Is there actually some way to count operations in Matlab? I found a
program
that counts flops but that is outside matlab and surely conciders
some
background programs and windows as well, so it is not objective.
Flops was really nice...

All would be good if flops actually
was correct. It is no longer applicable.
Its not just that they capriciously
decided to make your life miserable.

For example, do you KNOW how many
flops are involved in a single
matrix multiply? Do you KNOW it?
Are you sure? Try out the following
code. While it is executing, do NOT
even touch your mouse. If you have a
fast computer, allow N to go a little
larger.

figure
N = (5:250)';
t = zeros(length(N),2);
M = 20;
for i = 1:length(N)
A = rand(N(i));
B = rand(N(i));
for L = 1:2
tic;
for j = 1:M
C = A*B;
end
t(i,L) = toc;
end
end
loglog(N,t,'-o')
grid on

Note that the plot produced should
be linear. There should not be any
repeatable dips, bumps, jiggles. Yet
there will be exactly that.

These intriguing artifacts will be
repeatable. Note that there are two
curves plotted. If you run it again,
the same bumps appear. There are even
dips, where increasing the size of the
matrices causes a significant decrease
in the time required.

Worse, this behavior will vary depending
on what cpu you have, how much ram you
have, how large are the various caches
your cpu has, etc. I can't even imagine
what effect a multi-threaded blas call
does to this mess.

This behavior cannot be predicted by
the simple O(N^3) theoretical number
for the flops count.

THERE IS A REASON WHY THEY DROPPED
FLOPS.

John


.



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: SuSE 10.0 boot problems with CPU changed
    ... stock performance of better hardware but really need the FLOPS. ... come in cheap - and build your own Beowulf cluster. ... overclocked Intel D 805 CPU. ... People have managed to overclock this monster to 2x4.0GHz, ...
    (comp.os.linux.misc)