Added propagation of not big initial stack size of master thread to workers.
Currently implemented only for non-Windows 64-bit platforms.
Differential Revision: https://reviews.llvm.org/D62488
llvm-svn: 362618
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index 7eb782a..b1cf829 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -1833,6 +1833,17 @@
__kmp_xproc = __kmp_get_xproc();
+#if ! KMP_32_BIT_ARCH
+ struct rlimit rlim;
+ // read stack size of calling thread, save it as default for worker threads;
+ // this should be done before reading environment variables
+ status = getrlimit(RLIMIT_STACK, &rlim);
+ if (status == 0) { // success?
+ __kmp_stksize = rlim.rlim_cur;
+ __kmp_check_stksize(&__kmp_stksize); // check value and adjust if needed
+ }
+#endif /* KMP_32_BIT_ARCH */
+
if (sysconf(_SC_THREADS)) {
/* Query the maximum number of threads */