<?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 to both and thanks for the in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098656#M23726</link>
    <description>&lt;P&gt;Hi to both and thanks for the responses,&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;SPAN style="font-size: 12px;"&gt;If resource exhaustion occurs with increasing number of threads, decreasing omp_stacksize seems a more likely tactic.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I don't really understand why should I decrease the stack size. Nevertheless, I assigned "1m" to "KMP_STACKSIZE". The program crashed exactly at the same point.&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;SPAN style="font-size: 12px;"&gt;In case of C/C++ languages I use&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-weight: 700; font-size: 12px;"&gt;kmp_set_defaults&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;nbsp;function, like: ...&amp;nbsp;to set an environment variable(s), or set all environment variable(s) before starting your application.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;So, I assume that is not possible to change KMP_NUM_THREADS dinamically depending on the call that is done at each moment? I thought that the amount of OpenMP threads was defined by the environmental variable at the beggining of the parallel version.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;gt;&amp;gt;&amp;nbsp;What is a default value for BSIZE?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;BSIZE is equal to 4096 in this execution. The block created has 134MB. Is this important?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;gt;&amp;gt;&amp;nbsp;It is clear that application crashed with a default value for OMP stack size.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;For the moment, I tried to not change the value, set it to "1000m" and "1m". The thing is that the program crash always at the same point, so I tend to think that is not directly caused by this.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 06 May 2017 16:08:24 GMT</pubDate>
    <dc:creator>Ramon_A_</dc:creator>
    <dc:date>2017-05-06T16:08:24Z</dc:date>
    <item>
      <title>MKL crashing when creating too many OpenMP threads</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098649#M23719</link>
      <description>Hi,
I have 64 threads running on a Intel Xeon Phi 7230. Each thread can run the following MKL rountine:

&lt;PRE class="brush:python;" style="font-size: 13.008px;"&gt;
@constraint (ComputingUnits="${ComputingUnits}")
@task(returns=list)
def createBlock(BSIZE, MKLProc, diag):
    import os
    os.environ["KMP_AFFINITY"]="verbose"
    os.environ["MKL_NUM_THREADS"]=str(MKLProc)
    block = np.array(np.random.random((BSIZE, BSIZE)), dtype=np.double,copy=False)
    mb = np.matrix(block, dtype=np.double, copy=False)
    mb = mb + np.transpose(mb)
    if diag:
        mb = mb + 2*BSIZE*np.eye(BSIZE)
    return mb&lt;/PRE&gt;

MKL_NUM_THREADS is set to 64 in order to take advantage of all the cores. When executing the routine number 32, I obtain the following error:

&lt;PRE class="brush:sql;"&gt;
OMP: Error #34: System unable to allocate necessary resources for OMP thread:
OMP: System error #11: Resource temporarily unavailable
OMP: Hint: Try decreasing the value of OMP_NUM_THREADS.&lt;/PRE&gt;

&lt;P&gt;I've found here&amp;nbsp;https://software.intel.com/en-us/forums/intel-open-source-openmp-runtime-library/topic/622016 that threads are not destroyed so I can be reaching the thread limit in the machine. The thing is that, at each time, only one thread is running so only 64 OpenMP threads are awaken. My problem is that I'm running this code in a shared cluster so I should not recompile the library with my custom setting if possible. Is there a way to avoid this problem without decrasing the amount of threads running on the machine? I think that just having a fewer amount of threads i could avoid this problem but this is a part of a bigger program and I am really interested in keeping the 64 threads.&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;

&lt;P&gt;Ramon&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2017 18:01:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098649#M23719</guid>
      <dc:creator>Ramon_A_</dc:creator>
      <dc:date>2017-05-04T18:01:35Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;OMP: Error #34: System</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098650#M23720</link>
      <description>&amp;gt;&amp;gt;OMP: Error #34: System unable to allocate necessary resources for OMP thread:
&amp;gt;&amp;gt;OMP: System error #11: Resource temporarily unavailable
&amp;gt;&amp;gt;OMP: Hint: Try decreasing the value of OMP_NUM_THREADS.

You need to increase:

- A stack size for OpenMP threads ( a default value is exceeded in your case ), and
- A default stack size of your application ( Note: On a KNL server with a Linux Red Hat that I use 'ulimit -s' shows 512K ).</description>
      <pubDate>Thu, 04 May 2017 22:16:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098650#M23720</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2017-05-04T22:16:00Z</dc:date>
    </item>
    <item>
      <title>Hi Sergey,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098651#M23721</link>
      <description>&lt;P&gt;Hi Sergey,&lt;/P&gt;

&lt;P&gt;Thanks for the fast response.&lt;/P&gt;

&lt;P&gt;I've tryied what you suggested and, for the "&lt;SPAN style="font-size: 12px;"&gt;ulimit -s" call, I get "unlimited". On the other hand, I've set "&lt;/SPAN&gt;KMP_STACKSIZE" to "1000m". I get the same error at the same point.&lt;/P&gt;

&lt;P&gt;I forgot to specify that I'm using MKL through Numpy with Intel Python 2.7.11. As shown in the example code, all the variables are set before entering the first parallel region. Nevertheless, the module is imported before. Could this be a problem? Thanks in advance.&lt;/P&gt;

&lt;P&gt;Ramon&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 10:04:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098651#M23721</guid>
      <dc:creator>Ramon_A_</dc:creator>
      <dc:date>2017-05-05T10:04:50Z</dc:date>
    </item>
    <item>
      <title>If resource exhaustion occurs</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098652#M23722</link>
      <description>&lt;P&gt;If resource exhaustion occurs with increasing number of threads, decreasing omp_stacksize seems a more likely tactic. &amp;nbsp;Assuming it was working at 4m with a reasonable number of threads, changes by more than a factor of 2 seem ridiculous.&lt;/P&gt;</description>
      <pubDate>Fri, 05 May 2017 12:27:21 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098652#M23722</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2017-05-05T12:27:21Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;...all the variables are</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098653#M23723</link>
      <description>&amp;gt;&amp;gt;...all the variables are set before entering the first parallel region. Nevertheless, the module is imported before.
&amp;gt;&amp;gt;Could this be a problem?..

In case of C/C++ languages I use &lt;STRONG&gt;kmp_set_defaults&lt;/STRONG&gt; function, like:
...
	kmp_set_defaults( "KMP_AFFINITY=compact" );
...
to set an environment variable(s), or set all environment variable(s) before starting your application.</description>
      <pubDate>Fri, 05 May 2017 15:49:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098653#M23723</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2017-05-05T15:49:10Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;...np.array(np.random</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098654#M23724</link>
      <description>&amp;gt;&amp;gt;...np.array(np.random.random(( BSIZE, BSIZE ))...

What is a default value for BSIZE?</description>
      <pubDate>Fri, 05 May 2017 15:50:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098654#M23724</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2017-05-05T15:50:46Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;...Assuming it was working</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098655#M23725</link>
      <description>&amp;gt;&amp;gt;...Assuming it was working at 4m with a reasonable number of threads...

It is clear that application crashed with a default value for OMP stack size.</description>
      <pubDate>Sat, 06 May 2017 15:21:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098655#M23725</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2017-05-06T15:21:33Z</dc:date>
    </item>
    <item>
      <title>Hi to both and thanks for the</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098656#M23726</link>
      <description>&lt;P&gt;Hi to both and thanks for the responses,&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;SPAN style="font-size: 12px;"&gt;If resource exhaustion occurs with increasing number of threads, decreasing omp_stacksize seems a more likely tactic.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I don't really understand why should I decrease the stack size. Nevertheless, I assigned "1m" to "KMP_STACKSIZE". The program crashed exactly at the same point.&lt;/P&gt;

&lt;P&gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;SPAN style="font-size: 12px;"&gt;In case of C/C++ languages I use&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-weight: 700; font-size: 12px;"&gt;kmp_set_defaults&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;nbsp;function, like: ...&amp;nbsp;to set an environment variable(s), or set all environment variable(s) before starting your application.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;So, I assume that is not possible to change KMP_NUM_THREADS dinamically depending on the call that is done at each moment? I thought that the amount of OpenMP threads was defined by the environmental variable at the beggining of the parallel version.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;gt;&amp;gt;&amp;nbsp;What is a default value for BSIZE?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;BSIZE is equal to 4096 in this execution. The block created has 134MB. Is this important?&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;&amp;gt;&amp;gt;&amp;nbsp;It is clear that application crashed with a default value for OMP stack size.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;For the moment, I tried to not change the value, set it to "1000m" and "1m". The thing is that the program crash always at the same point, so I tend to think that is not directly caused by this.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 May 2017 16:08:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098656#M23726</guid>
      <dc:creator>Ramon_A_</dc:creator>
      <dc:date>2017-05-06T16:08:24Z</dc:date>
    </item>
    <item>
      <title>&gt;&gt;So, I assume that is not</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098657#M23727</link>
      <description>&amp;gt;&amp;gt;So, I assume that is not possible to change KMP_NUM_THREADS dinamically depending on the call that is done at each moment?
&amp;gt;&amp;gt;I thought that the amount of OpenMP threads was defined by the environmental variable at the beggining of the parallel version.

mkl_set_num_threads( num_of_threads ) allows to change number of OpenMP threads for processing.

&amp;gt;&amp;gt;&amp;gt;&amp;gt; What is a default value for BSIZE?
&amp;gt;&amp;gt;
&amp;gt;&amp;gt;BSIZE is equal to 4096 in this execution. The block created has 134MB. Is this important?

Yes and stack size should be greater than 134MB.

&amp;gt;&amp;gt;&amp;gt;&amp;gt; It is clear that application crashed with a default value for OMP stack size.
&amp;gt;&amp;gt;
&amp;gt;&amp;gt;For the moment, I tried to not change the value, set it to "1000m" and "1m". The thing is that the program crash always
&amp;gt;&amp;gt;at the same point, so I tend to think that is not directly caused by this.

Do a set of tests:

...
mkl_set_num_threads( 1 )
Set OpenMP stack size to 64MB
...
mkl_set_num_threads( 1 )
Set OpenMP stack size to 128MB
...
mkl_set_num_threads( 1 )
Set OpenMP stack size to 192MB
...
mkl_set_num_threads( 1 )
Set OpenMP stack size to 256MB
...

to find out what stack size is needed for a &lt;STRONG&gt;single OpenMP threaded&lt;/STRONG&gt; processing.</description>
      <pubDate>Mon, 08 May 2017 16:58:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/MKL-crashing-when-creating-too-many-OpenMP-threads/m-p/1098657#M23727</guid>
      <dc:creator>SergeyKostrov</dc:creator>
      <dc:date>2017-05-08T16:58:00Z</dc:date>
    </item>
  </channel>
</rss>

