<?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 Problem with setting number of threads for MKL in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772959#M777</link>
    <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;It was my fault! I had added some code to set affinity flags which was experimental code and did not work correctly. I removed that part and now the number of threads is set in a correct way.&lt;BR /&gt;&lt;BR /&gt;I have another question. Using environment variables (which I think is the simplest way), how can I bind each thread to the processor that is originally assigned when I run my code? What is the simplest way to avoid context switch and keep each thread to its process until the program ends? The affinity is not a big issue when I have two processors, but with four and eight processors, I think this would result a significant improvement.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;D.&lt;BR /&gt;</description>
    <pubDate>Thu, 11 Aug 2011 15:57:18 GMT</pubDate>
    <dc:creator>Dan4</dc:creator>
    <dc:date>2011-08-11T15:57:18Z</dc:date>
    <item>
      <title>Problem with setting number of threads for MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772956#M774</link>
      <description>Dear all,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I need to simply set number of threads for my tests to benchmark the code. I use this code to set number of threads:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[bash]procs=4;

omp_set_num_threads(procs);
mkl_set_num_threads(procs);
mkl_set_dynamic(0);
[/bash]&lt;/PRE&gt; &lt;BR /&gt;Using this part of code, I could successfully use 1 and 2 processors. But, when I intend to use 4 or 8 processors, the MKL routines, always use only 2 processors. For example the above code should allocate 4 processors, but it doesn't work correctly. When I try to use all available processors (16 processors), then it seems that it works OK too. I am using a computational node with two quad-core CPUs which gives 8 physical processors. The Hyper-Threading is also enabled on this system, but as far as I know, MKL only uses physical processors, so it shouldn't be any problem. I would also prefer not to disable Hyper-Threading, because the server is located somewhere else and it would be hard to manually restart it. Is there any solution for this?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;D.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Aug 2011 11:23:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772956#M774</guid>
      <dc:creator>Dan4</dc:creator>
      <dc:date>2011-08-11T11:23:13Z</dc:date>
    </item>
    <item>
      <title>Problem with setting number of threads for MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772957#M775</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;MKL function can use less number of threads if volume of data is not large enough.&lt;BR /&gt;Tosee how many threads are working please set in environment (`compact'below maybe deleted)&lt;BR /&gt; KMP_AFFINITY=verbose,compact&lt;BR /&gt;&lt;BR /&gt;Also, it would be helpful if you have a small reproducer of the problem to analyze it on our side.</description>
      <pubDate>Thu, 11 Aug 2011 11:55:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772957#M775</guid>
      <dc:creator>barragan_villanueva_</dc:creator>
      <dc:date>2011-08-11T11:55:45Z</dc:date>
    </item>
    <item>
      <title>Problem with setting number of threads for MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772958#M776</link>
      <description>Using AFFINITY environment variable, it seems that correct number of processors is allocated:&lt;BR /&gt;&lt;BR /&gt;OMP: Info #147: KMP_AFFINITY: Internal thread 0 bound to OS proc set {0,8}&lt;BR /&gt;OMP: Info #147: KMP_AFFINITY: Internal thread 1 bound to OS proc set {0,8}&lt;BR /&gt;OMP: Info #147: KMP_AFFINITY: Internal thread 2 bound to OS proc set {2,10}&lt;BR /&gt;OMP: Info #147: KMP_AFFINITY: Internal thread 3 bound to OS proc set {2,10}&lt;BR /&gt;&lt;BR /&gt;but when I run the code, I still see that only 2 processors is busy! Why even when it is explicitly shown that 4 processors will be used, MKL still uses only 2 processors? I use "mkl_set_dynamic(0)" to prevent dynamic processor management by MKL. So, why would MKL still decide on number of processors? My problems are not that small, but I also would like to deliberately run small problems using different number of processors to benchmark the code. Any solution for that?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;D.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Aug 2011 12:22:44 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772958#M776</guid>
      <dc:creator>Dan4</dc:creator>
      <dc:date>2011-08-11T12:22:44Z</dc:date>
    </item>
    <item>
      <title>Problem with setting number of threads for MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772959#M777</link>
      <description>Hi again,&lt;BR /&gt;&lt;BR /&gt;It was my fault! I had added some code to set affinity flags which was experimental code and did not work correctly. I removed that part and now the number of threads is set in a correct way.&lt;BR /&gt;&lt;BR /&gt;I have another question. Using environment variables (which I think is the simplest way), how can I bind each thread to the processor that is originally assigned when I run my code? What is the simplest way to avoid context switch and keep each thread to its process until the program ends? The affinity is not a big issue when I have two processors, but with four and eight processors, I think this would result a significant improvement.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;D.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Aug 2011 15:57:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772959#M777</guid>
      <dc:creator>Dan4</dc:creator>
      <dc:date>2011-08-11T15:57:18Z</dc:date>
    </item>
    <item>
      <title>Problem with setting number of threads for MKL</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772960#M778</link>
      <description>If I understand your question, I would think KMP_AFFINITY is the simplest way (although some of the options may be difficult to get right). &lt;BR /&gt;It makes the most difference when you have more than one last level cache, as you certainly do when you have multiple physical CPUs. The default (same as KMP_AFFINITY=none) leaves the affinity entirely to the OS scheduler, which generally is far from optimal on dual or quad CPU systems running a single job.&lt;BR /&gt;Processors is an ambiguous term; for some people it may mean logical processors (e.g. hyperthreads), but MKL thread library is set up to use only 1 thread per core, unless you over-ride that default.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Aug 2011 16:38:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-setting-number-of-threads-for-MKL/m-p/772960#M778</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-08-11T16:38:51Z</dc:date>
    </item>
  </channel>
</rss>

