[Openmp-dev] Default value for OpenMP thread stacksize

Jeff Hammond via Openmp-dev openmp-dev at lists.llvm.org
Mon Oct 8 09:25:19 PDT 2018


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.

It would certainly improve the portability of the LLVM OpenMP runtime if
the non-x86 default was 4M, at least on 64-bit systems.

>From kmp.h:

#if KMP_ARCH_X86
#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))
#elif KMP_ARCH_X86_64
#define KMP_DEFAULT_STKSIZE ((size_t)(4 * 1024 * 1024))
#define KMP_BACKUP_STKSIZE ((size_t)(2 * 1024 * 1024))
#else
#define KMP_DEFAULT_STKSIZE ((size_t)(1024 * 1024))
#endif

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.

#if KMP_ARCH_X86 || KMP_ARCH_ARM ||  KMP_ARCH_MIPS
#define KMP_DEFAULT_STKSIZE ((size_t)(2 * 1024 * 1024))
#elif KMP_ARCH_X86_64 || KMP_ARCH_AARCH64 || KMP_ARCH_PPC64 ||
 KMP_ARCH_MIPS64
#define KMP_DEFAULT_STKSIZE ((size_t)(4 * 1024 * 1024))
//#if KMP_ARCH_X86_64
#define KMP_BACKUP_STKSIZE ((size_t)(2 * 1024 * 1024))
//#endif
#else
#define KMP_DEFAULT_STKSIZE ((size_t)(4*1024 * 1024))
#endif

Jeff

On Mon, Oct 8, 2018 at 8:21 AM Cownie, James H via Openmp-dev <
openmp-dev at lists.llvm.org> wrote:

> I cannot answer the question of why the PPC port chose a different stack
> size :-)
>
> But that doesn’t affect the solution, which, as you suggested, is to force
> the issue with OMP_STACKSIZE.
>
>
>
> -- Jim
>
> Jim Cownie <james.h.cownie at intel.com>
> CVCG/DPD/TCAR (Technical Computing, Analyzers, and Runtimes)
>
> Tel: +44 117 9071438
>
>
>
> *From:* Simone Atzeni [mailto:satzeni at nvidia.com]
> *Sent:* Monday, October 8, 2018 4:16 PM
> *To:* Cownie, James H <james.h.cownie at intel.com>
> *Cc:* openmp-dev at lists.llvm.org
> *Subject:* RE: Default value for OpenMP thread stacksize
>
>
>
> 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?
>
>
>
> Anyway, makes sense to set the OMP_STACKSIZE.
>
>
>
> Thanks.
>
> Simone
>
>
>
> *From:* Cownie, James H <james.h.cownie at intel.com>
> *Sent:* Monday, October 8, 2018 5:05 PM
> *To:* Simone Atzeni <satzeni at nvidia.com>
> *Cc:* openmp-dev at lists.llvm.org
> *Subject:* RE: Default value for OpenMP thread stacksize
>
>
>
> I do not know what the default OpenMP stack size is on PPC, but the rest
> of your logic seems sound, and setting OMP_STACKSIZE seems entirely
> reasonable.
>
> The standard says that the default stack size is “implementation defined”,
> so it is entirely reasonable that different implementations have different
> default values.
>
>
>
> -- Jim
>
> Jim Cownie <james.h.cownie at intel.com>
> CVCG/DPD/TCAR (Technical Computing, Analyzers, and Runtimes)
>
> Tel: +44 117 9071438
>
>
>
> *From:* Openmp-dev [mailto:openmp-dev-bounces at lists.llvm.org
> <openmp-dev-bounces at lists.llvm.org>] *On Behalf Of *Simone Atzeni via
> Openmp-dev
> *Sent:* Monday, October 8, 2018 3:58 PM
> *To:* openmp-dev at lists.llvm.org
> *Subject:* [Openmp-dev] Default value for OpenMP thread stacksize
>
>
>
> HI all,
>
>
>
> What’s the default size for the stack of the OpenMP threads in x86 and and
> ppc64 in the OpenMP runtime?
>
>
>
> 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.
>
> I am seeing that each thread in x86 has a stacksize of 4096kb while on
> ppc64 is 1024kb.
>
> 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.
>
>
>
> Is this the expected behavior and the correct solution is to set
> OMP_STACKSIZE?
>
>
>
> Thanks.
>
> Simone
> ------------------------------
>
> 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.
> ------------------------------
>
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
> ---------------------------------------------------------------------
> Intel Corporation (UK) Limited
> Registered No. 1134945 (England)
> Registered Office: Pipers Way, Swindon SN3 1RJ
> VAT No: 860 2173 47
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
> _______________________________________________
> Openmp-dev mailing list
> Openmp-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev
>


-- 
Jeff Hammond
jeff.science at gmail.com
http://jeffhammond.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20181008/daa2aadb/attachment.html>


More information about the Openmp-dev mailing list