Hello,

Does anyone know if there is a fast cosine transform routine within the FFT library?

Mandrew

# Fast Cosine Transform?

## Fast Cosine Transform?

For more complete information about compiler optimizations, see our Optimization Notice.

Quoting - mandrew

*Hello,
Does anyone know if there is a fast cosine transform routine within the FFT library?
Mandrew
*

Hello Mandrew,

There is a part of MKL that realized fast cosine transform -Trigonometric Transform. In details it describe in chapter 13 "*Partial Differential Equations Support*" of Intel Math Kernel Library** **Reference Manual

With best regards,

Alexander

I have tried using the trigonometric transform, however, I have had some problems using it. It appears that many of the parameters needed to call these routines are associated with the partial differential equation library. Since I don't want to actually use these parameters I am not sure how to initialize/use them. For instance, when I tried using the cosine transform a time-dependent simulation, it was working for the beginning of the simulation, but then I get the following error messages in the terminal:

------------------------------------------------------------------------------

MKL TRIG TRANSFORMS ERROR:

Initialization has failed to complete, or the parameter ipar[6]=-10000

was altered by mistake outside the d_commit_trig_transform routine

------------------------------------------------------------------------------

MKL TRIG TRANSFORMS ERROR:

The previous call to an MKL Trigonometric Transform routine produced an error

code, or the parameter ipar[6]=-10000 was altered by mistake outside

the routine. If you are sure that everything is correct, you may force the

routine to work by setting ipar[6]=0 before the call to this routine

------------------------------------------------------------------------------

The larger the problem size, the sooner these messages pop up during the simulation. Any idea why this might be happening?

Thanks,

Mandrew

Quoting - mandrew

*I have tried using the trigonometric transform, however, I have had some problems using it. It appears that many of the parameters needed to call these routines are associated with the partial differential equation library. Since I don't want to actually use these parameters I am not sure how to initialize/use them. For instance, when I tried using the cosine transform a time-dependent simulation, it was working for the beginning of the simulation, but then I get the following error messages in the terminal:*

------------------------------------------------------------------------------

MKL TRIG TRANSFORMS ERROR:

Initialization has failed to complete, or the parameter ipar[6]=-10000

was altered by mistake outside the d_commit_trig_transform routine

------------------------------------------------------------------------------

MKL TRIG TRANSFORMS ERROR:

The previous call to an MKL Trigonometric Transform routine produced an error

code, or the parameter ipar[6]=-10000 was altered by mistake outside

the routine. If you are sure that everything is correct, you may force the

routine to work by setting ipar[6]=0 before the call to this routine

------------------------------------------------------------------------------

The larger the problem size, the sooner these messages pop up during the simulation. Any idea why this might be happening?

Thanks,

*Mandrew*

Hello Mandrew,

It's look like init step of TT has failed to complete or was not execute. Could you show in this topic the value of ipar[6] after init step and before commit step?

With best regards,

Alexander

Quoting - mandrew

Alexander,

I get ipar[6]=1 both after the init step and before the commit step - hope that helps.

*Mandrew*

Mandrew,

It's a really strange and look like there are some problems with fortran/C interpretation. Could you show how you call init of TrigTransform?

With best regards,

Alexander

Quoting - Alexander Kalinkin (Intel)

Mandrew,

It's a really strange and look like there are some problems with fortran/C interpretation. Could you show how you call init of TrigTransform?

With best regards,

Alexander

Alexander,

I use the same procedure given in the manual:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

How should I be initializing ipar, dpar, and ir?

Mandrew

Quoting - mandrew

Alexander,

I use the same procedure given in the manual:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

How should I be initializing ipar, dpar, and ir?

*Mandrew*

Mandrew,

D_INIT_TRIG_TRANSFORM must initializing ipar, dpar and ir itself, you need only allocate these arrays. As I understood, your program developed by Fortran, so could you show the value of ipar(7) and how you call D_COMMIT_TRIG_TRANSFORM?

With best regards,

Alexander

Quoting - Alexander Kalinkin (Intel)

Mandrew,

D_INIT_TRIG_TRANSFORM must initializing ipar, dpar and ir itself, you need only allocate these arrays. As I understood, your program developed by Fortran, so could you show the value of ipar(7) and how you call D_COMMIT_TRIG_TRANSFORM?

With best regards,

Alexander

Alexander,

Yes, I am using fortran 90. I get ipar(7)=0 after INIT step. I then call the routine using:

CALL D_COMMIT_TRIG_TRANSFORM(Vector,handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(Vector,handle_dct,ipar,dpar,ir)

Mandrew

Quoting - mandrew

Alexander,

Yes, I am using fortran 90. I get ipar(7)=0 after INIT step. I then call the routine using:

CALL D_COMMIT_TRIG_TRANSFORM(Vector,handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(Vector,handle_dct,ipar,dpar,ir)

*Mandrew*

Mandrew,

The situation is really strange for me. The error, you wrote below could be appeared only if ipar(7) is equal -10000. ipar(7) could be equal -10000 if you call commit or forward/backward with ipar(7) not equal zero, so to get ipar(7) = -10000 you need to call commit with ipar(7) not equal zero twice. The variant, if you sure that you didn't change internal data you can set ipar(7) =0 before commit, but you wrote that it is so. The better solution I see if you could develop test case of this problem and attach it here?

With best regards,

Alexander

Quoting - Alexander Kalinkin (Intel)

Mandrew,

The situation is really strange for me. The error, you wrote below could be appeared only if ipar(7) is equal -10000. ipar(7) could be equal -10000 if you call commit or forward/backward with ipar(7) not equal zero, so to get ipar(7) = -10000 you need to call commit with ipar(7) not equal zero twice. The variant, if you sure that you didn't change internal data you can set ipar(7) =0 before commit, but you wrote that it is so. The better solution I see if you could develop test case of this problem and attach it here?

With best regards,

Alexander

Alexander,

I will paraphrase my code here since it is rather lengthy. Essentially I am performing a time-dependent simulation that takes many forward/backward cosine transforms at each time step. It looks something like this:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

DO iter=1,itermax

DO i=1,N

( Solve for vecnew here )

END DO

DO i=1,N

CALL D_COMMIT_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

END DO

vecold=vecnew

END DO

Is there anything that I might be doing incorrectly with the cosine transform in the above example?

Mandrew

Quoting - mandrew

Alexander,

I will paraphrase my code here since it is rather lengthy. Essentially I am performing a time-dependent simulation that takes many forward/backward cosine transforms at each time step. It looks something like this:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

DO iter=1,itermax

DO i=1,N

( Solve for vecnew here )

END DO

DO i=1,N

CALL D_COMMIT_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

END DO

vecold=vecnew

END DO

Is there anything that I might be doing incorrectly with the cosine transform in the above example?

*Mandrew*

Hi Mandrew,

I think that problem is that your program try to initializate one handle several times. So try to change your program in next way:

CALL D_COMMIT_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

DO i=1,N

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

END DO

As additional you will have increase in performance :)

With best regards,

Alexander

Quoting - Alexander Kalinkin (Intel)

Hi Mandrew,

I think that problem is that your program try to initializate one handle several times. So try to change your program in next way:

CALL D_COMMIT_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

DO i=1,N

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew(:,i),handle_dct,ipar,dpar,ir)

END DO

As additional you will have increase in performance :)

With best regards,

Alexander

Alexander,

Is it possible to only use one COMMIT step prior to beginning the simulation for many vectors and for forward and backward transforms? In other words can I do the following:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

CALL D_COMMIT_TRIG_TRANSFORM(vecnew1(:,1),handle_dct,ipar,dpar,ir)

DO iter=1,itermax

DO i=1,N

( Solve for all vecnew* here )

END DO

DO i=1,N

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew1(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew2(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew3(:,i),handle_dct,ipar,dpar,ir)

END DO

DO i=1,N

CALL D_FORWARD_TRIG_TRANSFORM(vecnew1(:,i),handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(vecnew2(:,i),handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(vecnew3(:,i),handle_dct,ipar,dpar,ir)

END DO

END DO

Thanks,

Mandrew

Quoting - mandrew

Alexander,

Is it possible to only use one COMMIT step prior to beginning the simulation for many vectors and for forward and backward transforms? In other words can I do the following:

CALL D_INIT_TRIG_TRANSFORM(N,MKL_COSINE_TRANSFORM,ipar,dpar,ir)

CALL D_COMMIT_TRIG_TRANSFORM(vecnew1(:,1),handle_dct,ipar,dpar,ir)

DO iter=1,itermax

DO i=1,N

( Solve for all vecnew* here )

END DO

DO i=1,N

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew1(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew2(:,i),handle_dct,ipar,dpar,ir)

CALL D_BACKWARD_TRIG_TRANSFORM(vecnew3(:,i),handle_dct,ipar,dpar,ir)

END DO

DO i=1,N

CALL D_FORWARD_TRIG_TRANSFORM(vecnew1(:,i),handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(vecnew2(:,i),handle_dct,ipar,dpar,ir)

CALL D_FORWARD_TRIG_TRANSFORM(vecnew3(:,i),handle_dct,ipar,dpar,ir)

END DO

END DO

Thanks,

*Mandrew*

Mandrew,

Yes, If you want to use Forward/Backward TrigTransform with one tt_type and with one dimension (N) several times the best way to using it - as in your example

With best regards,

Alexander

Quoting - Alexander Kalinkin (Intel)

*Mandrew,Yes, If you want to use Forward/Backward TrigTransform with one tt_type and with one dimension (N) several times the best way to using it - as in your exampleWith best regards,Alexander*

Alexander,

Yes, placing one init step before the time-stepping loop began has fixed issue.

Thanks,

Mandrew

Quoting - mandrew

Alexander,

Yes, placing one init step before the time-stepping loop began has fixed issue.

Thanks,

*Mandrew*

Hi Mandrew,

You are welcome,

Alexander