Error in using SGEMM

Hi all.

I wish to multiply two matrices Jr^T and Jr using the BLAS function SGEMM. Here Jr is an m x n matrix.

call sgemm('T','N',n,n,m,1.0,Jr,n,Jr,m,0.0,C,n)

While running my code on the terminal, I get the following error:

** On entry to SGEMM parameter number 8 had an illegal value

Can anyone help me identify where I might have gone wrong?

Thank you.

Parameter 8 (and 10) are the leading dimensions of the matrix, they are independent of the transpose option in the first and second argument.

call sgemm('T','N',n,n,m,1.0,Jr,n,Jr,m,0.0,C,n)
!                               ^    - actual leading dimension
!                               |
!                               incorrect size, should be size(Jr, 1)

Setting up calls to BLAS can be tedious to setup, I created a collection of interfaces to all BLAS routines plus convenience wrappers to set the dimension values automatically.

This should allow you to simply use

use blas, only : blas_gemm
! ...
call blas_gemm(Jr, Jr, C, transa="T")

instead of the full BLAS call.

6 Likes

Oh. Now I understand where I had gone wrong.

I would definitely try out the BLAS wrappers as well. They seem very convenient.

Thank you.

Seems interesting. I see there are wrappers for both blas and lapack. blas-interface and lapack interface.

Are there some test examples available to confirm that the parameters/variables are correctly passed? Although, I am expected to test some routines in the future using these interfaces.

The BLAS interface is in use in several of our projects, mainly as copy rather than as proper dependency. The LAPACK interface was only assembled recently, I still have to do some testing to ensure they all work properly.

2 Likes