diff options
Diffstat (limited to 'matrixproduct.f90')
| -rw-r--r-- | matrixproduct.f90 | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/matrixproduct.f90 b/matrixproduct.f90 index feb4cf1..fd15622 100644 --- a/matrixproduct.f90 +++ b/matrixproduct.f90 @@ -11,10 +11,10 @@ program matrixproduct external :: dgemm !> double-precision general matrix-matrix multiplication real(real64), allocatable, dimension(:,:) :: A, B, C - real(real64) :: start, end, loop_time, matmul_time, blas_time + real(real64) :: start, end, loop_time, loop_alt_time, matmul_time, blas_time integer(int32) :: n - do n = 1000,100000,1000 + do n = 1000,35000,1000 call prep_mats(A,B,C,n) call cpu_time(start) @@ -24,6 +24,12 @@ program matrixproduct C = 0 call cpu_time(start) + !call triple_loop_mul_alt(A,B,C,n) + call cpu_time(end) + loop_alt_time = end-start + C = 0 + + call cpu_time(start) C = matmul(A,B) call cpu_time(end) matmul_time = end-start @@ -34,7 +40,8 @@ program matrixproduct call cpu_time(end) blas_time = end-start - write(*,'((i5),3(e16.8))') n, loop_time, matmul_time, blas_time + !write(*,'((i5),4(e16.8))') n, loop_time, loop_alt_time, matmul_time, blas_time + write(*,'((i5),2(e16.8))') n, matmul_time, blas_time enddo contains @@ -69,5 +76,20 @@ contains end subroutine triple_loop_mul + subroutine triple_loop_mul_alt(A,B,C,n) + real(real64), dimension(:,:), intent(in) :: A,B + real(real64), dimension(:,:), intent(out) :: C + integer(int32), intent(in) :: n + integer(int32) :: i, j, k + + col: do j = 1,n + row: do i = 1,n + sum: do k = 1,n + C(i,j) = C(i,j) + A(i,k)*B(k,j) + end do sum + end do row + end do col + + end subroutine triple_loop_mul_alt end program matrixproduct |
