Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
6440 Discussions

very different results from FFT when using MKL internal threading

cgg_distribution
Beginner
411 Views

 

 

The following code returns different results (that do not seem to be down to numerical precision). depending on whether I set the mkl internal threading.

I have attached the input (data1.txt) to reproduce the issue.

And also the outputs:

data1_out_4f.txt ( with  mkl_set_num_threads(4) )

data1_out_1f.txt ( with  mkl_set_num_threads(1) )

 

program fft_issue

        USE MKL_DFTI

        implicit none

        include  'mkl.fi'

        integer length
        integer ntr,i,j,itr,nfft
        real, allocatable :: buffer(:)
        complex, allocatable :: buffer_out(:)
        complex, allocatable :: s1(:)
        integer status

        type(dfti_descriptor), pointer :: My_Desc1_Handle

        length = 2051
        nfft = 3200

        allocate(buffer(length))
        allocate(buffer_out(nfft))
        allocate(s1(nfft))

        open(1, file = 'data1.txt')

        do j = 1 , 2051
           read(1,*), buffer(j)
        enddo
        call mkl_set_num_threads(4)

        s1(:length) = cmplx(buffer(:))
        s1(length+1:) = 0

        status = DftiCreateDescriptor(My_Desc1_Handle,DFTI_SINGLE,DFTI_COMPLEX,1,3200)
        status = DftiSetValue(My_Desc1_Handle, DFTI_PLACEMENT, DFTI_NOT_INPLACE);
        status = DftiSetValue(My_Desc1_Handle, DFTI_NUMBER_OF_TRANSFORMS, 1);
        status = DftiSetValue(My_Desc1_Handle, DFTI_BACKWARD_SCALE, 1.0/nfft);
        status = DftiCommitDescriptor(My_Desc1_Handle);
        status = DftiComputeForward( My_Desc1_Handle, s1, buffer_out )
        status = DftiComputeBackward( My_Desc1_Handle, buffer_out, s1 )

        open(1, file = 'data1_out_4f.txt')

        do j = 1 , nfft
           write(1,*), s1(j)
        enddo


      end program

 

 

I am running the program on a 4-core Intel(R) Xeon(R) CPU E3-1240 v3 @ 3.40GHz

I am using mkl 19 update 5

My compile command as follows:

/opt/intel/19/bin/ifort reproduce_intel.f90 -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl -I${MKLROOT}/include

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
374 Views

thanks, Marie for the case. At the very first glance, everything is correct with this case. We will check and get back asap.


Gennady_F_Intel
Moderator
280 Views

the issue has been reproduced and escalated against the MKL FFT team. We will keep this thread informed when the fix will be ready to release.


Reply