<?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 memory leak in oneapi::mkl::blas::row_major::gemm in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1244527#M30621</link>
    <description>&lt;P&gt;My System:&lt;/P&gt;
&lt;P&gt;Ubuntu 20.04.1 LTS (Focal Fossa)&lt;/P&gt;
&lt;P&gt;Intel(R) oneAPI DPC++ Compiler 2021.1.2 (2020.10.0.1214)&lt;/P&gt;
&lt;P&gt;MKL: 2021.1.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My program is performing oneapi::mkl::blas::row_major::gemm in loop, that is a function of the following form is called repeatedly with very large matrices and massively leaking memory (16Gig after a few seconds = 50 calls or so).&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;// C = A * B, assumes row-major matrices with B being transposed already
// Inputs = {A, B'}
int MatrixMul(
   sycl::queue * queue,
   std::shared_ptr&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt; &amp;amp;output,
   const std::vector&amp;lt;std::shared_ptr&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt;&amp;gt; &amp;amp;inputs,
   size_t M, size_t N, size_t K)
{
   output = std::make_shared&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt;(M * N);
   oneapi::mkl::blas::row_major::gemm(
      *queue,
      oneapi::mkl::transpose::nontrans, oneapi::mkl::transpose::trans,
      M, N, K, 1.f,
      *inputs[0], K, *inputs[1], K,
      0.f, *output, N);

   return 0;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I tried calling "&lt;SPAN class="kwd"&gt;mkl_free_buffers&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;(&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;)" / "mkl_disable_fast_mm()", or setting &lt;SAMP class="codeph"&gt;MKL_DISABLE_FAST_MM&lt;/SAMP&gt;=1, all to no avail. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="delim"&gt;I have replaced the call to gemm with my own sycl::handler performing naive gemm and it works just fine, not leaking any memory (albeit at half the speed -.-)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;What am I missing?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;Patrik&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jan 2021 13:49:55 GMT</pubDate>
    <dc:creator>siquus</dc:creator>
    <dc:date>2021-01-08T13:49:55Z</dc:date>
    <item>
      <title>memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1244527#M30621</link>
      <description>&lt;P&gt;My System:&lt;/P&gt;
&lt;P&gt;Ubuntu 20.04.1 LTS (Focal Fossa)&lt;/P&gt;
&lt;P&gt;Intel(R) oneAPI DPC++ Compiler 2021.1.2 (2020.10.0.1214)&lt;/P&gt;
&lt;P&gt;MKL: 2021.1.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My program is performing oneapi::mkl::blas::row_major::gemm in loop, that is a function of the following form is called repeatedly with very large matrices and massively leaking memory (16Gig after a few seconds = 50 calls or so).&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;// C = A * B, assumes row-major matrices with B being transposed already
// Inputs = {A, B'}
int MatrixMul(
   sycl::queue * queue,
   std::shared_ptr&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt; &amp;amp;output,
   const std::vector&amp;lt;std::shared_ptr&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt;&amp;gt; &amp;amp;inputs,
   size_t M, size_t N, size_t K)
{
   output = std::make_shared&amp;lt;sycl::buffer&amp;lt;float, 1&amp;gt;&amp;gt;(M * N);
   oneapi::mkl::blas::row_major::gemm(
      *queue,
      oneapi::mkl::transpose::nontrans, oneapi::mkl::transpose::trans,
      M, N, K, 1.f,
      *inputs[0], K, *inputs[1], K,
      0.f, *output, N);

   return 0;
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I tried calling "&lt;SPAN class="kwd"&gt;mkl_free_buffers&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;(&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;)" / "mkl_disable_fast_mm()", or setting &lt;SAMP class="codeph"&gt;MKL_DISABLE_FAST_MM&lt;/SAMP&gt;=1, all to no avail. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="delim"&gt;I have replaced the call to gemm with my own sycl::handler performing naive gemm and it works just fine, not leaking any memory (albeit at half the speed -.-)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;What am I missing?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;Patrik&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:49:55 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1244527#M30621</guid>
      <dc:creator>siquus</dc:creator>
      <dc:date>2021-01-08T13:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1244528#M30622</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Device: Intel(R) Core(TM) i7-8750H CPU @ 2.20GH&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2021 13:54:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1244528#M30622</guid>
      <dc:creator>siquus</dc:creator>
      <dc:date>2021-01-08T13:54:03Z</dc:date>
    </item>
    <item>
      <title>Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1245474#M30656</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for reporting this issue. &lt;/P&gt;&lt;P&gt;Not sure if oneMKL gemm API is causing the memory leak. I will try to reproduce this issue in my environment and get back to you with the update.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rahul&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jan 2021 11:52:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1245474#M30656</guid>
      <dc:creator>RahulV_intel</dc:creator>
      <dc:date>2021-01-12T11:52:14Z</dc:date>
    </item>
    <item>
      <title>Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1247207#M30701</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Could you please share your complete reproducer code (including your input matrices and function calls)? &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rahul&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Jan 2021 06:39:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1247207#M30701</guid>
      <dc:creator>RahulV_intel</dc:creator>
      <dc:date>2021-01-18T06:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1247301#M30702</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;as I am not allowed to share my code, I tried writing sample programs which would reproduce the problem, but couldn't. Then I ran my original program and the problem was gone as well and I couldn't reproduce it. I am not aware of any library updates on my machine affecting the toolchain. I'll take a snapshot if the problem reappears.&lt;/P&gt;
&lt;P&gt;As for my original question: I did read that with MKL one needs to call&amp;nbsp;&lt;SPAN class="kwd"&gt;mkl_free_buffers&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;(&lt;/SPAN&gt;&lt;SPAN class="delim"&gt;) every now and then in a long-running program as MKL would not free unused buffers by itself. Seeing that my program and the test programs I wrote do not have this issue, I assume this does not hold for the dpcpp-runtime oneMKL?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="delim"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2021 12:05:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1247301#M30702</guid>
      <dc:creator>siquus</dc:creator>
      <dc:date>2021-01-18T12:05:27Z</dc:date>
    </item>
    <item>
      <title>Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1249629#M30753</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The DPCPP runtime does seem to free the MKL buffers automatically. However, for the sake of confirmation, I have forwarded this question to the MKL experts. They will get back to you on this.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rahul&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 25 Jan 2021 11:38:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1249629#M30753</guid>
      <dc:creator>RahulV_intel</dc:creator>
      <dc:date>2021-01-25T11:38:38Z</dc:date>
    </item>
    <item>
      <title>Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1289965#M31513</link>
      <description>&lt;P&gt;Hi Patrik,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When you use oneMKL with buffers, MKL buffers will automatically be freed when they are out of scope.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please let us know if this helps and if it does can we proceed further to close the thread?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Rajesh.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 15 Jun 2021 11:42:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1289965#M31513</guid>
      <dc:creator>MRajesh_intel</dc:creator>
      <dc:date>2021-06-15T11:42:40Z</dc:date>
    </item>
    <item>
      <title>Re:memory leak in oneapi::mkl::blas::row_major::gemm</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1291923#M31562</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Since we didn't hear back from you. We are closing this thread for now. If you require any further assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Have a Good day.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Rajesh.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Jun 2021 06:18:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/memory-leak-in-oneapi-mkl-blas-row-major-gemm/m-p/1291923#M31562</guid>
      <dc:creator>MRajesh_intel</dc:creator>
      <dc:date>2021-06-22T06:18:12Z</dc:date>
    </item>
  </channel>
</rss>

