Community
cancel
Showing results for 
Search instead for 
Did you mean: 
shawnstat
Beginner
128 Views

Memory question.

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
0 Kudos
13 Replies
barragan_villanueva_
Valued Contributor I
128 Views

Hi,

For large data it's recommended to place them into allocatable buffers. Are they in allocatable memory?
Also, maybe you need to use ILP64 interfaceof MKL....
Nadezhda_M_Intel
Employee
128 Views

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

* 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.

shawnstat
Beginner
128 Views


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
shawnstat
Beginner
128 Views

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
shawnstat
Beginner
128 Views

How to place the data into allocatable buffers?
You mean like this:
real, allocatable :: DataName(:,:,:).
and read the data.
barragan_villanueva_
Valued Contributor I
128 Views

Hi,

Could you please share with usyour testcase (MIX.f90 or some small reproducer) to analyze your problem?
Victor_K_Intel1
Employee
128 Views

It is not clear from the example where i is used? Probably, there is a typo. Or you ment solving the same sytem 50 times?
And one more question - how do you know the result is not correct?
shawnstat
Beginner
128 Views

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.
shawnstat
Beginner
128 Views

PS: the ILP interface works well.
Thank you very much.
Shawn
Gennady_F_Intel
Moderator
128 Views

Shawn, does that mean there are no problems with big input data you originally indicated?
shawnstat
Beginner
128 Views

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
Gennady_F_Intel
Moderator
128 Views

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
shawnstat
Beginner
128 Views

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

Reply