Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

gemm problem

Ren_J_
Beginner
715 Views

I calculate matrix matrix product in my program. But I meet some problem.

There are three matrix.

 rightv dimension is larger than (svddimbefore,4*Rrealdimbefore).

midmat2 dimension is larger than (rsvddimbefore,4*lsvddimbefore).

coeffguess dimension is larger than (4*Rrealdimbefore,4*lsvddimbefore)

When I use the fortran95 interface

use blas95

 call gemm(rightv(1:rsvddimbefore,1:4*Rrealdimbefore),midmat2(1:rsvddimbefore,1:4*lsvddimbefore),&
              coeffguess(1:4*Rrealdimbefore,1:4*lsvddimbefore),'T','N',1.0D0,0.0D0)  

It failed!

Program received signal SIGSEGV, Segmentation fault.
0:  0x000000000059e35f in dgemm_f95_ ()

 

But when i use f77 interface

call dgemm('T','N',4*Rrealdimbefore,4*lsvddimbefore,rsvddimbefore,1.0D0,&
          rightv(1:rsvddimbefore,1:4*Rrealdimbefore),rsvddimbefore,&
          midmat2(1:rsvddimbefore,1:4*lsvddimbefore),rsvddimbefore,0.0D0,coeffguess,4*subMp)

It works.

My question is that why fortran95 interface cannot work in this case.

I used fortran95 interface gemm before, it can work. But this time it doesn't.

Any idea?

 

Best Regards,

Jiajun

 

 

 

0 Kudos
1 Solution
mecej4
Honored Contributor III
715 Views

Please show a complete code example which demonstrates the problem. In particular, the declarations of the array variables must be known, and the matrices being passed to GEMM must conform to the specifications.

Here is an example code that is similar to what you described in passing the matrix arguments as array sections. It runs correctly (verified using Matlab).

program asec_gem
use blas95
!test calling F95 GEMM with array sections
implicit none
real A(5,4), B(4,5), C(3,3)
integer i,j
!
do i=1,5
   do j=1,4
      A(i,j)=10*i+j
      B(j,i)=100*j+i
   end do
end do
write(*,'(1x,3F8.1)')((A(i,j),j=1,3),i=1,5,2)
write(*,*)
write(*,'(1x,3F8.1)')((B(i,j),j=1,5,2),i=2,4)
write(*,*)
call gemm(A(1:5:2,1:3),B(2:4,1:5:2),C)
write(*,'(1x,3F10.1)')((C(i,j),j=1,3),i=1,3)
end

 

View solution in original post

0 Kudos
2 Replies
mecej4
Honored Contributor III
716 Views

Please show a complete code example which demonstrates the problem. In particular, the declarations of the array variables must be known, and the matrices being passed to GEMM must conform to the specifications.

Here is an example code that is similar to what you described in passing the matrix arguments as array sections. It runs correctly (verified using Matlab).

program asec_gem
use blas95
!test calling F95 GEMM with array sections
implicit none
real A(5,4), B(4,5), C(3,3)
integer i,j
!
do i=1,5
   do j=1,4
      A(i,j)=10*i+j
      B(j,i)=100*j+i
   end do
end do
write(*,'(1x,3F8.1)')((A(i,j),j=1,3),i=1,5,2)
write(*,*)
write(*,'(1x,3F8.1)')((B(i,j),j=1,5,2),i=2,4)
write(*,*)
call gemm(A(1:5:2,1:3),B(2:4,1:5:2),C)
write(*,'(1x,3F10.1)')((C(i,j),j=1,3),i=1,3)
end

 

0 Kudos
Ren_J_
Beginner
715 Views

It's my fault. The problem has solved.

Thank you all.

Jiajun 

0 Kudos
Reply