<div dir="ltr">1M is the default stack size.  x86 and x86_64 have large stack size defaults, presumably because somebody at Intel decided that was better for some reason.<br><br>It would certainly improve the portability of the LLVM OpenMP runtime if the non-x86 default was 4M, at least on 64-bit systems.<br><br>From kmp.h:<br><br>#if KMP_ARCH_X86<br>#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))<br>#elif KMP_ARCH_X86_64<br>#define KMP_DEFAULT_STKSIZE ((size_t)(4 * 1024 * 1024))<br>#define KMP_BACKUP_STKSIZE ((size_t)(2 * 1024 * 1024))<br>#else<br>#define KMP_DEFAULT_STKSIZE ((size_t)(1024 * 1024))<br>#endif<br><br>If I was going to change it, I would group all the 32-bit and all the 64-bit architectures to be the same, at least until somebody proves that one of them deserves specialization.  I don't know what KMP_BACKUP_STKSIZE does but if that is x86_64-specific, then one can uncomment the relevant code below.<br><br>#if KMP_ARCH_X86 || KMP_ARCH_ARM || 





KMP_ARCH_MIPS<div>#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))<br>#elif KMP_ARCH_X86_64 || KMP_ARCH_AARCH64 || KMP_ARCH_PPC64 ||  KMP_ARCH_MIPS64<br>#define KMP_DEFAULT_STKSIZE ((size_t)(4 * 1024 * 1024))</div><div>//#if KMP_ARCH_X86_64<br><div>#define KMP_BACKUP_STKSIZE ((size_t)(2 * 1024 * 1024))</div><div>//#endif<br>#else<br>#define KMP_DEFAULT_STKSIZE ((size_t)(4*1024 * 1024))<br>#endif<br><div><br></div><div>Jeff<br><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 8, 2018 at 8:21 AM Cownie, James H via Openmp-dev <<a href="mailto:openmp-dev@lists.llvm.org">openmp-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="#0563C1" vlink="#954F72">
<div class="m_7956687119395904920WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">I cannot answer the question of why the PPC port chose a different stack size :-)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">But that doesn’t affect the solution, which, as you suggested, is to force the issue with
</span><span style="font-size:10.0pt;font-family:"Lucida Console";color:#1f497d">OMP_STACKSIZE</span><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">-- Jim<br>
<br>
Jim Cownie <<a href="mailto:james.h.cownie@intel.com" target="_blank">james.h.cownie@intel.com</a>><br>
CVCG/DPD/TCAR (Technical Computing, Analyzers, and Runtimes)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">Tel: +44 117 9071438</span><span style="color:#1f497d"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><a name="m_7956687119395904920______replyseparator"></a><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Simone Atzeni [mailto:<a href="mailto:satzeni@nvidia.com" target="_blank">satzeni@nvidia.com</a>]
<br>
<b>Sent:</b> Monday, October 8, 2018 4:16 PM<br>
<b>To:</b> Cownie, James H <<a href="mailto:james.h.cownie@intel.com" target="_blank">james.h.cownie@intel.com</a>><br>
<b>Cc:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a><br>
<b>Subject:</b> RE: Default value for OpenMP thread stacksize<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US">It looks though the LLVM OpenMP runtime has two different stack size for x86 (4096kb) and power (1024kb), so I thought that this is not implementation related but maybe architecture dependent?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Anyway, makes sense to set the OMP_STACKSIZE.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Simone<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Cownie, James H <<a href="mailto:james.h.cownie@intel.com" target="_blank">james.h.cownie@intel.com</a>>
<br>
<b>Sent:</b> Monday, October 8, 2018 5:05 PM<br>
<b>To:</b> Simone Atzeni <<a href="mailto:satzeni@nvidia.com" target="_blank">satzeni@nvidia.com</a>><br>
<b>Cc:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a><br>
<b>Subject:</b> RE: Default value for OpenMP thread stacksize<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">I do not know what the default OpenMP stack size is on PPC, but the rest of your logic seems sound, and setting
</span><span style="font-size:10.0pt;font-family:"Lucida Console";color:#1f497d">OMP_STACKSIZE</span><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d"> seems entirely reasonable.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">The standard says that the default stack size is “implementation defined”, so it is entirely reasonable that different implementations have different default
 values.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">-- Jim<br>
<br>
Jim Cownie <<a href="mailto:james.h.cownie@intel.com" target="_blank">james.h.cownie@intel.com</a>><br>
CVCG/DPD/TCAR (Technical Computing, Analyzers, and Runtimes)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d">Tel: +44 117 9071438</span><span style="color:#1f497d"><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Openmp-dev [<a href="mailto:openmp-dev-bounces@lists.llvm.org" target="_blank">mailto:openmp-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Simone Atzeni via Openmp-dev<br>
<b>Sent:</b> Monday, October 8, 2018 3:58 PM<br>
<b>To:</b> <a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a><br>
<b>Subject:</b> [Openmp-dev] Default value for OpenMP thread stacksize<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US">HI all,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">What’s the default size for the stack of the OpenMP threads in x86 and and ppc64 in the OpenMP runtime?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I have a Fortran program which allocates more than a 1MB on the stack for each thread. On x86 runs correctly, but on ppc64 it seg faults.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I am seeing that each thread in x86 has a stacksize of 4096kb while on ppc64 is 1024kb.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">If I increase the stacksize with OMP_STACKSIZE the program runs correctly also on Power, but it fails if I only set “ulimit -s unlimited”, which make sense since ulimit should only change the stacksize for the main thread
 but not for the other threads.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Is this the expected behavior and the correct solution is to set OMP_STACKSIZE?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Simone<u></u><u></u></span></p>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif">
<hr size="2" width="100%" align="center">
</span></div>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif">This email message is for the sole use of the intended recipient(s) and may contain confidential information.  Any unauthorized review, use, disclosure or distribution
 is prohibited.  If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.
<u></u><u></u></span></p>
</div>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span lang="EN-US" style="font-size:12.0pt;font-family:"Times New Roman",serif">
<hr size="2" width="100%" align="center">
</span></div>
</div>
<p>---------------------------------------------------------------------<br>
Intel Corporation (UK) Limited<br>
Registered No. 1134945 (England)<br>
Registered Office: Pipers Way, Swindon SN3 1RJ<br>
VAT No: 860 2173 47<u></u><u></u></p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.<u></u><u></u></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Corporation (UK) Limited<br>
Registered No. 1134945 (England)<br>
Registered Office: Pipers Way, Swindon SN3 1RJ<br>
VAT No: 860 2173 47</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></div>

_______________________________________________<br>
Openmp-dev mailing list<br>
<a href="mailto:Openmp-dev@lists.llvm.org" target="_blank">Openmp-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Jeff Hammond<br><a href="mailto:jeff.science@gmail.com" target="_blank">jeff.science@gmail.com</a><br><a href="http://jeffhammond.github.io/" target="_blank">http://jeffhammond.github.io/</a></div></div></div></div></div></div>