Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MATLAB vs. Fortran performance

1,095 views
Skip to first unread message

pred...@bellatlantic.net

unread,
Apr 28, 2001, 11:39:39 AM4/28/01
to
I am investigating the relative performance level of Fortran versus
other languages, such as MATLAB, but am confused by execution times for
the following programs:

Fortran (execution time: approx. 15 seconds):
program test

REAL a(500,500), b(500,500), c(500,500)

call RANDOM_NUMBER(a)
call RANDOM_NUMBER(b)

do i=1,10
c = MATMUL(a,b)
END do

stop
end program


MATLAB (execution time: approx. 3.7 seconds):
tic
A = rand(500);
B = rand(500);
C = zeros(500);
for i = 1:10,
C = A * B;
end
toc

Technical details: MATLAB is version 6. Both languages are being run
on the same machine, a Falcon Northwest computer running an AMD Athlon
at 800 MHz, with 512 MB RAM (PC133) under Windows Me.

Due to my inexperience with Fortran and this particular Fortran
compiler, I realize that I (very likely) may not be using the Fortran
language or the compiler to best advantage. I also fully appreciate
that the above simple matrix multiplication loop is no comprehensive
test of these two language systems. Still, I was wondering what the
general experience has been in this regard. Any thoughts? Are there
real-world computations for which interpreted MATLAB is more-or-less as
fast as other languages, like Fortran?

Will Dwinnell
pred...@dwinnell.com

Jason Bowman

unread,
Apr 28, 2001, 12:13:32 PM4/28/01
to
I wouldn't think there would be that much difference, but Matlab 6
uses LAPACK and a machine specific BLAS. In this particular example,
the Matlab data is probably being sent to a block algorithm, and by
block I mean that the algorithms are written to operate on multiple
columns/rows at once. This is about the extent of my knowledge on
BLAS and LAPACK, so I can't be of more help.

Matlab is generally fast when doing vector math, but if you depend
heavily on loops you'll wonder if your computer reverted back
to a 486. For 10 loops, it shouldn't be a big deal, but when you
start getting into loops with 10,000 iterations like I do it
makes a big difference. Stay away from long loops and Matlab will
for the most part hold its own. However, I'm running commercial
software on an old SGI (at least 4 years old) and the equivalent
Matlab code heavily optimized runs noticably slower on a P3 800MHz
with RAMBUS. They say that the builtin functions can't be beat,
but that's where my large code gets bogged down. So I'm
contemplating writing that portion in C or Fortran and then mexing
it. Fortran is usually very fast, and there are tricks in C that
may allow you to speed up your code.

Jason

Ken Plotkin

unread,
Apr 28, 2001, 12:13:49 PM4/28/01
to
On Sat, 28 Apr 2001 15:39:39 GMT, pred...@bellatlantic.net wrote:

[snip]


>Fortran (execution time: approx. 15 seconds):
>program test
>
>REAL a(500,500), b(500,500), c(500,500)

[snip]

>MATLAB (execution time: approx. 3.7 seconds):
>tic
>A = rand(500);
>B = rand(500);
>C = zeros(500);
>for i = 1:10,

[snip]

The arrays in your Fortran program are 500 times the size of those in
your Matlab program.

Normalizing by that size, the Fortran program is 123 times as fast.

Ken Plotkin

Ulrich Elsner

unread,
Apr 28, 2001, 12:21:12 PM4/28/01
to
According to <pred...@bellatlantic.net>:

>I am investigating the relative performance level of Fortran versus
>other languages, such as MATLAB, but am confused by execution times for
>the following programs: [...]
>
>Fortran (execution time: approx. 15 seconds): [...]

>do i=1,10
> c = MATMUL(a,b)
>END do
> [...]
>MATLAB (execution time: approx. 3.7 seconds): [...]

>for i = 1:10,
> C = A * B;
>end

>Technical details: MATLAB is version 6. Both languages are being run
>on the same machine, a Falcon Northwest computer running an AMD Athlon
>at 800 MHz, with 512 MB RAM (PC133) under Windows Me.

The main question is: what MATMUL do you use. For matrix multiplication,
Matlab 6 uses the highly optimized ALTAS libraries (see
http://www.netlib.org/atlas/ ). If MATMULT is just any old matrix matrix
multiplication (or even some non-optimized BLAS routines), this will
easily explain the difference. On my machine, ATLAS is about 10 times
faster than the (best) simple three-loop version.

You have to realize that in your example almost all of the work is done
in the matrix-matrix multiplications. The rest of the code contributes a
negligible amount to the runtime. Hence the fact that Matlab is
interpreted is of no consequence.

>Are there real-world computations for which interpreted MATLAB is
>more-or-less as fast as other languages, like Fortran?

This really depends on your type of code. If most of the work is done
in Matlab's 'build in' matrix or vector routines, the code will be
nearly as fast as even highly optimized FORTRAN code. If , on the other
hand, your code requires operations that can not be vectorized (in the
Matlab sense) Fortran code can easily be tens (if not hundreds) of times
faster.

You can interface Fortran (or C) code to Matlab to speed up time critical
sections, but that adds another level of complexity.

Development time is likely to be faster in an Matlab, but that really depends
on many factors like available libraries, personal preferences, ...


Hope that helps,


Ulrich Elsner


Ulrich Elsner

unread,
Apr 28, 2001, 12:24:08 PM4/28/01
to
According to Ken Plotkin <kplo...@nospam.net>:
>[snip]

>>REAL a(500,500), b(500,500), c(500,500)
>[snip]
>>A = rand(500);
>>B = rand(500);
>>C = zeros(500);

>The arrays in your Fortran program are 500 times the size of those in
>your Matlab program.

No, they are both 500*500 matrices. Im matlab, these are doubles, in
Fortran shouldn't that be REAL*8 ? (It's been a long time).

Ulrich

E. Robert Tisdale

unread,
Apr 28, 2001, 11:25:54 AM4/28/01
to
pred...@bellatlantic.net wrote:

> I am investigating the relative performance level
> of Fortran versus other languages, such as MATLAB,
> but am confused by execution times for the following programs:
>
> Fortran (execution time: approx. 15 seconds):
>
> program test
>
> REAL a(500,500), b(500,500), c(500,500)
>
> call RANDOM_NUMBER(a)
> call RANDOM_NUMBER(b)
>
> do i = 1, 10
> c = MATMUL(a, b)
> END do
>
> stop
> end program
>
> MATLAB (execution time: approx. 3.7 seconds):
>
> tic
> A = rand(500);
> B = rand(500);
> C = zeros(500);
> for i = 1:10,
> C = A*B;
> end
> toc
>
> Technical details: MATLAB is version 6.

Which Fortran?

> Both languages are being run on the same machine,
> a Falcon Northwest computer running an AMD Athlon
> at 800 MHz, with 512 MB RAM (PC133) under Windows Me.
>
> Due to my inexperience with Fortran
> and this particular Fortran compiler,

Which compiler?

> I realize that I (very likely) may not be using
> the Fortran language or the compiler to best advantage.
> I also fully appreciate that the above simple matrix multiplication loop
> is no comprehensive test of these two language systems.
> Still, I was wondering what the general experience has been in this regard.
> Any thoughts? Are there real-world computations
> for which interpreted MATLAB
> is more-or-less as fast as other languages, like Fortran?

Hi Will,

MATLAB calls a highly optimized routine for matrix-matrix multiplication.
I believe they use a DGEMM from the BLAS library
which is implemented in Fortran 77. MATMUL should be just as fast.
Check your compiler options and start looking for a different Fortran compiler
if you can't get it to run just as fast as MATLAB.
MATLAB is as good as any computer programming language
for high performance numerical computing
as long as you can work with large matrices.
But MATLAB doesn't deal well with loops
that access matrix elements one at a time.
Your MATLAB manual tells you how to call routines
from performance numerical libraries written in either C or Fortran.

James Giles

unread,
Apr 28, 2001, 1:16:59 PM4/28/01
to

<pred...@bellatlantic.net> wrote in message
news:3AEAE3AC...@bellatlantic.net...
...

> do i=1,10
> c = MATMUL(a,b)
> END do
...

> for i = 1:10,
> C = A * B;
> end

Others have already given some useful answers. There is
another possibility as well. In the above loops, the operands
to the only expressions are loop invariants. If one of the
processors discovers that and the other doesn't, the one that
does may only actually perform the loop once (since subsequent
trips through the loop merely duplicate the previous effort).
The Fortran may not notice this since the operands are being
passed to a procedure (though it's an intrinsic that the compiler
should know the properties of).

Also, the result of the calculation is never used anywhere.
So a really aggressive optimization (such as many Fortran's
should be capable of) might replace the whole program with
nothing at all. Since this isn't happening, I suspect the Fortran
you're using in not the best, or that you have optimizations
turned off.

Comparing languages for speed is a messy business. The
benchmark needs to be able to trick the optimizer into actually
doing the work without disabling those optimizations you
really want to test.

--
J. Giles


David Spurr

unread,
Apr 29, 2001, 12:32:09 AM4/29/01
to
In view of other comments (highly optimized ALTAS libraries), seems
like like MATLAB is probably faster for this specialised task. But
the point about compilers skipping unnecessary loops needs to be
checked, especially for MATLAB. Easily checked - try it with say 5 &
20 loops & compare the times taken (ie. 20 loops should take about 4
times the cpu time for 5 loops)

In my experience, CVF does not take this type of short cut, even at
highest (normal ?) optimising levels. Suggests that it not optimising
as well as it could, but does make it easier to get realistic time
estimates by testing dummy cases.

The time quoted in the original post is about right for CVF6.5A doing
10 loops (& about 10 x what you get if you do only 1 loop). I got
33.2 secs on a Celeron 500 with "off the shelf" level 4 optimisation
(3.3 secs for 1 loop).

On the other hand, Watcom 10.6 which I have used a lot previously,
would report near zero time for this example (if it could do Matmul
ops). Since the result is never used, there is not point in doing the
calcs. A PRINT following the loop will cause it to do the calc once
To get it to do the calc each loop, it would be necessary to make sure
different calcs are done every loop AND that the result for each loop
is used (either in following loops or written to file, etc).

Better optimising (which of course is the way it should be), but makes
it much harder to set up artificial timing tests.

David

Ron Shepard

unread,
Apr 29, 2001, 12:40:19 AM4/29/01
to
In article <9ceqr8$69b$2...@narses.hrz.tu-chemnitz.de>,
comp.soft-...@elsner.org (Ulrich Elsner) wrote:

I've never used Matlab, so what exactly does the statement "A=rand(500)"
do? Does it only fill the first 500 elements of A(:,:) with nonzero
values? If so, then it would be reasonable to expect the
matrix-multiply to be able to branch around some inner loops.

Also, what exactly does the Matlab statement "C=A*B" do. Is this an
element-by-element multiply, or a matrix-matrix product (as this
statement would be in fortran)?

$.02 -Ron Shepard

David Spurr

unread,
Apr 29, 2001, 1:02:42 AM4/29/01
to
I should have done this before posting, but I just repeated the runs
with the optimisation level set to 5 (highest), with no debugging (cf
min before) & no warnings. Time reduced to 12sec (loops) and 1.16
secs (1 loop), which suggests that the 15s in the original post can be
considerably improved on (expect more like 6 - 7 sec for an Athlon
800) ?

David

Nabeel

unread,
Apr 29, 2001, 3:01:01 AM4/29/01
to
Hi,

> I've never used Matlab, so what exactly does the statement "A=rand(500)"
> do?

rand(500) is a "shortcut" for rand(500,500). These commands create a
500x500 matrix of uniformly distributed random numbers.

> Also, what exactly does the Matlab statement "C=A*B" do. Is this an
> element-by-element multiply, or a matrix-matrix product (as this
> statement would be in fortran)?

"A*B" does matrix multiplication, in a "linear algebra" sense (ie, the
inner dimensions must match). "A.*B" does element-by-element
multiplication (ie, size(A)==size(B)).

-- Nabeel

David Spurr

unread,
Apr 29, 2001, 6:56:48 AM4/29/01
to
size(A)==size(B). This sounds like it is the same as c = a*b in
Fortran, ie. c11 = a11*b11; c12 = a12*b12, etc. This is a VERY much
faster operation (5.33 secs for 10,000 loops - Win98SE, Celeron 500
CVF 6.5A level 5 opt).- for this case, about 2000 times faster than
Matmul.

Matmul calculates the matrix-matrix product. A & B do not have to be
the same shape; eg. If matrix_a has shape (n, m) and matrix_b has
shape (m, k), the result is a rank-two array with shape (n, k).

David

David Frank

unread,
Apr 29, 2001, 7:07:54 AM4/29/01
to
some observations to get my 2 cents in..

1. CVF normally generates code for MATMUL inline (doesnt call a library
routine)..
whether this code is optimum is a timely topic that perhaps could be
discussed in
another topic here.. (use the /Fa switch to generate a test.asm
file)

2. Yesterday I posted results for TEST_FPU inverting 1000x1000
using its test#4's LAPACK +intel BLAS,
the error was .000000000xxxxxx this is getting close to NO-GO
results

3. If MATLAB uses LAPACK/BLAS one wonders what the MATLAB error is
dealing with 1000x1000 matrices ..

<pred...@bellatlantic.net> wrote in message
news:3AEAE3AC...@bellatlantic.net...

Dan Tex1

unread,
Apr 29, 2001, 2:45:56 PM4/29/01
to
Hmmmm. I've just read all the post for this one. Interesting. So...
I have performed a few quick test myself. I tested the code on
an Athlon 750 running Windows 98 with another program or two
loaded up in the background ( including AOL ).
Oh... Lahey LF95 5.6 was the fortran compiler used.

I ran the following versions of the code:

As posted with full optimization: just under 15 secs.

Replaced posted MATMUL with
simple Do loops and with full optimization: 0 seconds

Replaced posted MATMUL with
simple Do loops and NO optimization: 11.6 secs

Replaced posted MATMUL with
simple Do loops and full optimization
and added code to force the full
computation of c(). ie. I told the
program to print the results out after
the computation was performed: 2.6 secs ( not too shabby here )

Seems to me.... some fortran compiler optimizations are required
to make some of the "newer" functions such as MATMUL worth
using?

Dan :-)

James Giles

unread,
Apr 29, 2001, 4:32:00 PM4/29/01
to

"Dan Tex1" <dan...@aol.com> wrote in message
news:20010429144556...@ng-fq1.aol.com...
...

> Replaced posted MATMUL with
> simple Do loops and full optimization
> and added code to force the full
> computation of c(). ie. I told the
> program to print the results out after
> the computation was performed: 2.6 secs ( not too shabby here )
>
> Seems to me.... some fortran compiler optimizations are required
> to make some of the "newer" functions such as MATMUL worth
> using?

This may not be sufficient. You might have to make changes
to A and B between passes through the loop for the optimizer
to see that it needs to do 10 calculations of C instead of one.
And, you have to use each copy of C so the optimizer doesn't
notice that it need do only the last pass through the loop.

A different benchmark might be better.

--
J. Giles


David Spurr

unread,
Apr 29, 2001, 8:45:46 PM4/29/01
to
Easy to check; ie. do say 2 loops and 10 loops. Time difference will
confirm whether 10 calcs are being done in the latter case.

If not, then change to something like

do i=1,10
c = MATMUL(a,b)

a = a + c
end do
print *, c(1,1)

David

Tom Hoffend

unread,
Apr 30, 2001, 9:13:34 AM4/30/01
to
In comp.soft-sys.matlab pred...@bellatlantic.net wrote:
> I am investigating the relative performance level of Fortran versus
> other languages, such as MATLAB, but am confused by execution times for
> the following programs:

On an SGI R10000 (a few years old), I get about 8.66 seconds for a
FORTRAN code using the BLAS routine DGEMM to do the matrix multiplication
and the old fortran RAND (I know its not the best...) to generate the
random numbers. The timing really depends on the compiler options that
you pick. Here I used the level 3 optimization switch -O3, and also
-64, -R10000, and -mips4 switches.

On matlab 5 (which is about to go away since I just switched to PC; I
never did get around to installin matlab 6 on the SGI and now I never
will) I get 9.96 seconds. I have not yet tried comparing matlab 6 with
visual fortran on my PC. The result here is that FORTRAN and matlab 5
are pretty much the same.

It is true that for loops FORTRAN is much faster. For example, I have
one code that calculates a very complicated oscillating but positive
integral (and integral with many peaks, say more than 50) versus several
parameters in the integral, where the number and nature of the oscillations
changes with the parameters (in a known way which can be used to bust up
the integral into subpanels and do the adaptive quadrature on the subpanels).
In that case, the quadrature method is different for each set of parameter
values, and I find (this time on the PC) that visual FORTRAN using adaptive
quadrature routines from QUADPACK is very much faster than matlab 6 with
QUAD or QUADL with visual FORTRAN.

Best wishes,

TRH

--
Thomas R. Hoffend Jr., Ph.D. EMAIL: trho...@mmm.com
3M Company
Optical Markets and Technologies
Display Materials Technology Center
3M Center Bldg. 201-1C-18 My opinions are my own and not
St. Paul, MN 55144-1000 those of 3M Company.

Opinions expressed herein are my own and may not represent those of my employer.

David Spurr

unread,
Apr 30, 2001, 7:09:35 PM4/30/01
to
It is still not clear to me what C = A * B is in MATLAB; ie. does

C11 = A11*B11
C21 = A21*B21
.
Cij = Aij*Bij

etc, as per Fortran C = A * B
(A, B & C all being of the same shape)


Or does - for A(n,m) & B(m,k)

C11 = A11*B11 + A12*B21 + .... + A1m*Bm1
C21 = A21*B11 + A22*B21 + .... + A2m*Bm1
.
Cnk = An1*B1k + An2*B2k + .... + Anm*Bmk

as per Fortran C = MATMUL(A,B) ?

Anybody able to clarify ?

David

Ken Plotkin

unread,
Apr 30, 2001, 7:50:35 PM4/30/01
to
On Sun, 29 Apr 2001 03:01:01 -0400, Nabeel <nab...@mathworks.com>
wrote:


>rand(500) is a "shortcut" for rand(500,500). These commands create a
>500x500 matrix of uniformly distributed random numbers.

What would the command be to create a 500 element vector of random
numbers?

Michael Crump

unread,
Apr 30, 2001, 8:39:49 PM4/30/01
to
Ken

To create a 500 element vector of random numbers you would use
rand(500,1) % gives a 500 x 1 vector
rand(1,500) % gives a 1 x 500 vector
rand(500,500) % gives a 500 x 500 vector
rand(500) % shortcut for above 500 x 500 vector

David,
in matlab A = B*C does a matrix multiply (fortran matmul)
whilst A = B.*C (notice the dot) does an element by element multiplication
(fortran B*C)

hope this clarifies things
Mic


--
-------------
Michael Crump
Postgraduate Researcher / PhD Candidate
Sir Lawrence Wackett Centre for Aerospace Design Technology
Department of Aerospace Engineering
RMIT University
GPO Box 2476V
Melbourne, Vic 3001
AUSTRALIA

Ph: +61 3 9647 3089
Fax: +61 3 9647 3050


"Ken Plotkin" <kplo...@nospam.net> wrote in message
news:1huretsbk36i0n9gk...@4ax.com...

Gerry Thomas

unread,
Apr 30, 2001, 9:54:09 PM4/30/01
to
In Matlab, type

help mtimes.

Matlab's A*B is the same as Fortran's matmul.

--
Gerry T.

"David Spurr" <XX...@viaihug.co.nz> wrote in message
news:3aedea72....@news.wlg.ihug.co.nz...

Gerry Thomas

unread,
Apr 30, 2001, 10:00:22 PM4/30/01
to
"Ken Plotkin" <kplo...@nospam.net> wrote in message
news:1huretsbk36i0n9gk...@4ax.com...

Would you believe rand(500,1)? As Nabeel rand(n)=rand(n,n).

--
Gerry T.


Gerry Thomas

unread,
Apr 30, 2001, 10:25:42 PM4/30/01
to

"David Frank" <dave_...@hotmail.com> wrote in message
news:eCSG6.137755$o9.18...@typhoon.tampabay.rr.com...

> some observations to get my 2 cents in..
>
> 1. CVF normally generates code for MATMUL inline (doesnt call a
library
> routine)..
> whether this code is optimum is a timely topic that perhaps could
be
> discussed in
> another topic here.. (use the /Fa switch to generate a
test.asm
> file)
>
> 2. Yesterday I posted results for TEST_FPU inverting 1000x1000
> using its test#4's LAPACK +intel BLAS,
> the error was .000000000xxxxxx this is getting close to
NO-GO
> results
>
> 3. If MATLAB uses LAPACK/BLAS one wonders what the MATLAB error is
> dealing with 1000x1000 matrices ..
>
>

Matlab 6's lapack/blas.dll is a CVF-generated library. If you must,
Matlab has no problem inverting a 1000x1000 matrix.

--
Gerry T.


Duane Bozarth

unread,
May 1, 2001, 9:38:13 AM5/1/01
to
In Matlab, C = A * B is the <matrix> multiplication of A and B...A and B
must be conformant....(after all it is the MATrix LABoratory). C = A .*
B is the element product wherein A and B must be same size.

Jos Bergervoet

unread,
May 3, 2001, 4:22:49 PM5/3/01
to
In comp.lang.fortran Tom Hoffend <trho...@mmm.com> wrote:
> In comp.soft-sys.matlab pred...@bellatlantic.net wrote:
>> other languages, such as MATLAB, but am confused by execution times for
>> the following programs:
>> [ 10 times multiplying 500x500 matrices ]

> On an SGI R10000 (a few years old), I get about 8.66 seconds for a
> FORTRAN code using the BLAS routine DGEMM to do the matrix multiplication

On HP-UX, using an HP risc processor that is also a few years old, I
tested the following:

Mathematica 4.1 : 47.2 s
MATLAB 5.3.1 : 58.7494 s
MATLAB 6.0.0.88 Release 12 : 5.4283 s
HP f90 v2.4 (-O3) using matmul for real*4 : 2.96 s
idem calling SGEMM of liblapack (mlib) : 2.41 s
HP f90 v2.4 (-O3) using matmul, real*8 : 3.86 s
idem calling DGEMM of liblapack (mlib) : 2.17 s

Some notes:

* Although Matlab 6 is reasonably fast, Matlab 5 certainly wasn't!

* Mathematica, given that it combines symbolic and numerical power,
is not that bad either. In fact its time drops to less than 2s for
matrix size 250 instead of 500, so it just seems to lack proper
blocking.

* HP's fortran compiler is clearly faster than MATLAB, and the mlib
library (which is hand-optimized) is about 2.5 times faster.

* Single precision is slightly faster than double with matmul, and
slightly slower when comparing SGEMM vs. DGEMM

-- Jos

bv

unread,
May 3, 2001, 9:14:54 PM5/3/01
to
pred...@bellatlantic.net wrote:
>
> general experience has been in this regard. Any thoughts? Are there
> real-world computations for which interpreted MATLAB is more-or-less as
> fast as other languages, like Fortran?

*Never*! Assuming this is not a troll by a Matlab drone, I'll make an
exception and offer a few thoughts on the subject. First, you need to
examine how Matlab is put together and then apply basic laws of nature
and you'll know that squeezing out more than you put in, well...

Now to your "benchmark". I dug out a piece of code that's probably some
20++ years old, therefore predating Blas, Atlas and HP dlls, as
apparently Matlab did in this case, this is what plain vanilla Fortran
of yesteryear did:

P800MHz, Watcom, 3.74 sec

Unlike the homework problem above, you may want to peruse through the
results of the "Language Contest" (on "Applications" pg) we ran last
year. There were no Matlab entries, however, there was a subsequent
solution with Mathematica -- *TWO ORDERS" of magnitude off the winning
Fortran solution.

btw, if someone is interested in the old "Cheetah" code, drop us a note.
Offer valid to ftn users only as I'd hate to see the original artwork
mangled into something else.

--
Dr.B.Voh
------------------------------------------------------
Applied Algorithms http://sdynamix.com

Jason Bowman

unread,
May 3, 2001, 11:53:42 PM5/3/01
to
Speed used to be the paradigm, but today portability and debugging are
as if not more important. I work next to a CFD and CEM group, and
they'll tell you that code would be written that only worked on or was
optimized for the latest and greatest machine. Eventually they
realized that they were losing productivity not because of speed but
because they were always updating code for the newest machines. I
don't know about the F95 specification, but the improvements in F90
over F77 came too late and half-assed for me to give fortran another
try. Pointers that really aren't pointers? Object-oriented
programming that isn't? C++ has its problems too. I think the main
one is the legacy C as a subset. Take away the C (looks like Java)
but keep it compiled (unlike Java) and I'd be happy. But languages
like C++ offer a programming paradigm that satisfies the portability
and debugging requirements of today's world, and with the STL C++
just keeps getting better. Maybe I should start programming in it
some day. I've got a highly optimized Matlab code running on a new
PC that can't beat a similar compiled code running on a 5 year old
SGI doing more detailed calculations.

Ok, it's time for me to go to bed now. Just my $0.02.
Jason

bv wrote:
>
> pred...@bellatlantic.net wrote:
> >
> > general experience has been in this regard. Any thoughts? Are there
> > real-world computations for which interpreted MATLAB is more-or-less as
> > fast as other languages, like Fortran?
>

> Now to your "benchmark". I dug out a piece of code that's probably some
> 20++ years old, therefore predating Blas, Atlas and HP dlls, as
> apparently Matlab did in this case, this is what plain vanilla Fortran
> of yesteryear did:
>
> P800MHz, Watcom, 3.74 sec
>

Heike Koch-Beuttenmüller

unread,
May 11, 2001, 2:54:55 AM5/11/01
to

Jos Bergervoet schrieb:

> In comp.lang.fortran Tom Hoffend <trho...@mmm.com> wrote:
> > In comp.soft-sys.matlab pred...@bellatlantic.net wrote:
> >> other languages, such as MATLAB, but am confused by execution times for
> >> the following programs:
> >> [ 10 times multiplying 500x500 matrices ]
> > On an SGI R10000 (a few years old), I get about 8.66 seconds for a
> > FORTRAN code using the BLAS routine DGEMM to do the matrix multiplication
>
> On HP-UX, using an HP risc processor that is also a few years old, I
> tested the following:
>
> Mathematica 4.1 : 47.2 s
> MATLAB 5.3.1 : 58.7494 s
> MATLAB 6.0.0.88 Release 12 : 5.4283 s
> HP f90 v2.4 (-O3) using matmul for real*4 : 2.96 s
> idem calling SGEMM of liblapack (mlib) : 2.41 s
> HP f90 v2.4 (-O3) using matmul, real*8 : 3.86 s
> idem calling DGEMM of liblapack (mlib) : 2.17 s

I did some tests with matlab5 , matlab6 and octave for the
matrix-Multiplication on Solaris yesterday and I got these great differences
due to the highly optimized DGEMM now used by Matlab6 as well (about a factor
of ten). When I made tests with the DGEMM- routines of the Computer
Manufacturer with Fortran on different computers (SGI, Sun, AIX, HP, Compaq
alpha) those Compilers which are highly optimizing gave results near the
floating point peak performance. Some compilers where able to optimize the
matrix multiplication written with loops nearly as good as th DGEMM (see HP
f90 results above). So it depends on the MATMUL you have used and the
optimization possibilities of your Fortran-Compiler.

Best regards
Heike Koch-Beuttenmüller

>

0 new messages