<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic MKL_Free_Buffer Thread Safety in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Free-Buffer-Thread-Safety/m-p/998351#M18389</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;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( &amp;amp;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 &amp;amp;&amp;amp; fftType == FFT_FORWARD) 
              status = DftiComputeForward( desc_handle, iotptzz); /*descriptor handle, input and output complex*/
       if (status == 0 &amp;amp;&amp;amp; 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( &amp;amp;desc_handle );

       // MKL Free memory buffers in current thread
       MKL_Free_Buffers();

       // The function returns the zero status when completes successfully
       return status;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Apr 2014 11:53:50 GMT</pubDate>
    <dc:creator>Sai_V_</dc:creator>
    <dc:date>2014-04-22T11:53:50Z</dc:date>
    <item>
      <title>MKL_Free_Buffer Thread Safety</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Free-Buffer-Thread-Safety/m-p/998351#M18389</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;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( &amp;amp;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 &amp;amp;&amp;amp; fftType == FFT_FORWARD) 
              status = DftiComputeForward( desc_handle, iotptzz); /*descriptor handle, input and output complex*/
       if (status == 0 &amp;amp;&amp;amp; 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( &amp;amp;desc_handle );

       // MKL Free memory buffers in current thread
       MKL_Free_Buffers();

       // The function returns the zero status when completes successfully
       return status;
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Apr 2014 11:53:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-Free-Buffer-Thread-Safety/m-p/998351#M18389</guid>
      <dc:creator>Sai_V_</dc:creator>
      <dc:date>2014-04-22T11:53:50Z</dc:date>
    </item>
  </channel>
</rss>

