Hi everybody,
I met a problem when used the Fortran with MKL to write a program. When the volume of data is small, the function dgetrf and dgetrs, which can get the inverse of matrix , runs well, but as the data become large, say about 12GB, these functions produce strange result.
I used -mcmodel=medium to compile the code and at first sloving inverse of matrix is not based on the data.
Does anybody encounter this problem?
Thanks
链接已复制
13 回复数
Hi
Can you describe the problem in detail? The result from detrf function wasn't correct or you got error message?
Do you pay attention to return INFO parameter? You can find the following informationfor INFO parameter for dgetrf function in documentation
Can you describe the problem in detail? The result from detrf function wasn't correct or you got error message?
Do you pay attention to return INFO parameter? You can find the following informationfor INFO parameter for dgetrf function in documentation
* INFO (output) INTEGER
* = 0: successful exit
* < 0: if INFO = -i, the i-th argument had an illegal value
* > 0: if INFO = i, U(i,i) is exactly zero. The factorization
* has been completed, but the factor U is exactly
* singular, and division by zero will occur if it is used
* to solve a system of equations.
At first, supposing the max of i = 50, I use dgetrf and dgetrs to solve a matrix, dimension 8*8, in a do stetement and return a right result. But when the max of i equals to 7000000, the result is not right.
However,both dgetrf and dgetrs's INFO are equal to 0.
For example:
do i = 1,50
call dgetrf( n, n, v, n,ipiv,info1)
call dgetrs( trans,n, n, v, n, ipiv,tt,n,info2)
end do
I used ILP64 interface but it did not work. The result is also wrong.
This is my link and compile code:
ifort -i8 -I${MKL_HOME}/include/intel64/ilp64 -I${MKL_HOME}/include -mcmodel=medium -shared-intel Mixfun.f90 MIX.f90 -c
ifort -o MIX.out Mixfun.o MIX.o -L${MKL_HOME}/lib/intel64 ${MKL_HOME}/lib/intel64/libmkl_lapack95_ilp64.a -lmkl_intel_ilp64 -lmkl_intel_thread -lmkl_core -openmp -lpthread -mcmodel=medium -shared-intel -lm
Thanks
Thank you very much for your help.
At first, I put these functions into the DO statement, which may be a bad habit.
Now, I put dgetrf and dgetfs into a function and when I use them, I will load the function I write.
This method works well and the result is correct.
I use R software, which is famous in statistics computing, to test the result.
Thank you.
If I don't use the ILP interface, there are some problems about the output,such as nagetive value of a variable which is positive as it is the variance of a sample.But it is OK after using the ILP interface.
Thank you for your help.
Shawn
Shawn, I don't know methods how we can check the problem based on this description. as already Victor suggested - would you please give us the testcase for investigation the problem on our side?
--Gennady
Hi,Gennady,
I will give a description briefly.
At first ,I need to calculate the inverse of a matrix in DO statements just like below:
do k=1,km
do j=1,jm
mtemp0 = tsigma
ivm1 = i8
call dgetrf( 8, 8, mtemp0, 8,ipiv1,info1)
call dgetrs( trans,8,8, mtemp0, 8, ipiv1,ivm1,8,info2)
if(info1 /= 0 .OR. info2 /= 0) then
write(*,*) "Sigular Matrix in IVM1."
end if
mtemp1 = sigma + ivm1
ivm2 = i8
call dgetrf( 8, 8, mtemp1, 8,ipiv2,info3)
call dgetrs( trans,8,8, mtemp1, 8, ipiv2,ivm2,8,info4)
if(info3 /= 0 .OR. info4 /= 0) then
write(*,*) "Sigular Matrix in IVM2."
end if
do i=1,im
! some statements in it
end do
end do
end do
########################################
I used ILP interface to compile and link the code, however, it got some error results.
Then I modified the code, putting dgetrf and dgetrs into a function.
The function code list below(I put the function into a module):
#######################################
function inv(n,m)
integer n,ipiv(n),info1,info2
real(kind = 8) :: m(n,n),temp(n,n),inv(n,n)
call dgetrf( n, n, m, n,ipiv,info1)
temp = i8
call dgetrs(trans, n, n, m,n, ipiv,temp,n,info2)
if(info1 /= 0 .AND. info2 /=0) then
write(*,*) "Sigular matrix in sigma!!"
end if
inv = temp
end function inv
########################################
PS: i8 is anidentity matrix of dimension 8*8
At last I changed the code in the DO statments:
##################################################
do k=1,km
do j=1,jm
ivm1 = inv(8,tsigma)
mtemp1 = sigma + ivm1
vb = inv(8,mtemp1)
....
....
do i=1,im
! some statements in it
end do
end do
end do
###############################
My compile and link statements are on the #4
