Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
117 Views

very different results from FFT when using MKL internal threading

 

 

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
1 Reply
Highlighted
Moderator
80 Views

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


0 Kudos