PDA

View Full Version : Re: [LF] MATMUL-Performance


Lahey Support
08-15-2003, 01:33 AM
At 10:02 07-09-01 +0200, you wrote:


>Dear forum members,
>
>testing the new Fortran90/95 feature MATMUL (with LF90 4.5 and LF95
>5.6f,
>OS: WIN9X and WIN2000, with and without optimizing) i have found that
>the use of MATMUL causes the programs to run remarkable more slowly.
>
>For example, inside a subroutine (often called from a big main prgram)
>with the following subset of declarations
>
> REAL(8) :: A(2,2),B(2,2)
> REAL(8) :: X(2),Y(2),Z(2)
>
>i have changed the following code
>
> Z(1)=A(1,1)*X(1)+A(1,2)*X(2)-B(1,1)*Y(1)-B(1,2)*Y(2)
> Z(2)=A(2,1)*X(1)+A(2,2)*X(2)-B(2,1)*Y(1)-B(2,2)*Y(2)
>
>to the equivalent code
>
> Z=MATMUL(A,X)-MATMUL(B,Y)
>
>The results from the MATMUL-code are exactly the same as from the
>explicit code before, but the execution grows with MATMUL by a
>factor > 6.
>
>In an other test with the same (matrix- and vector-dimensions, the
>execution time with MATMUL-code was growing by a factor 3.
>
>Has anyone analogous experiences with other f90/f95 compilers?
>Will the MUTMUL-Performance grow by greater matrix- and
>vector-dimensions?
>How actual are the popular benchmarks in respect to the new Fortran90/95
>features?
>
>MfG
>W. Schmidt

I did a quick test with my compilers and the following program:

! [W.Schmidt] 2001-09-07 test-intr.f90
program Test_intr
implicit NONE

integer :: I
real :: T0, T1
integer, parameter :: S = 2, N = 1000000
double precision :: A(s,s), B(s,s)
double precision :: X(s), Y(s), Z(s)

A = reshape((/1,2,3,4/), (/s,s/))
B = reshape((/6,7,8,9/), (/s,s/))
X = (/ 1.1d0, 2.2d0 /)
Y = (/ -7d0, 12d0 /)

call cpu_time(T0)
do i = -N, N
! i have changed the following code
Z(1)=A(1,1)*X(1)+A(1,s)*X(s) -B(1,1)*Y(1)-B(1,s)*Y(s)
a(s,s) = i ! Against opt.
Z(s)=A(s,1)*X(1)+A(s,s)*X(s) -B(s,1)*Y(1)-B(s,s)*Y(s)
end do
call cpu_time(T1)
print "(' Explicit:', F8.3)" , T1 - T0

call cpu_time(T0)
do i = -N, N
! also equivalent [JvO] :
Z(1) = dot_product(A(1,:), X) - dot_product(B(1,:), Y)
a(s,s) = i ! Against opt.
Z(s) = dot_product(A(s,:), X) - dot_product(B(s,:), Y)
end do
call cpu_time(T1)
print "(' Dot_prod.', F8.3)" , T1 - T0

call cpu_time(T0)
do i = -N, N
! to the equivalent code
Z = MATMUL(A, X) - MATMUL(B, Y)
a(s,s) = i ! Against opt.
end do
call cpu_time(T1)
print "(' Matmul: ', F8.3)" , T1 - T0
end program Test_intr

My results (very surprising):

Absoft -O no opt. Salford
Explicit: 0.18 0.17 0.20
Dot_prod. 0.17 2.42 0.35
Matmul: 4.77 4.65 0.21 Seconds


Best regards,

--

Lahey User

----------------------------------------------------------
To unsubscribe, send to [address removed] the following
as the first and only line of the message body:
unsubscribe fortran
----------------------------------------------------------