<?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 Changing MKL_NUM_THREADS at runtime in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789051#M2050</link>
    <description>You probably misunderstand the role of environmental variables. They provide a means of communication with the runtime of the compiler, or with the operating system. The runtime or the OS may be written to query the existence and value of an environmental variable, and decide to allocate threads, allocate more memory, abort a process, etc. The hardware itself knows NOTHING about environmental variables.&lt;BR /&gt;&lt;BR /&gt;Secondly, an environmental variable is not a semaphore. Your program inherits the environment that existed when the process was started. Subsequent changes to the environment are not communicated to your program.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;&amp;gt; If my machine has N processors, I create N Windows threads so that at a 
very high level I achieve the parallelization I want. At this point I 
would like to set MKL_NUM_THREADS to 1 as I have no more processor power
 left.&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;If all possible threads have been allocated, how can you do anything but wait for at least one thread to finish? If you terminate threads before they finished, would your results not be junk? &lt;BR /&gt;&lt;BR /&gt;Why don't you create N-1 (or N-M) threads, instead?</description>
    <pubDate>Thu, 14 Jul 2011 14:57:57 GMT</pubDate>
    <dc:creator>mecej4</dc:creator>
    <dc:date>2011-07-14T14:57:57Z</dc:date>
    <item>
      <title>Changing MKL_NUM_THREADS at runtime</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789048#M2047</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I have an application that uses Windows threads on a high level for parallelization. MKL is called on each thread.&lt;BR /&gt;&lt;BR /&gt;In certain critical sections of the program threads are executed serially (think mutex). In these critical sections MKL functions are also called.&lt;BR /&gt;&lt;BR /&gt;If my machine has N processors, I create N Windows threads so that at a very high level I achieve the parallelization I want. At this point I would like to set MKL_NUM_THREADS to 1 as I have no more processor power left.&lt;BR /&gt;&lt;BR /&gt;However, at the critical sections I would like to set MKL_NUM_THREADS to N.&lt;BR /&gt;&lt;BR /&gt;My question: is there a way to continuosly change the value of this environment variable? I'm concerned about when a MKL function will actually check the value of the environment variable. If I use "putenv" this may not be good enough.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Wed, 13 Jul 2011 22:19:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789048#M2047</guid>
      <dc:creator>mullervki</dc:creator>
      <dc:date>2011-07-13T22:19:25Z</dc:date>
    </item>
    <item>
      <title>Changing MKL_NUM_THREADS at runtime</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789049#M2048</link>
      <description>You can use the MKL function, mkl_set_num_threads() to set/modify the number of threads at run-time and this function has precedence overthe environment variable, MKL_NUM_THREADS.&lt;BR /&gt;&lt;BR /&gt;You can refer to section 5 ("Manging Performance and Memory") of the MKL user guide located at, &lt;A href="http://software.intel.com/en-us/articles/intel-math-kernel-library-documentation/"&gt;http://software.intel.com/en-us/articles/intel-math-kernel-library-documentation/&lt;/A&gt; for more details and code examples.</description>
      <pubDate>Thu, 14 Jul 2011 00:42:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789049#M2048</guid>
      <dc:creator>Vamsi_S_Intel</dc:creator>
      <dc:date>2011-07-14T00:42:52Z</dc:date>
    </item>
    <item>
      <title>Changing MKL_NUM_THREADS at runtime</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789050#M2049</link>
      <description>&lt;DIV id="tiny_quote"&gt;
                &lt;DIV style="margin-left: 2px; margin-right: 2px;"&gt;Quoting &lt;A rel="/en-us/services/profile/quick_profile.php?is_paid=&amp;amp;user_id=394928" class="basic" href="https://community.intel.com/en-us/profile/394928/"&gt;mullervki&lt;/A&gt;&lt;/DIV&gt;
                &lt;DIV style="background-color: #e5e5e5; padding: 5px; border: 1px; border-style: inset; margin-left: 2px; margin-right: 2px;"&gt;&lt;I&gt;&lt;BR /&gt;&lt;BR /&gt;However, at the critical sections I would like to set MKL_NUM_THREADS to N.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;I'm confused by this statement. Perhaps you don't mean critical section in the sense it normally has in the context of threading.&lt;BR /&gt;As Vamsi said, you should be able to call mkl_set_num_threads to set the number for the next MKL function call.</description>
      <pubDate>Thu, 14 Jul 2011 12:21:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789050#M2049</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2011-07-14T12:21:12Z</dc:date>
    </item>
    <item>
      <title>Changing MKL_NUM_THREADS at runtime</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789051#M2050</link>
      <description>You probably misunderstand the role of environmental variables. They provide a means of communication with the runtime of the compiler, or with the operating system. The runtime or the OS may be written to query the existence and value of an environmental variable, and decide to allocate threads, allocate more memory, abort a process, etc. The hardware itself knows NOTHING about environmental variables.&lt;BR /&gt;&lt;BR /&gt;Secondly, an environmental variable is not a semaphore. Your program inherits the environment that existed when the process was started. Subsequent changes to the environment are not communicated to your program.&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;&amp;gt; If my machine has N processors, I create N Windows threads so that at a 
very high level I achieve the parallelization I want. At this point I 
would like to set MKL_NUM_THREADS to 1 as I have no more processor power
 left.&lt;BR /&gt;&lt;BR /&gt;&lt;/I&gt;If all possible threads have been allocated, how can you do anything but wait for at least one thread to finish? If you terminate threads before they finished, would your results not be junk? &lt;BR /&gt;&lt;BR /&gt;Why don't you create N-1 (or N-M) threads, instead?</description>
      <pubDate>Thu, 14 Jul 2011 14:57:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Changing-MKL-NUM-THREADS-at-runtime/m-p/789051#M2050</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2011-07-14T14:57:57Z</dc:date>
    </item>
  </channel>
</rss>

