AMD 9950x dgemm benchmarks OPENBLAS/BLIS/MKL

A while ago I inquired about benchmarks for dgemm. In the meantime my own machine arrived and shows some impressive numbers over 2.3 TFLOPs.
As expected faster memory helps… This run was with 2x 48 GB MT6000 memory.
With not completely stable (4x48) 192 GB@4800 MT it peaks at 2 TFlops.

2 Likes

Unfortunately, I seem not to be able to get an uploaded picture displayed… any help?

I see the picture, although it looks a little truncated on all sides.

the X-axis of the graph is n, correct?

How does the scaling look with bigger matrices? In the past I remember this is where MKL took the lead over other BLAS.

Sorry, I did not label the axis: y is TFlops, x is the matrix size.
I checked now bigger matrices as well.
You are very right. This is were Intel shines and BLIS and Openblas looses! My matrix sizes are small(er) though.
dgemm_larger

2 Likes

Thanks for sharing this!

AMD has made progress with their homegrown BLAS, AOCL, the past ~year with the launch of version 4.x by including AVX-512 and targeting Zen 4/5 architectures specifically… but I did notice AMD often used very small problems in their comparison benchmarks which seemed to be the only area they performed competitively in compared to MKL.

My thought is that BLAS performance doesn’t matter much in small problem sizes since they can be solved in seconds; I’m more worried about the large matrices that take days or weeks to solve.
I do realize there are a subset of problems that can be captured by solving many small matrices where these other BLAS are competitive with MKL, but none of the problems I ever find myself up against are like this.

1 Like

I was really wondering about the BLIS performance drop for larger matrices. Indeed when I checked for the influence of the thread affinity I saw better results, still below the MKL data but definitely better.
omp
tter.

2 Likes

The new AGESA 1.2.0.2 update that’s recently come out for some motherboard’s is supposed to reduce CCD to CCD latency by half, I suspect this update would improve BLAS performance.

1 Like

Could you gave me the code in Fortran or C?
I am testing also OpenBLAS, AOCL-Blis/FLAME, intel-MKL. I saw lately the patcher fake intel doesnt work at 2025 Intel MKLoneapi.

The Pardiso and DSS sparse solver seems slower in 2025 than 2019 version, the LLVM intel icx can now made superlu superfast.

program lapack_comparison
    implicit none
    integer :: n, i, j, lda, info
    double precision, allocatable :: A(:,:), A_inv(:,:), A_twice_inv(:,:),B(:,:)
    double precision, allocatable :: work(:)
    integer, allocatable :: ipiv(:)
    real*8 :: start, finish, time_dgetri, time_dgetrs,avg_Err

    ! User input for matrix size
    print *, "Enter matrix size (n):"
    read *, n
    lda = n

    ! Allocate matrices
    allocate(A(n, n), A_inv(n, n), A_twice_inv(n, n), ipiv(n),B(n,n))
    allocate(work(n))

    ! Generate a random symmetric positive definite matrix
    call random_seed()
    call random_number(A)
    A = 0.5 * (A + transpose(A)) + n * eye(n)
    

    !compare the result
    print *,'Important to save because it will changed thru DGTRF/DGTRS'
    open(10,file='matrix_A.dat',form='unformatted')
    write(10) n
    write(10) A
    close(10)


    if (n.lt.10) then
    ! Print original matrix
    print *, "Original Matrix (A):"
    call print_matrix(A, n)
    endif

    ! ---- DGETRF + DGETRI ----
    print *, 'DGETRF + DGETRI'
    A_inv = A
    deallocate(A)
    call cpu_time(start)
    call dgetrf(n, n, A_inv, lda, ipiv, info)
    if (info /= 0) stop 'DGETRF failed'
    
    call dgetri(n, A_inv, lda, ipiv, work, n, info)
    if (info /= 0) stop 'DGETRI failed'

    if (n.lt.10) then
    ! Print inverse matrix
    print *, "Inverse Matrix (A^-1):"
    call print_matrix(A_inv, n)
    endif

    ! Compute A_twice_inv using DGETRF + DGETRI again
    A_twice_inv = A_inv
    deallocate(A_inv)
    call dgetrf(n, n, A_twice_inv, lda, ipiv, info)
    call dgetri(n, A_twice_inv, lda, ipiv, work, n, info)

    call cpu_time(finish)
    time_dgetri = finish - start

    if (n.lt.10) then
    ! Print inverse matrix
    print *, "re-Inverse Matrix (A^-1)^-1:"
    call print_matrix(A_twice_inv, n)
    endif

    !compare the result
    open(10,file='matrix_A.dat',form='unformatted')
    read(10) i
    if (i.ne.n) stop 'wrong data n'
    allocate(A(i,i))
    read(10) A
    close(10)

    ! Compute column-wise error
    avg_err=0.d0
    avg_err = SUM(ABS(A - A_twice_inv)) / (n * n)
    print *, 'DGETRI twice invers error', avg_err
    deallocate(A_twice_inv)

    ! ---- DGETRF + DGETRS ----
    print *, 'DGETRF + DGETRS'
    if (n.lt.10) then
    ! Print original matrix
    print *, "Original Matrix (A):"
    call print_matrix(A, n)
    endif

    call cpu_time(start)
    call dgetrf(n, n, A, lda, ipiv, info)
    if (info /= 0) stop 'DGETRF failed'
    
    ! Compute inverse column-by-column
    allocate(A_inv(n,n))
    A_inv = 0.0d0
    do j = 1, n
        A_inv(:, j) = 0.0d0
        A_inv(j, j) = 1.0d0
        call dgetrs('N', n, 1, A, lda, ipiv, A_inv(:, j), n, info)
    end do
    deallocate(A)

    if (n.lt.10) then
    ! Print inverse matrix
    print *, "Inverse Matrix (A^-1):"
    call print_matrix(A_inv, n)
    endif

    call dgetrf(n, n, A_inv, lda, ipiv, info)
    if (info /= 0) stop 'DGETRF failed'
    
    ! Compute inverse column-by-column
    allocate(A_twice_inv(n,n))
    A_twice_inv = 0.0d0
    do j = 1, n
        A_twice_inv(:, j) = 0.0d0
        A_twice_inv(j, j) = 1.0d0
        call dgetrs('N', n, 1, A_inv, lda, ipiv, A_twice_inv(:, j), n, info)
    end do

    deallocate(A_inv)

    if (n.lt.10) then
    ! Print inverse matrix
    print *, "re-Inverse Matrix (A^-1)^-1:"
    call print_matrix(A_twice_inv, n)
    endif

    !compare the result
    open(10,file='matrix_A.dat',form='unformatted')
    read(10) i
    if (i.ne.n) stop 'wrong data n'
    allocate(A(i,i))
    read(10) A
    close(10)

    if (n.lt.10) then
    ! Print original matrix
    print *, "recheck Original Matrix (A):"
    call print_matrix(A, n)
    endif
    call cpu_time(finish)
    time_dgetrs = finish - start

    !check error 
    avg_err=0.d0
    avg_err = SUM(ABS(A - A_twice_inv)) / (n * n)
    print *, 'DGETRS twice invers error', avg_err

    ! Print performance results
    print *, 'DGETRF + DGETRI Time:', time_dgetri, ' seconds'
    print *, 'DGETRF + DGETRS Time:', time_dgetrs, ' seconds'

    ! Cleanup
    deallocate(A, A_twice_inv, ipiv, work)

contains
    function eye(n) result(Identity)
        integer, intent(in) :: n
        double precision :: Identity(n, n)
        integer :: i
        Identity = 0.0d0
        do i = 1, n
            Identity(i, i) = 1.0d0
        end do
    end function eye

    ! Print a matrix
    subroutine print_matrix(M, n)
        implicit none
        integer, intent(in) :: n
        double precision, intent(in) :: M(n, n)
        integer :: i, j

        do i = 1, n
            print '(4F12.6)', (M(i, j), j=1, n)
        end do
        print *
    end subroutine print_matrix

end program lapack_comparison

This topic was automatically closed 273 days after the last reply. New replies are no longer allowed.