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

Memory increasing problem calling trigonometric transform routines.

zhangwei83
Beginner
411 Views
Hi all

I have some problems with calling trigonometric transform routines in MKL, here is the exact description of my

problem: In loops(up to more than 1,000,000),i need to call MKL trigonometric transform routines to calculate Fast

cosine fourier transform, but when running my problem, the memory is increasing continuously till the problem has

to stop.

My OS is Windows xp sp2, with Intel visual fortran 11.0 and MKL 10.0

The following subroutine is called in loops:

subroutine residual(mgh,ush)
use global
implicit none
integer i,j,nn,mgh
real*8 ush(0:nx(mgh),0:ny(mgh),2:3)
type(dfti_descriptor), pointer :: handle_c,handle_s
integer tt_type_c,tt_type_s,stat_s,stat_c
integer ipar_c(128),ipar_s(128)
real*8 dpar_c(5*max(ni,nj)/2+2),dpar_s(5*max(ni,nj)/2+2)
real*8 an(0:max(ni,nj)),qprime(0:max(ni,nj)),qdprime(0:max(ni,nj))
real*8 vx1(ni-1),vx2(ni-1),px(ni-1)
real*8 vy1(nj-1),vy2(nj-1),py(nj-1)
resi=0.
tt_type_c=1
tt_type_s=0
!
nn=nx(mgh)
do j=1,ny(mgh)-1

an(0:nn)=mid(0:nn,j,2)
call d_init_trig_transform(nn,tt_type_c,ipar_c,dpar_c,stat_c)
call d_commit_trig_transform(an(0:nn),handle_c,ipar_c,dpar_c,stat_c)
call d_forward_trig_transform(an(0:nn),handle_c,ipar_c,dpar_c,stat_c)
call free_trig_transform(handle_c,ipar_c,stat_c)
qprime(0:nn)=an(0:nn)*i_1(0:nn)
qprime(0)=0.0
qprime(nn)=0.0
call d_init_trig_transform(nn,tt_type_s,ipar_s,dpar_s,stat_s)
call d_commit_trig_transform(qprime(0:nn),handle_s,ipar_s,dpar_s,stat_s)
call d_backward_trig_transform(qprime(0:nn),handle_s,ipar_s,dpar_s,stat_s)
call free_trig_transform(handle_s,ipar_s,stat_s)
qdprime(0:nn)=an(0:nn)*i_2(0:nn)
call d_init_trig_transform(nn,tt_type_c,ipar_c,dpar_c,stat_c)
call d_commit_trig_transform(qdprime(0:nn),handle_c,ipar_c,dpar_c,stat_c)
call d_backward_trig_transform(qdprime(0:nn),handle_c,ipar_c,dpar_c,stat_c)
call free_trig_transform(handle_c,ipar_c,stat_c)
!
vx1(1:nn-1)=qprime(1:nn-1)*xdon12(1:nn-1,mgh)
vx2(1:nn-1)=qprime(1:nn-1)*xdon32(1:nn-1,mgh)-qdprime(1:nn-1)*xdon1(1:nn-1,mgh)
!
call dgemv('n',nn-1,nn-1,1.0,pdx(1:nn-1,1:nn-1,mgh),nn-1,mid(1:nn-1,j,1),1,0.0,px,1)

resi(1:nn-1,j,1)=resi(1:nn-1,j,1)-beta*vx1(1:nn-1)
resi(1:nn-1,j,2)=resi(1:nn-1,j,2)-mid(1:nn-1,j,2)*vx1(1:nn-1)+vx2(1:nn-1)/re-px(1:nn-1)

enddo
call mkl_freebuffers()
end subroutine

As you can see, the forward and backward routines are called several times in the subroutine and the subroutine is

called in the main program for many times.

Could anyone tell me how to deal with this problem? Thanks a lot.
0 Kudos
1 Reply
Sergey_G_Intel
Employee
411 Views
Hi,

First of all, thank you for using Intel MKL!

Could you please check and let me know what happens if you
1. put the line call mkl_freebuffers() inside the loop
2. put the calls to all init andcommit routines before the loopand the calls to all free routinesafter the loop

It would also be helpful for me to get a driver that runs your subroutine residual to see the growth of memory used. Could you provide it please?

Regards,
-Sergey G
0 Kudos
Reply