<?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 Hi MiauCat, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148014#M26875</link>
    <description>&lt;P&gt;Hi MiauCat,&lt;/P&gt;

&lt;P&gt;thanks for the suggestion. The problem was escalated to our doc team.&lt;/P&gt;

&lt;P&gt;About the &lt;EM&gt;mkl_set_num_threads( &lt;/EM&gt;really_high_value &lt;EM&gt;);&amp;nbsp;&amp;nbsp;&lt;/EM&gt;is called at higher level and outside "my" control,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;you can use mkl_get_max_threads&lt;SPAN class="sep"&gt;() to&amp;nbsp;get the &amp;nbsp;&lt;/SPAN&gt;really_high_value&lt;/P&gt;

&lt;P&gt;or use &amp;nbsp;&lt;EM&gt;mkl_set_num_threads(&amp;nbsp;wanted number) to set the number. &lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;If you want to get the number of physical cores of system, maybe use&amp;nbsp;OpenMP function, &amp;nbsp;OMP_GET_NUM_PROCS (OP).which should be ok in mkl application.&amp;nbsp; ( for your reference&amp;nbsp;&lt;A href="https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/302866"&gt;https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/302866&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;BR /&gt;
	Ying&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jul 2017 03:19:42 GMT</pubDate>
    <dc:creator>Ying_H_Intel</dc:creator>
    <dc:date>2017-07-25T03:19:42Z</dc:date>
    <item>
      <title>mkl_get_max_threads() return value unclear</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148008#M26869</link>
      <description>&lt;P&gt;I'm a bit confused about the method&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mkl_get_max_threads()&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;According to the help documentation, it should return the number of physical cores (provided that &lt;EM&gt;dynamic adjustment &lt;/EM&gt;is enabled).&lt;/P&gt;

&lt;P&gt;However, when I run the code below on my 4-core machine, I get back "1" for "nT". How so?&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;			if ( 1 == mkl_get_dynamic( ) )
			{
				long nT = mkl_get_max_threads();
				mkl_set_num_threads( nT );
			}&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2017 09:22:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148008#M26869</guid>
      <dc:creator>MiauCat</dc:creator>
      <dc:date>2017-07-14T09:22:07Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148009#M26870</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Right, generally, it returns physical cores.&amp;nbsp; What is you CPU type or do you set OMP_NUM_THREAD in environment?&lt;/P&gt;

&lt;P&gt;Could you please add the cpu check code as below and share your output?&lt;/P&gt;

&lt;P&gt;or what exact MKL function are you calling? you may&lt;/P&gt;

&lt;P&gt;export MKL_VERBOSE=1&lt;/P&gt;

&lt;P&gt;run your exe.&lt;/P&gt;

&lt;P&gt;and share the output&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;&lt;SPAN class="fontstyle0"&gt;&lt;FONT size="2"&gt;MKLVersion Version;&lt;BR /&gt;
	mkl_get_version(&amp;amp;Version);&lt;BR /&gt;
	printf("Major version: %d\n",Version.MajorVersion);&lt;BR /&gt;
	printf("Minor version: %d\n",Version.MinorVersion);&lt;BR /&gt;
	printf("Update version: %d\n",Version.UpdateVersion);&lt;BR /&gt;
	printf("Product status: %s\n",Version.ProductStatus);&lt;BR /&gt;
	printf("Build: %s\n",Version.Build);&lt;BR /&gt;
	printf("Platform: %s\n",Version.Platform);&lt;BR /&gt;
	printf("Processor optimization: %s\n",Version.Processor);&lt;BR /&gt;
	printf("================================================================\n");&lt;BR /&gt;
	printf("\n");&lt;/FONT&gt;&lt;/SPAN&gt;&lt;BR style="text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; font-style: normal; font-variant: normal; font-weight: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" /&gt;
	&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 04:02:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148009#M26870</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2017-07-19T04:02:48Z</dc:date>
    </item>
    <item>
      <title>Thanks Ying.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148010#M26871</link>
      <description>&lt;P&gt;Thanks Ying.&lt;/P&gt;

&lt;P&gt;I've placed your code (plus a check for the environmental variables) in a separate piece of code and run it, and it seems to do the &lt;STRONG&gt;correct&lt;/STRONG&gt; thing. However, the piece of code I've submitted earlier did return &lt;STRONG&gt;1 &lt;/STRONG&gt;for sure.&lt;/P&gt;

&lt;P&gt;Unfortunately, that piece of code is scraped by now. I need to redo it for testing. It is not unlikely that the application (of which the code is only a small part of) set anything OMP related beforehand - but that (in theory) shouldn't influence the outcome, or should it?&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;Major version: 2017&lt;BR /&gt;
		Minor version: 0&lt;BR /&gt;
		Update version: 3&lt;BR /&gt;
		Product status: Product&lt;BR /&gt;
		Build: 20170413&lt;BR /&gt;
		Platform: Intel(R) 64 architecture&lt;BR /&gt;
		Processor optimization: Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) enabled processors&lt;BR /&gt;
		================================================================&lt;/P&gt;

	&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; mkl_get_dynamic( ) returned: 1&lt;BR /&gt;
		&amp;nbsp;&amp;nbsp; &amp;nbsp; mkl_get_max_threads( ) returned: 4&lt;BR /&gt;
		================================================================&lt;/P&gt;

	&lt;P&gt;OMP_NUM_THREAD:&amp;nbsp; -NOT SET-&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="system.jpg"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/9605iB8FC8F7BEFDB5697/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="system.jpg" alt="system.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2017 06:41:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148010#M26871</guid>
      <dc:creator>MiauCat</dc:creator>
      <dc:date>2017-07-19T06:41:47Z</dc:date>
    </item>
    <item>
      <title>Hi Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148011#M26872</link>
      <description>&lt;P&gt;Hi Ying,&lt;/P&gt;

&lt;P&gt;did some more testing and can reproduce my problem.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;The reason I want to use mkl_get_max_threads( ) in a first place is to "reset" the threads to the normal situation after having it forced to use 1 thread only previosly. However, the moment I've set the mkl threads to 1, the according commands can not recover my physical cores anymore:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;mkl_set_num_threads( 1 );
&amp;lt;...some code...&amp;gt;

if ( 1 == mkl_get_dynamic( ) )
{
	&amp;lt;...debug output code...&amp;gt;

	long nT = mkl_get_max_threads( );
	mkl_set_num_threads( nT );	
}

&lt;/PRE&gt;

&lt;P&gt;I do &lt;STRONG&gt;not&lt;/STRONG&gt; reset the MKL threads because nT is still 1. The debug output is:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;PRE class="brush:cpp;"&gt;Major version: 2017
Minor version: 0
Update version: 3
Product status: Product
Build: 20170413
Platform: Intel(R) 64 architecture
Processor optimization: Intel(R) Streaming SIMD Extensions 2 (Intel(R) SSE2) enabled processors
================================================================

	 mkl_get_dynamic( ) returned: 1
	 mkl_get_max_threads( ) returned: 1
================================================================

	 OMP_NUM_THREAD: &lt;/PRE&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 19 Jul 2017 07:16:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148011#M26872</guid>
      <dc:creator>MiauCat</dc:creator>
      <dc:date>2017-07-19T07:16:53Z</dc:date>
    </item>
    <item>
      <title>Hi MiauCat,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148012#M26873</link>
      <description>&lt;P&gt;Hi MiauCat,&lt;/P&gt;

&lt;P&gt;Right, that should be the root cause.&amp;nbsp; So you may reset the matrix&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
	long nT = mkl_get_max_threads( );&lt;/P&gt;

&lt;P&gt;mkl_set_num_threads( 1 );&lt;BR /&gt;
	&amp;lt;...some code...&amp;gt;&lt;BR /&gt;
	&lt;BR /&gt;
	mkl_set_num_threads( nT );&lt;/P&gt;

&lt;P&gt;The function is based on OpenMP function. so it detected the current OpenMP thread number.&amp;nbsp;&amp;nbsp; The documentation seems need to rewording.&amp;nbsp; We will check this and fix&amp;nbsp;them. &amp;nbsp;&lt;/P&gt;

&lt;TABLE class="NormalTable"&gt;
	&lt;TBODY&gt;
		&lt;TR&gt;
			&lt;TD width="360"&gt;&lt;SPAN class="fontstyle0"&gt;&lt;FONT face="Verdana" size="2"&gt;The maximum number of threads for Intel MKL functions to&lt;BR /&gt;
				use in internal parallel regions.&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/TD&gt;
		&lt;/TR&gt;
	&lt;/TBODY&gt;
&lt;/TABLE&gt;

&lt;P&gt;Thank you!&lt;/P&gt;

&lt;P&gt;Ying&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 06:50:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148012#M26873</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2017-07-20T06:50:38Z</dc:date>
    </item>
    <item>
      <title>Hi Ying,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148013#M26874</link>
      <description>&lt;P&gt;Hi Ying,&lt;/P&gt;

&lt;P&gt;thanks for clearing this up. Yes I also think that the documention needs a bit of update in this case - maybe with a nice example?&lt;/P&gt;

&lt;P&gt;In particular the &lt;STRONG&gt;Description&lt;/STRONG&gt; section was confusing in&amp;nbsp;&lt;A href="https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-get-max-threads"&gt;https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-get-max-threads&lt;/A&gt; where it currently just reads:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P&gt;If the dynamic adjustment is enabled, the function returns the number of physical cores on your system.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But I also think there should be an example of "how to reset" properly in &lt;A href="https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-set-num-threads"&gt;https://software.intel.com/en-us/mkl-developer-reference-fortran-mkl-set-num-threads&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;A related question: In case the &lt;EM&gt;mkl_set_num_threads(); &lt;/EM&gt;is called at higher level and outside "my" control, what to do?&lt;BR /&gt;
	Is it a valid or a stupid idea to use:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;mkl_set_num_threads( really_high_value );&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2017 07:17:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148013#M26874</guid>
      <dc:creator>MiauCat</dc:creator>
      <dc:date>2017-07-20T07:17:57Z</dc:date>
    </item>
    <item>
      <title>Hi MiauCat,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148014#M26875</link>
      <description>&lt;P&gt;Hi MiauCat,&lt;/P&gt;

&lt;P&gt;thanks for the suggestion. The problem was escalated to our doc team.&lt;/P&gt;

&lt;P&gt;About the &lt;EM&gt;mkl_set_num_threads( &lt;/EM&gt;really_high_value &lt;EM&gt;);&amp;nbsp;&amp;nbsp;&lt;/EM&gt;is called at higher level and outside "my" control,&amp;nbsp;&lt;/P&gt;

&lt;P&gt;you can use mkl_get_max_threads&lt;SPAN class="sep"&gt;() to&amp;nbsp;get the &amp;nbsp;&lt;/SPAN&gt;really_high_value&lt;/P&gt;

&lt;P&gt;or use &amp;nbsp;&lt;EM&gt;mkl_set_num_threads(&amp;nbsp;wanted number) to set the number. &lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;If you want to get the number of physical cores of system, maybe use&amp;nbsp;OpenMP function, &amp;nbsp;OMP_GET_NUM_PROCS (OP).which should be ok in mkl application.&amp;nbsp; ( for your reference&amp;nbsp;&lt;A href="https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/302866"&gt;https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/302866&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;BR /&gt;
	Ying&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jul 2017 03:19:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/mkl-get-max-threads-return-value-unclear/m-p/1148014#M26875</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2017-07-25T03:19:42Z</dc:date>
    </item>
  </channel>
</rss>

