fortran使用MKL中的DGEMM实现大矩阵相乘

program TestMKLDgemm
        use ifport, only : fdate
        implicit none
        real*8  :: alpha, beta
        integer :: i, j
        integer, parameter :: m = 5000, k = 5000, n = 5000
        real*8 :: A(m,k), B(k,n), C(m,n)

        !// C = alpha*A*B + beta*C
        alpha = 1.d0
        beta  = 0.d0
        call random_seed()
        call random_number(A)
        call random_number(B)

        C = 0.d0

        print*, fdate()
        call DGEMM('N', 'N', M, N, K, alpha, A, M, B, K, beta, C, M)
        print*, fdate()

end program TestMKLDgemm
记得开启MKL函数库, 必要时调大堆栈

 

你可能感兴趣的:(FortranNote,Fortran教程,MKL函数库,fortran)