<?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 nested parallelism using OpenMP and MKL fft  in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068361#M22049</link>
    <description>&lt;P&gt;Hi folks.&lt;/P&gt;

&lt;P&gt;I had a problem with nested parallelism using OpenMP and MKl fft.&lt;/P&gt;

&lt;P&gt;The part of my code that uses MKL calls within omp parallel region looks like this:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;/////////////////////////////&lt;/P&gt;

&lt;P&gt;omp_set_nested(1);&lt;/P&gt;

&lt;P&gt;omp_set_num_threads(m);&lt;/P&gt;

&lt;P&gt;mkl_domain_set_num_threads(n, MKL_DOMAIN_FFT);&lt;/P&gt;

&lt;P&gt;#pragma omp parallel&lt;/P&gt;

&lt;P&gt;{&lt;/P&gt;

&lt;P&gt;//some code&lt;/P&gt;

&lt;P&gt;#pragma omp single&lt;/P&gt;

&lt;P&gt;{&lt;/P&gt;

&lt;P&gt;//call of the fft&lt;/P&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;/////////////////////////////&lt;/P&gt;

&lt;P&gt;The problem is that when m &amp;gt; 1 fft call is working with only 1 thread regardless of value of n.&lt;/P&gt;

&lt;P&gt;&lt;SPAN class="short_text" id="result_box" tabindex="-1" lang="en"&gt;&lt;SPAN&gt;I will be grateful for any help.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN class="short_text" tabindex="-1" lang="en"&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jan 2017 15:09:34 GMT</pubDate>
    <dc:creator>Mihran_V_</dc:creator>
    <dc:date>2017-01-12T15:09:34Z</dc:date>
    <item>
      <title>Problem with nested parallelism using OpenMP and MKL fft</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068361#M22049</link>
      <description>&lt;P&gt;Hi folks.&lt;/P&gt;

&lt;P&gt;I had a problem with nested parallelism using OpenMP and MKl fft.&lt;/P&gt;

&lt;P&gt;The part of my code that uses MKL calls within omp parallel region looks like this:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;/////////////////////////////&lt;/P&gt;

&lt;P&gt;omp_set_nested(1);&lt;/P&gt;

&lt;P&gt;omp_set_num_threads(m);&lt;/P&gt;

&lt;P&gt;mkl_domain_set_num_threads(n, MKL_DOMAIN_FFT);&lt;/P&gt;

&lt;P&gt;#pragma omp parallel&lt;/P&gt;

&lt;P&gt;{&lt;/P&gt;

&lt;P&gt;//some code&lt;/P&gt;

&lt;P&gt;#pragma omp single&lt;/P&gt;

&lt;P&gt;{&lt;/P&gt;

&lt;P&gt;//call of the fft&lt;/P&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;}&lt;/P&gt;

&lt;P&gt;/////////////////////////////&lt;/P&gt;

&lt;P&gt;The problem is that when m &amp;gt; 1 fft call is working with only 1 thread regardless of value of n.&lt;/P&gt;

&lt;P&gt;&lt;SPAN class="short_text" id="result_box" tabindex="-1" lang="en"&gt;&lt;SPAN&gt;I will be grateful for any help.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN class="short_text" tabindex="-1" lang="en"&gt;&lt;SPAN&gt;Regards.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 15:09:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068361#M22049</guid>
      <dc:creator>Mihran_V_</dc:creator>
      <dc:date>2017-01-12T15:09:34Z</dc:date>
    </item>
    <item>
      <title>Hi Mihran</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068362#M22050</link>
      <description>&lt;P&gt;Hi Mihran&lt;/P&gt;

&lt;P&gt;How about&amp;nbsp; Set the &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;MKL_DYNAMIC&lt;/FONT&gt;&lt;/SPAN&gt; environment variable to &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;FALSE&lt;/FONT&gt;&lt;/SPAN&gt; or call &lt;CODE&gt;&lt;FONT face="Courier New"&gt;mkl_set_dynamic(0)&lt;/FONT&gt;&lt;/CODE&gt; to use the suggested number of OpenMP threads whenever the algorithms permit and regardless of OpenMP overhead and data locality.&lt;/P&gt;

&lt;P&gt;Basically, the Intel MKL-specific threading controls take precedence over their OpenMP equivalents.&amp;nbsp; But when MKL&amp;nbsp;was in nested OpenMP parallel region , we recommend to use 1 mkl thread for better performance.&amp;nbsp; and that is reason why MKL run in sequential model by default.&lt;/P&gt;

&lt;P&gt;But &amp;nbsp;you can control them&amp;nbsp; as MKL developer&amp;nbsp;guide mentioned: &amp;nbsp;&lt;A href="https://software.intel.com/en-us/node/528550"&gt;&lt;U&gt;&lt;FONT color="#0066cc"&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/A&gt;&lt;A href="https://software.intel.com/en-us/node/528550" target="_blank"&gt;https://software.intel.com/en-us/node/528550&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If your application uses OpenMP* threading, you may need to provide additional settings:&lt;!-- --&gt;&lt;/P&gt;

&lt;UL id="GUID-7258149D-FD57-4BFC-B9AD-5E5E764FCF24"&gt;
	&lt;LI&gt;Set the environment variable &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;OMP_NESTED=TRUE&lt;/FONT&gt;&lt;/SPAN&gt;, or alternatively call &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;omp_set_nested(1)&lt;/FONT&gt;&lt;/SPAN&gt;, to enable OpenMP nested parallelism.&lt;/LI&gt;
	&lt;LI&gt;Set the environment variable &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;MKL_DYNAMIC=FALSE&lt;/FONT&gt;&lt;/SPAN&gt;, or alternatively call &lt;SPAN class="keyword"&gt;&lt;FONT face="Courier New"&gt;mkl_set_dynamic(0)&lt;/FONT&gt;&lt;/SPAN&gt;, to prevent Intel MKL from dynamically reducing the number of OpenMP threads in nested parallel regions.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;Some nested parallel tips in MKL user guide for your reference:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://software.intel.com/en-us/node/528546#92D6DAD0-A858-4824-9A90-AC2AD2A9C2E1"&gt;&lt;U&gt;&lt;FONT color="#0066cc"&gt;&lt;/FONT&gt;&lt;/U&gt;&lt;/A&gt;&lt;A href="https://software.intel.com/en-us/node/528546#92D6DAD0-A858-4824-9A90-AC2AD2A9C2E1" target="_blank"&gt;https://software.intel.com/en-us/node/528546#92D6DAD0-A858-4824-9A90-AC2AD2A9C2E1&lt;/A&gt;&lt;/P&gt;

&lt;TABLE width="100%" id="GUID-51FE8B86-A4CF-4263-9868-48E8CE788F37" border="1" rules="all" frame="hsides" cellpadding="4" summary=""&gt;
	&lt;TBODY&gt;
		&lt;TR&gt;
			&lt;TD width="30%" class="cellrowborder" valign="top" headers="d66900e59"&gt;
				&lt;P id="GUID-A2831981-B130-4590-8C3D-17B94D51B890"&gt;&lt;A name="GUID-A2831981-B130-4590-8C3D-17B94D51B890"&gt;&lt;!-- --&gt;&lt;/A&gt;You parallelize the program using OpenMP directives and/or pragmas and compile the program using a non-Intel compiler.&lt;/P&gt;
			&lt;/TD&gt;
			&lt;TD width="70%" class="row-nocellborder" valign="top" headers="d66900e65"&gt;
				&lt;P id="GUID-4DDB9BB9-8BC3-4080-85C6-9311FE6CA4A9"&gt;&lt;A name="GUID-4DDB9BB9-8BC3-4080-85C6-9311FE6CA4A9"&gt;&lt;!-- --&gt;&lt;/A&gt; To avoid simultaneous activities of multiple threading RTLs, link the program against the Intel MKL threading library that matches the compiler you use (see &lt;A href="https://software.intel.com/node/8ab17c16-96e6-40c1-ac88-480f2cb6f28f"&gt;&lt;FONT color="#0071c5"&gt;&lt;U&gt;Linking Examples&lt;/U&gt;&lt;/FONT&gt;&lt;/A&gt; on how to do this). If this is not possible, use Intel MKL in the sequential mode. To do this, you should link with the appropriate threading library: &lt;SPAN class="filepath" id="GUID-5F2C6789-D090-4ED1-B507-5319E9FF24E0"&gt;&lt;A name="GUID-5F2C6789-D090-4ED1-B507-5319E9FF24E0"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;lib&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="filepath" id="GUID-CC6B2E91-58D0-4918-99D0-533BCA0462EC"&gt;&lt;A name="GUID-CC6B2E91-58D0-4918-99D0-533BCA0462EC"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;mkl_sequential.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="filepath" id="GUID-35DB5B15-0664-43F8-840E-952294DB9021"&gt;&lt;A name="GUID-35DB5B15-0664-43F8-840E-952294DB9021"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;a&lt;/FONT&gt;&lt;/SPAN&gt; or &lt;SPAN class="filepath" id="GUID-677B4B94-301E-4D78-A51B-0C43ADC23805"&gt;&lt;A name="GUID-677B4B94-301E-4D78-A51B-0C43ADC23805"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;lib&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="filepath" id="GUID-CF2E658E-9ACE-47A8-8FEE-15593A6A537F"&gt;&lt;A name="GUID-CF2E658E-9ACE-47A8-8FEE-15593A6A537F"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;mkl_sequential.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;SPAN class="filepath" id="GUID-38F5F6CE-E9B9-4508-8245-5ECAE6BAE62D"&gt;&lt;A name="GUID-38F5F6CE-E9B9-4508-8245-5ECAE6BAE62D"&gt;&lt;!-- --&gt;&lt;/A&gt;&lt;FONT face="Courier New"&gt;so&lt;/FONT&gt;&lt;/SPAN&gt; (see &lt;A href="https://software.intel.com/node/36d380c6-22fd-4282-885d-aa53c498e881"&gt;&lt;FONT color="#0071c5"&gt;&lt;U&gt;Appendix C: Directory Structure in Detail&lt;/U&gt;&lt;/FONT&gt;&lt;/A&gt;).&lt;/P&gt;
			&lt;/TD&gt;
		&lt;/TR&gt;
	&lt;/TBODY&gt;
&lt;/TABLE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 01:39:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068362#M22050</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2017-01-13T01:39:48Z</dc:date>
    </item>
    <item>
      <title>Hi Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068363#M22051</link>
      <description>&lt;P&gt;Hi Ying,&lt;/P&gt;

&lt;P&gt;Thank you a lot for your response. It was very informative and mkl_set_dynamic(0) helped me, so now my code works as I want.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Mihran.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 09:27:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Problem-with-nested-parallelism-using-OpenMP-and-MKL-fft/m-p/1068363#M22051</guid>
      <dc:creator>Mihran_V_</dc:creator>
      <dc:date>2017-01-13T09:27:54Z</dc:date>
    </item>
  </channel>
</rss>

