<?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 Did you follow the in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108170#M5330</link>
    <description>&lt;P&gt;Did you follow the instruction to zero out mkl_num_threads_local before the end of any omp parallel region where it has been set?&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jun 2016 20:19:21 GMT</pubDate>
    <dc:creator>TimP</dc:creator>
    <dc:date>2016-06-24T20:19:21Z</dc:date>
    <item>
      <title>OpenMP and MKL</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108168#M5328</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a program where at one point I call a function.&lt;/P&gt;

&lt;P&gt;Inside this function I have OpenMP parallelization AND I have MKL/BLAS calls. I know that the BLAS are never called inside an OpenMP parallel block.&lt;/P&gt;

&lt;P&gt;I would like to specify the same number of threads be used in both parallel blocks in this function. So I call&lt;/P&gt;

&lt;P&gt;omp_set_num_threads(2);&lt;/P&gt;

&lt;P&gt;mkl_set_num_threads_local(2);&lt;/P&gt;

&lt;P&gt;The first call goes through with no problem. But the second crashes. This only happens in the Release version of the code. In the Debug version there is no crash.&lt;/P&gt;

&lt;P&gt;Can anybody tell me whether there is a problem with my calls above and what I should be doing differently?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 19:29:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108168#M5328</guid>
      <dc:creator>Gordon_F_</dc:creator>
      <dc:date>2016-06-24T19:29:19Z</dc:date>
    </item>
    <item>
      <title>A quick update: in order to</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108169#M5329</link>
      <description>&lt;P&gt;A quick update: in order to move forward I removed the omp_set_num_threads call. To my surprise, the code still crashes. I'm printing the value of the single argument to the console and the value being passed is indeed 2.&lt;/P&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 19:46:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108169#M5329</guid>
      <dc:creator>Gordon_F_</dc:creator>
      <dc:date>2016-06-24T19:46:23Z</dc:date>
    </item>
    <item>
      <title>Did you follow the</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108170#M5330</link>
      <description>&lt;P&gt;Did you follow the instruction to zero out mkl_num_threads_local before the end of any omp parallel region where it has been set?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 20:19:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108170#M5330</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2016-06-24T20:19:21Z</dc:date>
    </item>
    <item>
      <title>Tim,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108171#M5331</link>
      <description>&lt;P&gt;Tim,&lt;/P&gt;

&lt;P&gt;Thanks for the quick response. Could you send me a link to the documentation so I can get the proper context for your suggestion?&lt;/P&gt;

&lt;P&gt;This is the sequence of my parallel calls:&lt;/P&gt;

&lt;P&gt;(1) Serial code -&amp;gt; (2) Begin OpenMP Parallel code -&amp;gt; (3) Run parallel BLAS -&amp;gt; (4) End OpenMP Parallel code(2) -&amp;gt; (5) Begin OpenMP Parallel code -&amp;gt; (NO BLAS) -&amp;gt; End OpenMP Parallel code -&amp;gt; (6) Run parallel BLAS -&amp;gt; (7) Serial code&lt;/P&gt;

&lt;P&gt;I am given a number of threads to use (call it N). Step (2) has a "pragma omp for" loop with num_threads(m). I know that the threaded MKL BLAS on my machine loses steam rather quickly, so I limit the BLAS to never more than 4 threads. Anything else that I can do I use the variable "m" above. If the BLAS are using 2 threads, then "m" is set such that N = 2*m.&lt;/P&gt;

&lt;P&gt;Step 5 is in a separate library I have no control over. But I'm told that the BLAS are never called inside an OpenMP parallel code. So my thought was to set both omp_set_num_threads AND mkl_set_num_threads_local. It crashed. I thought the problem was setting both so I remove the omp_set_num_threads, but the problem persists. Step (5) is NOT called within a parallel OpenMP block.&lt;/P&gt;

&lt;P&gt;So, if I understand you correctly, I should be calling mkl_set_num_threads_local right before step (4). Is this correct?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 21:10:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108171#M5331</guid>
      <dc:creator>Gordon_F_</dc:creator>
      <dc:date>2016-06-24T21:10:08Z</dc:date>
    </item>
    <item>
      <title>Tim,</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108172#M5332</link>
      <description>&lt;P&gt;Tim,&lt;/P&gt;

&lt;P&gt;I did some reading here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://software.intel.com/en-us/node/471138" target="_blank"&gt;https://software.intel.com/en-us/node/471138&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I guess I understand your concern with resetting the number of threads. But it appears to me that the worst case scenario is that I end up using a different number of threads than expected.&lt;/P&gt;

&lt;P&gt;However, my problem is that the call to mkl_set_num_threads actually leads to a crash in the code. I did print the argument, and the value is indeed 2. So I think I'm setting a proper value.&lt;/P&gt;

&lt;P&gt;Is there any way to find out what my be causing the crash in this function?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;PS: To make matters worse, the entire code is run in MPI. Fortunately, the problem occurs even if I run the executable without using mpiexec - i.e., the MPI size is 1.&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2016 21:57:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108172#M5332</guid>
      <dc:creator>Gordon_F_</dc:creator>
      <dc:date>2016-06-24T21:57:46Z</dc:date>
    </item>
    <item>
      <title>Solved!</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108173#M5333</link>
      <description>&lt;P&gt;Solved!&lt;/P&gt;

&lt;P&gt;I had never touched this file with mkl calls before, so there was no #include "mkl.h" in it.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2016 15:18:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/OpenMP-and-MKL/m-p/1108173#M5333</guid>
      <dc:creator>Gordon_F_</dc:creator>
      <dc:date>2016-06-27T15:18:21Z</dc:date>
    </item>
  </channel>
</rss>

