[Openmp-commits] [PATCH] D11159: Fixing the stack offset functionality
jonathan.l.peyton at intel.com
Mon Jul 13 14:01:13 PDT 2015
jlpeyton created this revision.
jlpeyton added a reviewer: hfinkel.
jlpeyton added subscribers: llvm-commits, openmp-commits.
jlpeyton set the repository for this revision to rL LLVM.
The padding variable used for setting a stack offset (from a page boundary) was dead code as pointed out by Hal a while back. This change fixes that by making the pointer a volatile. Also, the stacksize is doubled based of observations of requesting staggered stacksizes. It was seen on some machines that an offset was created during thread creation (before the dummy alloca() of padding) when a staggered stack size (not a multiple of a page) was requested. Because this offset was created before the alloca(), the alloca() would actually eliminate the offset. To avoid this, we added a multiple of two to the stacksize increase. This way, we can then have the stacksize be as large as the user requested, and also retain the stack offset.
@@ -684,7 +684,7 @@
#endif /* KMP_BLOCK_SIGNALS */
#if KMP_OS_LINUX || KMP_OS_FREEBSD
- void *padding = 0;
+ void * volatile padding = 0;
@@ -1012,8 +1012,13 @@
}; // if
- /* Set stack size for this thread now. */
- stack_size += gtid * __kmp_stkoffset;
+ /* Set stack size for this thread now.
+ * The multiple of 2 is there because on some machines, requesting an unusual stacksize
+ * causes the thread to have an offset before the dummy alloca() takes place to create the
+ * offset. Since we want the user to have a sufficient stacksize AND support a stack offset, we
+ * alloca() twice the offset so that the upcoming alloca() does not eliminate any premade
+ * offset, and also gives the user the stack space they requested for all threads */
+ stack_size += gtid * __kmp_stkoffset * 2;
KA_TRACE( 10, ( "__kmp_create_worker: T#%d, default stacksize = %lu bytes, "
"__kmp_stksize = %lu bytes, final stacksize = %lu bytes\n",
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1345 bytes
Desc: not available
More information about the Openmp-commits