B
beliavsky
Chris Uppal said:Interesting example. I'm pleased to see that the traditional superiority of
Fortan still holds. (Not that I'm a Fortran programmer myself). Presumably a
32-bit integer version would perform about the same ? Or would it be twice as
fast ?
The 32-bit integer version also takes 1.0 s. Using 64-bit integers, by changing
(kind=4) to (kind=8) in the program below, increases the run time to 21.4
s.
To optimize performance on Intel hardware one should probably use the Intel
Math Kernel Library http://www.intel.com/software/products/mkl/ , which is
callable from C or Fortran. The matmul function I used is an intrinsic function
of F95.
Here is the Fortran 95 code for multiplying integer matrices.
program xmatmul_int_time
implicit none
integer, parameter :: n = 800,icalc=3, iscale = 10
real :: x
real :: t1,t2
integer(kind=4) :: i,j,ix(n,n),iy(n,n),isum
real , parameter :: shift_ran = 0.5
call cpu_time(t1)
call random_seed()
do i=1,n
do j=1,n
call random_number(x)
ix(i,j) = iscale*(x-shift_ran)
call random_number(x)
iy(i,j) = iscale*(x-shift_ran)
end do
end do
isum = sum(matmul(ix,iy))
call cpu_time(t2)
print*,1000*(t2-t1),icalc,isum
end program xmatmul_int_time