Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Sai_V_
Beginner
71 Views

MKL_Free_Buffer Thread Safety

Hello,

I have a code which uses MKL FFT function and is almost same as the standard example except I free the buffers at the end. It is a 1-D FFT complex to complex in-place. MKL is used by multiple threads. I am not sure if MKL_FREE_BUFFER is creating a race or a change in global state but the application crashes in MKL_FREE_BUFFER. Below is the code I used in the application. After changing to MKL_THREAD_FREE_BUFFER it doesn't seem to crash anymore but I am not sure if I am taking the right approach. Do let me know if I am using the API wrong. Any help is appreciated.

MKL_LONG MIProcessing::MklFFT(FFT_TYPE_t fftType, int length, MKL_Complex8 *iotptzz)
{
       MKL_LONG status; // MKL status of the operation
       DFTI_DESCRIPTOR *desc_handle = NULL; // MKL FFT descriptor handle
    status = DftiCreateDescriptor( &desc_handle, /*descriptor handle*/
        DFTI_SINGLE, /*precision*/
        DFTI_COMPLEX, /*forward domain*/
        1, /*dimension*/
        (MKL_LONG) length ); /*length*/
    // The function returns the zero status when completes successfully
    if (status == 0) status = DftiCommitDescriptor( desc_handle );

       if (status == 0 && fftType == FFT_FORWARD) 
              status = DftiComputeForward( desc_handle, iotptzz); /*descriptor handle, input and output complex*/
       if (status == 0 && fftType == FFT_BACKWARD) 
              status = DftiComputeBackward( desc_handle, iotptzz); /*descriptor handle, input and output complex*/
       // MKL Free memory allocated for descriptors
       if (status == 0) status = DftiFreeDescriptor( &desc_handle );

       // MKL Free memory buffers in current thread
       MKL_Free_Buffers();

       // The function returns the zero status when completes successfully
       return status;
}

 

0 Kudos
0 Replies
Reply