From: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
To: Siegfried Gonzi <siegfried.gonzi@kfunigraz.ac.at>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Some clarifications to the language shootout page
Date: Mon, 25 Nov 2002 12:09:05 +0100 [thread overview]
Message-ID: <3DE204D1.9090901@kfunigraz.ac.at> (raw)
In-Reply-To: <3DE1E6CD.2020906@kfunigraz.ac.at>
For the sake of completeness: An update to the Fortran 90/95 version.
This version comes close to C and even surpasses it a bit after adding a
few lines (the overal matrix matrix multiplication scheme just remains
valid, though). The author (thanks to François BÉREUX) gave the okay for
posting it here:
==
Hello,
I reply to you privately about the F90 code of the benchmark you mention (because this
is only Fortran related and not Caml related, but you can quote my e-mail if you want):
there is a primitive in the F90 language called matmul which precisely does dense
matrix-matrix multiplication, and which is pretty well optimized.
I ran the test on a Sun Solaris Ultra SParc III 600 MHz , with the compiler suite
WorkShop 6.2, and I got the following timings :
1) your C version (compiled with the -fast option) :
2.4s/2.02s/0.03s
2) your F90 version (compiled with the -fast option) :
5.2s/4.4s/0.02s
3)a F90 version using matmul (compiled with the -fast option ):
0.8s/0.7s/0.06s
I guess a similar conclusion will hold on your platform.
Now, if you do not want to use the matmul or dot_product primitives and would like to
program in a F77 way, the following code for mmult is better suited than yours:
subroutine mmult(m, n, a, b, c)
integer, intent(in) :: m,n
double precision, dimension(:,:), intent(in) :: a,b
double precision, dimension(:,:), intent(out) :: c
integer :: i,j,k
!! initialize c by 0.
do j = 1, n
do i = 1, m
c(i,j) = 0.0
enddo
enddo
!!
do k = 1, n
do j = 1, n
do i =1, m
c(i,j) = c(i,j) + a(i,k)*b(k,j)
enddo
enddo
enddo
!!
end subroutine mmult
4)a F90 version with an improved mmult (compiled with the -fast option ):
2.8s/1.8s/0.07s
which is faster than the C version.
Best regards,
F. Béreux
PS : please find enclosed the F90 code using matmul:
==========
version using matmul
==========
program main
integer:: size=512
double precision, POINTER,dimension(:,:):: m1, m2, mm
call mkmatrix(size,size,m1)
call mkmatrix(size,size,m2)
call mkmatrix(size,size,mm)
mm = matmul(m1,m2)
print *, mm(1,1)
deallocate(m1)
deallocate(m2)
deallocate(mm)
contains
subroutine mkmatrix(rows, cols,m)
integer, intent(in):: rows, cols
double precision, POINTER, dimension(:,:):: m
double precision:: counter
integer:: i,j
allocate(m(rows,cols))
counter = 1.0
do i=1,cols
do j=1,rows
counter = counter + 1.0
m(j,i) = counter
end do
end do
end subroutine mkmatrix
end program main
===============================
S. Gonzi
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-11-25 10:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-25 9:01 Siegfried Gonzi
2002-11-25 10:23 ` Pierre Weis
2002-11-25 13:03 ` Siegfried Gonzi
2002-11-25 11:09 ` Siegfried Gonzi [this message]
2002-11-26 9:43 ` Siegfried Gonzi
2002-11-26 13:22 ` Pierre Weis
2002-11-27 20:50 isaac gouy
2002-11-29 8:32 ` Siegfried Gonzi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3DE204D1.9090901@kfunigraz.ac.at \
--to=siegfried.gonzi@kfunigraz.ac.at \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox